diff --git a/src/main/java/dev/dubhe/anvilcraft/client/event/ClientBlockEventListener.java b/src/main/java/dev/dubhe/anvilcraft/client/event/ClientBlockEventListener.java index c3dc315ed..90be171f3 100644 --- a/src/main/java/dev/dubhe/anvilcraft/client/event/ClientBlockEventListener.java +++ b/src/main/java/dev/dubhe/anvilcraft/client/event/ClientBlockEventListener.java @@ -38,7 +38,7 @@ public static void anvilHammerUse(@NotNull PlayerInteractEvent.RightClickBlock e if (AnvilHammerItem.ableToUseAnvilHammer(event.getLevel(), event.getPos(), event.getEntity())) { Block b = event.getLevel().getBlockState(event.getPos()).getBlock(); if ((b instanceof IHammerRemovable || b.defaultBlockState().is(ModBlockTags.HAMMER_REMOVABLE)) - && !(b instanceof IHammerChangeable) + && !(b instanceof IHammerChangeable || b.defaultBlockState().is(ModBlockTags.HAMMER_CHANGEABLE)) && !event.getEntity().isShiftKeyDown() ) { return; diff --git a/src/main/java/dev/dubhe/anvilcraft/client/gui/screen/AnvilHammerScreen.java b/src/main/java/dev/dubhe/anvilcraft/client/gui/screen/AnvilHammerScreen.java index e496ebfce..13ea116d1 100644 --- a/src/main/java/dev/dubhe/anvilcraft/client/gui/screen/AnvilHammerScreen.java +++ b/src/main/java/dev/dubhe/anvilcraft/client/gui/screen/AnvilHammerScreen.java @@ -155,6 +155,31 @@ protected void init() { ).mul(1, -1); } + @Override + public boolean mouseScrolled(double mouseX, double mouseY, double scrollX, double scrollY) { + int selectionIdx = possibleStates.indexOf(currentBlockState); + if (scrollY > 0) { + if (selectionIdx == possibleStates.size() - 1) { + selectionIdx = 0; + } else { + selectionIdx++; + } + } else if (scrollY < 0) { + if (selectionIdx == 0) { + selectionIdx = possibleStates.size() - 1; + } else { + selectionIdx--; + } + } + currentBlockState = possibleStates.get(selectionIdx); + targetAngle = items.stream() + .filter(it -> it.state == currentBlockState) + .findFirst() + .orElseThrow() + .angle; + return true; + } + @Override public boolean mouseDragged(double mouseX, double mouseY, int button, double dragX, double dragY) { if (closingAnimationStarted) return true; diff --git a/src/main/java/dev/dubhe/anvilcraft/event/BlockEventListener.java b/src/main/java/dev/dubhe/anvilcraft/event/BlockEventListener.java index c011f1420..e35826a5c 100644 --- a/src/main/java/dev/dubhe/anvilcraft/event/BlockEventListener.java +++ b/src/main/java/dev/dubhe/anvilcraft/event/BlockEventListener.java @@ -45,7 +45,7 @@ public static void anvilHammerUse(@NotNull PlayerInteractEvent.RightClickBlock e if (AnvilHammerItem.ableToUseAnvilHammer(event.getLevel(), event.getPos(), event.getEntity())) { Block b = event.getLevel().getBlockState(event.getPos()).getBlock(); if ((b instanceof IHammerRemovable || b.defaultBlockState().is(ModBlockTags.HAMMER_REMOVABLE)) - && !(b instanceof IHammerChangeable) + && !(b instanceof IHammerChangeable || b.defaultBlockState().is(ModBlockTags.HAMMER_CHANGEABLE)) && !event.getEntity().isShiftKeyDown() ) { return;