Skip to content

Commit

Permalink
fix wrong way to get face
Browse files Browse the repository at this point in the history
  • Loading branch information
MrXiaoM committed Feb 16, 2025
1 parent d6f778f commit c1a24de
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/main/java/top/mrxiaom/catsense/ContainerListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,9 @@ public void onBlockClick(PlayerInteractEvent event) {
|| (player.isSneaking() && event.getAction().equals(Action.LEFT_CLICK_BLOCK)))) {
Sign sign = (Sign) block.getState();
// 获取牌子贴着的方块
block = block.getRelative(((org.bukkit.material.Sign) sign.getData()).getFacing().getOppositeFace(), 1);
BlockFace face = getFace(sign);
if (face == null) return;
block = block.getRelative(face.getOppositeFace(), 1);
if (!isTargetContainer(block)) return;
for (String line : sign.getLines()) {
if (line.equals(signKey)) {
Expand Down
6 changes: 4 additions & 2 deletions src/main/java/top/mrxiaom/catsense/LocksListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,9 @@ public void onSignChange(SignChangeEvent event) {
&& header.equals(event.getLine(0))) {
Player player = event.getPlayer();
// 获取贴着牌子的方块另一边是否有收费门牌子
Block oppositeBlock = event.getBlock().getRelative(((org.bukkit.material.Sign) event.getBlock().getState().getData()).getFacing().getOppositeFace(), 2);
BlockFace signFace = getFace(event.getBlock().getState());
if (signFace == null) return;
Block oppositeBlock = event.getBlock().getRelative(signFace.getOppositeFace(), 2);
if(oppositeBlock.getType().name().contains("WALL_SIGN")) {
BlockState sign = oppositeBlock.getState();
if ((sign instanceof Sign) && ((Sign) sign).getLine(0).equalsIgnoreCase(headerCheck)) {
Expand Down Expand Up @@ -155,7 +157,7 @@ public static boolean isTheSameFacing(Block block, Sign sign) {
}

@SuppressWarnings({"deprecation"})
public static BlockFace getFace(Sign sign) {
public static BlockFace getFace(BlockState sign) {
if (isPresent("org.bukkit.block.data.BlockData")) {
BlockData data = sign.getBlockData();
if (data instanceof org.bukkit.block.data.Directional) {
Expand Down

0 comments on commit c1a24de

Please sign in to comment.