diff --git a/src/main/java/com/atsuishio/superbwarfare/client/ClickHandler.java b/src/main/java/com/atsuishio/superbwarfare/client/ClickHandler.java index d1f84da12..80e452516 100644 --- a/src/main/java/com/atsuishio/superbwarfare/client/ClickHandler.java +++ b/src/main/java/com/atsuishio/superbwarfare/client/ClickHandler.java @@ -219,6 +219,12 @@ public class ClickHandler { PacketDistributor.sendToServer(new AdjustMortarAngleMessage(scroll)); event.setCanceled(true); } + + //TODO 为啥还能滚轮换物品? + if (player.isUsingItem() && player.getUseItem().is(ModItems.ARTILLERY_INDICATOR.get())) { + artilleryIndicatorCustomZoom = Mth.clamp(artilleryIndicatorCustomZoom + 0.4 * scroll, 0, 9); + event.setCanceled(true); + } } @SubscribeEvent diff --git a/src/main/java/com/atsuishio/superbwarfare/event/ClientEventHandler.java b/src/main/java/com/atsuishio/superbwarfare/event/ClientEventHandler.java index f80363046..eaf31e529 100644 --- a/src/main/java/com/atsuishio/superbwarfare/event/ClientEventHandler.java +++ b/src/main/java/com/atsuishio/superbwarfare/event/ClientEventHandler.java @@ -113,6 +113,9 @@ public class ClientEventHandler { public static double[] randomShell = {0, 0, 0}; public static double customZoom = 0; + + public static double artilleryIndicatorZoom = 1; + public static double artilleryIndicatorCustomZoom = 0; public static MillisTimer clientTimer = new MillisTimer(); public static MillisTimer clientTimerVehicle = new MillisTimer(); @@ -1460,6 +1463,22 @@ public class ClientEventHandler { return; } + double factor; + + if (stack.is(ModItems.ARTILLERY_INDICATOR.get())) { + if (player.isUsingItem() && player.getUseItem().is(ModItems.ARTILLERY_INDICATOR.get())) { + factor = 2 + artilleryIndicatorCustomZoom; + } else { + factor = 1; + } + } else { + factor = 1; + } + + artilleryIndicatorZoom = Mth.lerp(0.6 * times, artilleryIndicatorZoom, factor); + + event.setFOV(event.getFOV() / artilleryIndicatorZoom); + if (stack.getItem() instanceof GunItem) { if (!event.usedConfiguredFov()) { return; diff --git a/src/main/java/com/atsuishio/superbwarfare/item/ArtilleryIndicator.java b/src/main/java/com/atsuishio/superbwarfare/item/ArtilleryIndicator.java index 20fe64dfc..149c8c288 100644 --- a/src/main/java/com/atsuishio/superbwarfare/item/ArtilleryIndicator.java +++ b/src/main/java/com/atsuishio/superbwarfare/item/ArtilleryIndicator.java @@ -34,7 +34,6 @@ public class ArtilleryIndicator extends Item { @Override @ParametersAreNonnullByDefault public @NotNull InteractionResultHolder use(Level worldIn, Player playerIn, InteractionHand handIn) { - ItemStack stack = playerIn.getItemInHand(handIn); playerIn.playSound(SoundEvents.SPYGLASS_USE, 1.0F, 1.0F); return ItemUtils.startUsingInstantly(worldIn, playerIn, handIn); }