Skip to content

Commit

Permalink
Merge pull request #1384 from ZhuRuoLing/dev/1.21
Browse files Browse the repository at this point in the history
无极滚轮摧毁铁砧锤 修复侦测器不能调
  • Loading branch information
Gu-ZT authored Dec 20, 2024
2 parents 6964505 + 92c23f8 commit 1aa9dba
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 1aa9dba

Please sign in to comment.