From cb43fade3e78b1eeee92b03acfc84fcad6a0fb5c Mon Sep 17 00:00:00 2001 From: Atsuishio <842960157@qq.com> Date: Tue, 8 Jul 2025 22:24:46 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E7=82=AE=E5=87=BB=E6=8C=87?= =?UTF-8?q?=E7=A4=BA=E5=99=A8=E7=BC=A9=E6=94=BE=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../superbwarfare/client/ClickHandler.java | 6 ++++++ .../event/ClientEventHandler.java | 19 +++++++++++++++++++ .../item/ArtilleryIndicator.java | 1 - 3 files changed, 25 insertions(+), 1 deletion(-) 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); }