From f40776a9acad433a3cf9888ee2dd771132da9620 Mon Sep 17 00:00:00 2001 From: Atsuihsio <842960157@qq.com> Date: Wed, 15 Jan 2025 05:47:41 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=AD=A6=E8=A3=85=E8=BD=BD?= =?UTF-8?q?=E5=85=B7=E4=B8=BB=E9=A9=BE=E9=A9=B6=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/atsuishio/superbwarfare/ModUtils.java | 1 - .../superbwarfare/client/ClickHandler.java | 64 +++------ .../client/overlay/CannonHudOverlay.java | 2 +- .../client/overlay/CrossHairOverlay.java | 4 +- .../client/overlay/HelicopterHudOverlay.java | 31 +++-- .../client/overlay/JavelinHudOverlay.java | 2 + .../client/overlay/LandArmorHudOverlay.java | 29 +++++ .../client/overlay/M79UIOverlay.java | 2 + .../client/overlay/RedTriangleOverlay.java | 2 + .../client/overlay/VehicleMgHudOverlay.java | 16 +-- .../config/server/VehicleConfig.java | 34 ++++- .../entity/vehicle/Ah6Entity.java | 47 ++++++- .../entity/vehicle/AnnihilatorEntity.java | 15 +++ .../entity/vehicle/EnergyVehicleEntity.java | 2 +- .../entity/vehicle/IArmedVehicleEntity.java | 3 + .../entity/vehicle/Lav150Entity.java | 38 ++++-- .../entity/vehicle/Mk42Entity.java | 17 ++- .../entity/vehicle/Mle1934Entity.java | 15 +++ .../entity/vehicle/SpeedboatEntity.java | 16 ++- .../event/ClientEventHandler.java | 123 +++++++----------- .../superbwarfare/mixins/CameraMixin.java | 6 +- .../mixins/MouseHandlerMixin.java | 17 +-- .../network/message/DroneMovementMessage.java | 68 ---------- 23 files changed, 301 insertions(+), 253 deletions(-) delete mode 100644 src/main/java/com/atsuishio/superbwarfare/network/message/DroneMovementMessage.java diff --git a/src/main/java/com/atsuishio/superbwarfare/ModUtils.java b/src/main/java/com/atsuishio/superbwarfare/ModUtils.java index 3512f7748..27561a87a 100644 --- a/src/main/java/com/atsuishio/superbwarfare/ModUtils.java +++ b/src/main/java/com/atsuishio/superbwarfare/ModUtils.java @@ -136,7 +136,6 @@ public class ModUtils { addNetworkMessage(AdjustZoomFovMessage.class, AdjustZoomFovMessage::encode, AdjustZoomFovMessage::decode, AdjustZoomFovMessage::handler); addNetworkMessage(AdjustMortarAngleMessage.class, AdjustMortarAngleMessage::encode, AdjustMortarAngleMessage::decode, AdjustMortarAngleMessage::handler); addNetworkMessage(InteractMessage.class, InteractMessage::encode, InteractMessage::decode, InteractMessage::handler); - addNetworkMessage(DroneMovementMessage.class, DroneMovementMessage::encode, DroneMovementMessage::decode, DroneMovementMessage::handler); addNetworkMessage(VehicleMovementMessage.class, VehicleMovementMessage::encode, VehicleMovementMessage::decode, VehicleMovementMessage::handler); addNetworkMessage(DroneFireMessage.class, DroneFireMessage::encode, DroneFireMessage::decode, DroneFireMessage::handler); addNetworkMessage(SimulationDistanceMessage.class, SimulationDistanceMessage::encode, SimulationDistanceMessage::decode, SimulationDistanceMessage::handle, Optional.of(NetworkDirection.PLAY_TO_CLIENT)); diff --git a/src/main/java/com/atsuishio/superbwarfare/client/ClickHandler.java b/src/main/java/com/atsuishio/superbwarfare/client/ClickHandler.java index f6c52a4d0..6fd39c9bb 100644 --- a/src/main/java/com/atsuishio/superbwarfare/client/ClickHandler.java +++ b/src/main/java/com/atsuishio/superbwarfare/client/ClickHandler.java @@ -5,7 +5,10 @@ import com.atsuishio.superbwarfare.compat.CompatHolder; import com.atsuishio.superbwarfare.compat.clothconfig.ClothConfigHelper; import com.atsuishio.superbwarfare.config.client.ReloadConfig; import com.atsuishio.superbwarfare.entity.MortarEntity; -import com.atsuishio.superbwarfare.entity.vehicle.*; +import com.atsuishio.superbwarfare.entity.vehicle.IArmedVehicleEntity; +import com.atsuishio.superbwarfare.entity.vehicle.ICannonEntity; +import com.atsuishio.superbwarfare.entity.vehicle.MobileVehicleEntity; +import com.atsuishio.superbwarfare.entity.vehicle.VehicleEntity; import com.atsuishio.superbwarfare.event.ClientEventHandler; import com.atsuishio.superbwarfare.init.*; import com.atsuishio.superbwarfare.item.gun.GunItem; @@ -92,7 +95,7 @@ public class ClickHandler { int button = event.getButton(); if (stack.is(ModTags.Items.GUN) || stack.is(ModItems.MONITOR.get()) || stack.is(ModItems.LUNGE_MINE.get()) || player.hasEffect(ModMobEffects.SHOCK.get()) - || (player.getVehicle() instanceof IArmedVehicleEntity && !(player.getVehicle() instanceof WheelChairEntity))) { + || (player.getVehicle() instanceof IArmedVehicleEntity iArmedVehicle && iArmedVehicle.banHand())) { if (button == GLFW.GLFW_MOUSE_BUTTON_LEFT) { event.setCanceled(true); } @@ -104,10 +107,7 @@ public class ClickHandler { if (button == GLFW.GLFW_MOUSE_BUTTON_RIGHT) { if (stack.is(ModTags.Items.GUN) - || (player.getVehicle() instanceof ICannonEntity) - || (player.getVehicle() instanceof Ah6Entity ah6Entity && ah6Entity.getFirstPassenger() == player && !stack.getItem().isEdible()) - || (player.getVehicle() instanceof Lav150Entity lav150 && lav150.isDriver(player) && !stack.getItem().isEdible()) - || (player.getVehicle() instanceof SpeedboatEntity boat && boat.getFirstPassenger() == player && stack.is(ItemStack.EMPTY.getItem()))) { + || (player.getVehicle() instanceof IArmedVehicleEntity iArmedVehicle && iArmedVehicle.isDriver(player) && !stack.getItem().isEdible())) { event.setCanceled(true); } } @@ -118,10 +118,9 @@ public class ClickHandler { } } - if ((stack.is(ModTags.Items.GUN) && !(player.getVehicle() instanceof ICannonEntity)) + if (stack.is(ModTags.Items.GUN) || stack.is(ModItems.MONITOR.get()) || stack.is(ModItems.LUNGE_MINE.get()) - || (player.getVehicle() instanceof ICannonEntity) || (player.getVehicle() instanceof IArmedVehicleEntity iVehicle && iVehicle.isDriver(player)) || (stack.is(Items.SPYGLASS) && player.isScoping() && player.getOffhandItem().is(ModItems.FIRING_PARAMETERS.get()))) { if (button == ModKeyMappings.FIRE.getKey().getValue()) { @@ -166,11 +165,6 @@ public class ClickHandler { event.setCanceled(true); } - if (player.getVehicle() instanceof IArmedVehicleEntity iVehicle && iVehicle.isDriver(player) && ClientEventHandler.zoom) { - ClientEventHandler.vehicleFov = Mth.clamp(ClientEventHandler.vehicleFov + 0.4 * scroll, 1, 6); - event.setCanceled(true); - } - if (stack.is(ModItems.MONITOR.get()) && stack.getOrCreateTag().getBoolean("Using") && stack.getOrCreateTag().getBoolean("Linked")) { ClientEventHandler.droneFov = Mth.clamp(ClientEventHandler.droneFov + 0.4 * scroll, 1, 6); event.setCanceled(true); @@ -255,9 +249,8 @@ public class ClickHandler { ModUtils.PACKET_HANDLER.sendToServer(new SensitivityMessage(false)); } - if ((stack.is(ModTags.Items.GUN) && !(player.getVehicle() instanceof ICannonEntity)) + if (stack.is(ModTags.Items.GUN) || stack.is(ModItems.MONITOR.get()) - || (player.getVehicle() instanceof ICannonEntity) || (player.getVehicle() instanceof IArmedVehicleEntity iVehicle && iVehicle.isDriver(player)) || (stack.is(Items.SPYGLASS) && player.isScoping() && player.getOffhandItem().is(ModItems.FIRING_PARAMETERS.get()))) { if (key == ModKeyMappings.FIRE.getKey().getValue()) { @@ -307,13 +300,10 @@ public class ClickHandler { ModUtils.PACKET_HANDLER.sendToServer(new DroneFireMessage(0)); } - if (player.getVehicle() instanceof ICannonEntity) { - ModUtils.PACKET_HANDLER.sendToServer(new VehicleFireMessage(0)); - return; - } - if (player.getVehicle() instanceof IArmedVehicleEntity iVehicle && iVehicle.isDriver(player)) { - ClientEventHandler.holdFire = true; + if (player.getVehicle() instanceof IArmedVehicleEntity iVehicle && iVehicle.isDriver(player) && iVehicle.banHand()) { + ClientEventHandler.holdFireVehicle = true; + return; } if (stack.is(ModItems.LUNGE_MINE.get())) { @@ -350,11 +340,18 @@ public class ClickHandler { public static void handleWeaponFireRelease() { ModUtils.PACKET_HANDLER.sendToServer(new FireMessage(1)); ClientEventHandler.holdFire = false; + ClientEventHandler.holdFireVehicle = false; ClientEventHandler.customRpm = 0; } public static void handleWeaponZoomPress(Player player, ItemStack stack) { ModUtils.PACKET_HANDLER.sendToServer(new ZoomMessage(0)); + + if (player.getVehicle() instanceof IArmedVehicleEntity iVehicle && iVehicle.isDriver(player) && iVehicle.banHand()) { + ClientEventHandler.zoomVehicle = true; + return; + } + ClientEventHandler.zoom = true; int level = PerkHelper.getItemPerkLevel(ModPerks.INTELLIGENT_CHIP.get(), stack); if (level > 0) { @@ -367,6 +364,7 @@ public class ClickHandler { public static void handleWeaponZoomRelease() { ModUtils.PACKET_HANDLER.sendToServer(new ZoomMessage(1)); ClientEventHandler.zoom = false; + ClientEventHandler.zoomVehicle = false; ClientEventHandler.entity = null; } @@ -389,33 +387,9 @@ public class ClickHandler { Player player = Minecraft.getInstance().player; if (player == null) return; - handleDroneMove(key, state, player); handleVehicleMove(key, state, player); } - private static void handleDroneMove(int key, int state, Player player) { - ItemStack stack = player.getMainHandItem(); - if (!stack.is(ModItems.MONITOR.get())) return; - if (!stack.getOrCreateTag().getBoolean("Using")) return; - if (!stack.getOrCreateTag().getBoolean("Linked")) return; - - var options = Minecraft.getInstance().options; - - if (key == options.keyLeft.getKey().getValue()) { - ModUtils.PACKET_HANDLER.sendToServer(new DroneMovementMessage(0, state == 1)); - } else if (key == options.keyRight.getKey().getValue()) { - ModUtils.PACKET_HANDLER.sendToServer(new DroneMovementMessage(1, state == 1)); - } else if (key == options.keyUp.getKey().getValue()) { - ModUtils.PACKET_HANDLER.sendToServer(new DroneMovementMessage(2, state == 1)); - } else if (key == options.keyDown.getKey().getValue()) { - ModUtils.PACKET_HANDLER.sendToServer(new DroneMovementMessage(3, state == 1)); - } else if (key == options.keyJump.getKey().getValue()) { - ModUtils.PACKET_HANDLER.sendToServer(new DroneMovementMessage(4, state == 1)); - } else if (key == options.keyShift.getKey().getValue()) { - ModUtils.PACKET_HANDLER.sendToServer(new DroneMovementMessage(5, state == 1)); - } - } - private static void handleVehicleMove(int key, int state, Player player) { if (player.getVehicle() != null && player.getVehicle() instanceof MobileVehicleEntity && player.getVehicle().getFirstPassenger() == player) { var options = Minecraft.getInstance().options; diff --git a/src/main/java/com/atsuishio/superbwarfare/client/overlay/CannonHudOverlay.java b/src/main/java/com/atsuishio/superbwarfare/client/overlay/CannonHudOverlay.java index 13f2dddc8..48c20be01 100644 --- a/src/main/java/com/atsuishio/superbwarfare/client/overlay/CannonHudOverlay.java +++ b/src/main/java/com/atsuishio/superbwarfare/client/overlay/CannonHudOverlay.java @@ -77,7 +77,7 @@ public class CannonHudOverlay { int j = Mth.floor(f * f1); int k = (w - i) / 2; int l = (h - j) / 2; - if (ClientEventHandler.zoom) { + if (ClientEventHandler.zoomVehicle) { Entity lookingEntity = TraceTool.findLookingEntity(player, 512); boolean lookAtEntity = false; double blockRange = player.position().distanceTo((Vec3.atLowerCornerOf(player.level().clip( diff --git a/src/main/java/com/atsuishio/superbwarfare/client/overlay/CrossHairOverlay.java b/src/main/java/com/atsuishio/superbwarfare/client/overlay/CrossHairOverlay.java index 08da76a87..15a77f143 100644 --- a/src/main/java/com/atsuishio/superbwarfare/client/overlay/CrossHairOverlay.java +++ b/src/main/java/com/atsuishio/superbwarfare/client/overlay/CrossHairOverlay.java @@ -3,7 +3,7 @@ package com.atsuishio.superbwarfare.client.overlay; import com.atsuishio.superbwarfare.ModUtils; import com.atsuishio.superbwarfare.config.client.DisplayConfig; import com.atsuishio.superbwarfare.entity.vehicle.Ah6Entity; -import com.atsuishio.superbwarfare.entity.vehicle.ICannonEntity; +import com.atsuishio.superbwarfare.entity.vehicle.IArmedVehicleEntity; import com.atsuishio.superbwarfare.event.ClientEventHandler; import com.atsuishio.superbwarfare.init.ModItems; import com.atsuishio.superbwarfare.init.ModTags; @@ -56,7 +56,7 @@ public class CrossHairOverlay { if (player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables()).edit) return; - if (player.getVehicle() != null && player.getVehicle() instanceof ICannonEntity) return; + if (player.getVehicle() instanceof IArmedVehicleEntity iArmedVehicle && iArmedVehicle.isDriver(player) && iArmedVehicle.banHand()) return; GuiGraphics guiGraphics = event.getGuiGraphics(); diff --git a/src/main/java/com/atsuishio/superbwarfare/client/overlay/HelicopterHudOverlay.java b/src/main/java/com/atsuishio/superbwarfare/client/overlay/HelicopterHudOverlay.java index fb9ce3dbd..83cc4c902 100644 --- a/src/main/java/com/atsuishio/superbwarfare/client/overlay/HelicopterHudOverlay.java +++ b/src/main/java/com/atsuishio/superbwarfare/client/overlay/HelicopterHudOverlay.java @@ -2,10 +2,7 @@ package com.atsuishio.superbwarfare.client.overlay; import com.atsuishio.superbwarfare.ModUtils; import com.atsuishio.superbwarfare.client.RenderHelper; -import com.atsuishio.superbwarfare.entity.vehicle.IHelicopterEntity; -import com.atsuishio.superbwarfare.entity.vehicle.MobileVehicleEntity; -import com.atsuishio.superbwarfare.entity.vehicle.MultiWeaponVehicleEntity; -import com.atsuishio.superbwarfare.entity.vehicle.VehicleEntity; +import com.atsuishio.superbwarfare.entity.vehicle.*; import com.atsuishio.superbwarfare.event.ClientEventHandler; import com.atsuishio.superbwarfare.init.ModItems; import com.atsuishio.superbwarfare.network.ModVariables; @@ -118,12 +115,16 @@ public class HelicopterHudOverlay { guiGraphics.drawString(Minecraft.getInstance().font, Component.literal(new DecimalFormat("##").format(length(mobileVehicle.getDeltaMovement().x, mobileVehicle.getDeltaMovement().y, mobileVehicle.getDeltaMovement().z) * 72) + "KM/H"), w / 2 - 140, h / 2, 0x66FF00, false); - if (multiWeaponVehicle.getWeaponType() == 0) { - guiGraphics.drawString(Minecraft.getInstance().font, Component.literal("20MM CANNON " + (player.getInventory().hasAnyMatching(s -> s.is(ModItems.CREATIVE_AMMO_BOX.get())) ? "∞" : iHelicopterEntity.getAmmoCount(player))), w / 2 - 160, h / 2 - 60, 0x66FF00, false); - } else { - guiGraphics.drawString(Minecraft.getInstance().font, Component.literal("70MM ROCKET " + iHelicopterEntity.getAmmoCount(player)), w / 2 - 160, h / 2 - 60, 0x66FF00, false); + if (mobileVehicle instanceof Ah6Entity ah6Entity) { + if (multiWeaponVehicle.getWeaponType() == 0) { + double heat = 1 - ah6Entity.heat / 100.0F; + guiGraphics.drawString(Minecraft.getInstance().font, Component.literal("20MM CANNON " + (player.getInventory().hasAnyMatching(s -> s.is(ModItems.CREATIVE_AMMO_BOX.get())) ? "∞" : iHelicopterEntity.getAmmoCount(player))), w / 2 - 160, h / 2 - 60, Mth.hsvToRgb((float) heat / 3.745318352059925F, 1.0F, 1.0F), false); + } else { + guiGraphics.drawString(Minecraft.getInstance().font, Component.literal("70MM ROCKET " + iHelicopterEntity.getAmmoCount(player)), w / 2 - 160, h / 2 - 60, 0x66FF00, false); + } } + guiGraphics.drawString(Minecraft.getInstance().font, Component.literal("FLARE " + iHelicopterEntity.getDecoy()), w / 2 - 160, h / 2 - 50, 0x66FF00, false); if (lerpVy * 20 < -24) { @@ -160,7 +161,7 @@ public class HelicopterHudOverlay { var cPos = cameraPos.add(lookAngle); - Vec3 p = RenderHelper.worldToScreen(new Vec3(worldPosition.x, worldPosition.y, worldPosition.z).add(mobileVehicle.getViewVector(event.getPartialTick()).scale(192)), ClientEventHandler.zoom ? cPos : cameraPos); + Vec3 p = RenderHelper.worldToScreen(new Vec3(worldPosition.x, worldPosition.y, worldPosition.z).add(mobileVehicle.getViewVector(event.getPartialTick()).scale(192)), ClientEventHandler.zoomVehicle ? cPos : cameraPos); if (p != null) { poseStack.pushPose(); @@ -182,12 +183,16 @@ public class HelicopterHudOverlay { poseStack.translate(x, y, 0); poseStack.scale(0.75f, 0.75f, 1); - if (multiWeaponVehicle.getWeaponType() == 0) { - guiGraphics.drawString(Minecraft.getInstance().font, Component.literal("20MM CANNON " + (player.getInventory().hasAnyMatching(s -> s.is(ModItems.CREATIVE_AMMO_BOX.get())) ? "∞" : iHelicopterEntity.getAmmoCount(player))), 25, -9, -1, false); - } else { - guiGraphics.drawString(Minecraft.getInstance().font, Component.literal("70MM ROCKET " + iHelicopterEntity.getAmmoCount(player)), 25, -9, -1, false); + if (mobileVehicle instanceof Ah6Entity ah6Entity) { + if (multiWeaponVehicle.getWeaponType() == 0) { + double heat = ah6Entity.heat / 100.0F; + guiGraphics.drawString(Minecraft.getInstance().font, Component.literal("20MM CANNON " + (player.getInventory().hasAnyMatching(s -> s.is(ModItems.CREATIVE_AMMO_BOX.get())) ? "∞" : iHelicopterEntity.getAmmoCount(player))), 25, -9, Mth.hsvToRgb(0F, (float) heat, 1.0F), false); + } else { + guiGraphics.drawString(Minecraft.getInstance().font, Component.literal("70MM ROCKET " + iHelicopterEntity.getAmmoCount(player)), 25, -9, -1, false); + } } + guiGraphics.drawString(Minecraft.getInstance().font, Component.literal("FLARE " + iHelicopterEntity.getDecoy()), 25, 1, -1, false); poseStack.popPose(); poseStack.popPose(); diff --git a/src/main/java/com/atsuishio/superbwarfare/client/overlay/JavelinHudOverlay.java b/src/main/java/com/atsuishio/superbwarfare/client/overlay/JavelinHudOverlay.java index d31566fd1..e10c380e3 100644 --- a/src/main/java/com/atsuishio/superbwarfare/client/overlay/JavelinHudOverlay.java +++ b/src/main/java/com/atsuishio/superbwarfare/client/overlay/JavelinHudOverlay.java @@ -2,6 +2,7 @@ package com.atsuishio.superbwarfare.client.overlay; import com.atsuishio.superbwarfare.ModUtils; import com.atsuishio.superbwarfare.client.RenderHelper; +import com.atsuishio.superbwarfare.entity.vehicle.IArmedVehicleEntity; import com.atsuishio.superbwarfare.event.ClientEventHandler; import com.atsuishio.superbwarfare.init.ModItems; import com.atsuishio.superbwarfare.network.ModVariables; @@ -55,6 +56,7 @@ public class JavelinHudOverlay { if (player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables()).edit) return; + if (player.getVehicle() instanceof IArmedVehicleEntity iArmedVehicle && iArmedVehicle.isDriver(player) && iArmedVehicle.banHand()) return; if ((stack.getItem() == ModItems.JAVELIN.get() && !stack.getOrCreateTag().getBoolean("HoloHidden")) && Minecraft.getInstance().options.getCameraType().isFirstPerson() && ClientEventHandler.zoom) { RenderSystem.disableDepthTest(); diff --git a/src/main/java/com/atsuishio/superbwarfare/client/overlay/LandArmorHudOverlay.java b/src/main/java/com/atsuishio/superbwarfare/client/overlay/LandArmorHudOverlay.java index 7bb31942c..34018df11 100644 --- a/src/main/java/com/atsuishio/superbwarfare/client/overlay/LandArmorHudOverlay.java +++ b/src/main/java/com/atsuishio/superbwarfare/client/overlay/LandArmorHudOverlay.java @@ -31,6 +31,7 @@ import org.joml.Math; import java.text.DecimalFormat; import static com.atsuishio.superbwarfare.client.RenderHelper.preciseBlit; +import static com.atsuishio.superbwarfare.client.overlay.CrossHairOverlay.*; import static com.atsuishio.superbwarfare.entity.vehicle.Lav150Entity.HEAT; @Mod.EventBusSubscriber(value = Dist.CLIENT) @@ -144,6 +145,8 @@ public class LandArmorHudOverlay { double heal = lav150.getHealth() / lav150.getMaxHealth(); guiGraphics.drawString(Minecraft.getInstance().font, Component.literal(new DecimalFormat("##").format(100 * lav150.getHealth() / lav150.getMaxHealth())), w / 2 - 165, h / 2 - 46, Mth.hsvToRgb((float) heal / 3.745318352059925F, 1.0F, 1.0F), false); + + renderKillIndicator(guiGraphics, w, h); } poseStack.popPose(); @@ -151,4 +154,30 @@ public class LandArmorHudOverlay { scopeScale = 0.7f; } } + + private static void renderKillIndicator(GuiGraphics guiGraphics, int w, int h) { + float posX = w / 2f - 7.5f + (float) (2 * (java.lang.Math.random() - 0.5f)); + float posY = h / 2f - 7.5f + (float) (2 * (java.lang.Math.random() - 0.5f)); + float rate = (40 - KILL_INDICATOR * 5) / 5.5f; + + if (HIT_INDICATOR > 0) { + preciseBlit(guiGraphics, ModUtils.loc("textures/screens/hit_marker.png"), posX, posY, 0, 0, 16, 16, 16, 16); + } + + if (HEAD_INDICATOR > 0) { + preciseBlit(guiGraphics, ModUtils.loc("textures/screens/headshot_mark.png"), posX, posY, 0, 0, 16, 16, 16, 16); + } + + if (KILL_INDICATOR > 0) { + float posX1 = w / 2f - 7.5f - 2 + rate; + float posY1 = h / 2f - 7.5f - 2 + rate; + float posX2 = w / 2f - 7.5f + 2 - rate; + float posY2 = h / 2f - 7.5f + 2 - rate; + + preciseBlit(guiGraphics, ModUtils.loc("textures/screens/kill_mark1.png"), posX1, posY1, 0, 0, 16, 16, 16, 16); + preciseBlit(guiGraphics, ModUtils.loc("textures/screens/kill_mark2.png"), posX2, posY1, 0, 0, 16, 16, 16, 16); + preciseBlit(guiGraphics, ModUtils.loc("textures/screens/kill_mark3.png"), posX1, posY2, 0, 0, 16, 16, 16, 16); + preciseBlit(guiGraphics, ModUtils.loc("textures/screens/kill_mark4.png"), posX2, posY2, 0, 0, 16, 16, 16, 16); + } + } } diff --git a/src/main/java/com/atsuishio/superbwarfare/client/overlay/M79UIOverlay.java b/src/main/java/com/atsuishio/superbwarfare/client/overlay/M79UIOverlay.java index 5694e389c..8f7d948d4 100644 --- a/src/main/java/com/atsuishio/superbwarfare/client/overlay/M79UIOverlay.java +++ b/src/main/java/com/atsuishio/superbwarfare/client/overlay/M79UIOverlay.java @@ -1,6 +1,7 @@ package com.atsuishio.superbwarfare.client.overlay; import com.atsuishio.superbwarfare.ModUtils; +import com.atsuishio.superbwarfare.entity.vehicle.IArmedVehicleEntity; import com.atsuishio.superbwarfare.entity.vehicle.ICannonEntity; import com.atsuishio.superbwarfare.event.ClientEventHandler; import com.atsuishio.superbwarfare.init.ModItems; @@ -28,6 +29,7 @@ public class M79UIOverlay { if (player != null && player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables()).edit) return; + if (player.getVehicle() instanceof IArmedVehicleEntity iArmedVehicle && iArmedVehicle.isDriver(player) && iArmedVehicle.banHand()) return; RenderSystem.disableDepthTest(); RenderSystem.depthMask(false); diff --git a/src/main/java/com/atsuishio/superbwarfare/client/overlay/RedTriangleOverlay.java b/src/main/java/com/atsuishio/superbwarfare/client/overlay/RedTriangleOverlay.java index 02629be70..ccd6d9a16 100644 --- a/src/main/java/com/atsuishio/superbwarfare/client/overlay/RedTriangleOverlay.java +++ b/src/main/java/com/atsuishio/superbwarfare/client/overlay/RedTriangleOverlay.java @@ -2,6 +2,7 @@ package com.atsuishio.superbwarfare.client.overlay; import com.atsuishio.superbwarfare.ModUtils; import com.atsuishio.superbwarfare.client.RenderHelper; +import com.atsuishio.superbwarfare.entity.vehicle.IArmedVehicleEntity; import com.atsuishio.superbwarfare.init.ModItems; import com.atsuishio.superbwarfare.tools.HudUtil; import com.atsuishio.superbwarfare.tools.SeekTool; @@ -37,6 +38,7 @@ public class RedTriangleOverlay { ItemStack stack = player.getMainHandItem(); if (!stack.is(ModItems.RPG.get())) return; + if (player.getVehicle() instanceof IArmedVehicleEntity iArmedVehicle && iArmedVehicle.isDriver(player) && iArmedVehicle.banHand()) return; Entity idf = SeekTool.seekLivingEntity(player, player.level(), 128, 6); if (idf == null) return; diff --git a/src/main/java/com/atsuishio/superbwarfare/client/overlay/VehicleMgHudOverlay.java b/src/main/java/com/atsuishio/superbwarfare/client/overlay/VehicleMgHudOverlay.java index 3ea671ba3..465e93bd6 100644 --- a/src/main/java/com/atsuishio/superbwarfare/client/overlay/VehicleMgHudOverlay.java +++ b/src/main/java/com/atsuishio/superbwarfare/client/overlay/VehicleMgHudOverlay.java @@ -8,9 +8,7 @@ import com.atsuishio.superbwarfare.init.ModTags; import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.systems.RenderSystem; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.renderer.GameRenderer; -import net.minecraft.network.chat.Component; import net.minecraft.util.Mth; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.player.Player; @@ -20,10 +18,6 @@ import net.minecraftforge.eventbus.api.EventPriority; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; -import java.text.DecimalFormat; - -import static com.atsuishio.superbwarfare.client.RenderHelper.preciseBlit; - @Mod.EventBusSubscriber(value = Dist.CLIENT) public class VehicleMgHudOverlay { @@ -54,19 +48,11 @@ public class VehicleMgHudOverlay { int k = (w - i) / 2; int l = (h - j) / 2; RenderHelper.preciseBlit(event.getGuiGraphics(), ModUtils.loc("textures/screens/cannon/cannon_crosshair_notzoom.png"), k, l, 0, 0.0F, i, j, i, j); - - if (ClientEventHandler.vehicleFovLerp > 1.01) { - event.getGuiGraphics().blit(ModUtils.loc("textures/screens/drone_fov.png"), w / 2 + 100, h / 2 - 64, 0, 0, 64, 129, 64, 129); - GuiGraphics guiGraphics = event.getGuiGraphics(); - preciseBlit(guiGraphics, ModUtils.loc("textures/screens/drone_fov_move.png"), (float) w / 2 + 100, (float) (h / 2 - 64 - ((ClientEventHandler.vehicleFovLerp - 1) * 23.8)), 0, 0, 64, 129, 64, 129); - event.getGuiGraphics().drawString(Minecraft.getInstance().font, Component.literal(new DecimalFormat("##.#").format(ClientEventHandler.vehicleFovLerp) + "x"), - w / 2 + 144, h / 2 + 56 - (int) ((ClientEventHandler.vehicleFovLerp - 1) * 23.8), -1, false); - } } private static boolean shouldRenderCrossHair(Player player) { if (player == null) return false; return !player.isSpectator() - && player.getVehicle() instanceof SpeedboatEntity && ClientEventHandler.zoom && !player.getMainHandItem().is(ModTags.Items.GUN); + && player.getVehicle() instanceof SpeedboatEntity && ClientEventHandler.zoomVehicle && !player.getMainHandItem().is(ModTags.Items.GUN); } } diff --git a/src/main/java/com/atsuishio/superbwarfare/config/server/VehicleConfig.java b/src/main/java/com/atsuishio/superbwarfare/config/server/VehicleConfig.java index ed256da91..6c5b1b334 100644 --- a/src/main/java/com/atsuishio/superbwarfare/config/server/VehicleConfig.java +++ b/src/main/java/com/atsuishio/superbwarfare/config/server/VehicleConfig.java @@ -38,6 +38,14 @@ public class VehicleConfig { public static ForgeConfigSpec.IntValue AH_6_ROCKET_EXPLOSION_DAMAGE; public static ForgeConfigSpec.IntValue AH_6_ROCKET_EXPLOSION_RADIUS; + public static ForgeConfigSpec.IntValue LAV_150_HP; + public static ForgeConfigSpec.IntValue LAV_150_ENERGY_COST; + public static ForgeConfigSpec.IntValue LAV_150_MAX_ENERGY; + public static ForgeConfigSpec.IntValue LAV_150_CANNON_DAMAGE; + public static ForgeConfigSpec.IntValue LAV_150_CANNON_EXPLOSION_DAMAGE; + public static ForgeConfigSpec.IntValue LAV_150_CANNON_EXPLOSION_RADIUS; + + public static void init(ForgeConfigSpec.Builder builder) { builder.push("mk_42"); @@ -111,10 +119,10 @@ public class VehicleConfig { SPEEDBOAT_ENERGY_COST = builder.defineInRange("speedboat_energy_cost", 16, 0, 2147483647); builder.comment("The max energy storage of Speedboat"); - SPEEDBOAT_MAX_ENERGY = builder.defineInRange("speedboat_max_energy", 1000000, 0, 2147483647); + SPEEDBOAT_MAX_ENERGY = builder.defineInRange("speedboat_max_energy", 10000000, 0, 2147483647); builder.comment("The gun damage of Speedboat"); - SPEEDBOAT_GUN_DAMAGE = builder.defineInRange("speedboat_gun_damage", 45, 1, 10000000); + SPEEDBOAT_GUN_DAMAGE = builder.defineInRange("speedboat_gun_damage", 25, 1, 10000000); builder.pop(); @@ -145,6 +153,28 @@ public class VehicleConfig { AH_6_ROCKET_EXPLOSION_RADIUS = builder.defineInRange("ah_6_rocket_explosion_radius", 5, 1, 10000000); builder.pop(); + + builder.push("lav_150"); + + builder.comment("The HealthPoint of Lav_150"); + LAV_150_HP = builder.defineInRange("lav_150_hp", 850, 1, 10000000); + + builder.comment("The energy cost of Lav_150 per tick"); + LAV_150_ENERGY_COST = builder.defineInRange("lav_150_energy_cost", 64, 0, 2147483647); + + builder.comment("The max energy storage of Lav_150"); + LAV_150_MAX_ENERGY = builder.defineInRange("lav_150_max_energy", 3000000, 0, 2147483647); + + builder.comment("The cannon damage of Lav_150"); + LAV_150_CANNON_DAMAGE = builder.defineInRange("lav_150_cannon_damage", 40, 1, 10000000); + + builder.comment("The rocket explosion damage of Lav_150"); + LAV_150_CANNON_EXPLOSION_DAMAGE = builder.defineInRange("lav_150_cannon_explosion_damage", 12, 1, 10000000); + + builder.comment("The rocket explosion radius of Lav_150"); + LAV_150_CANNON_EXPLOSION_RADIUS = builder.defineInRange("lav_150_cannon_explosion_radius", 3, 1, 10000000); + + builder.pop(); } } diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Ah6Entity.java b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Ah6Entity.java index b64b1d970..21583d514 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Ah6Entity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Ah6Entity.java @@ -11,6 +11,7 @@ import com.atsuishio.superbwarfare.network.message.ShakeClientMessage; import com.atsuishio.superbwarfare.tools.CustomExplosion; import com.atsuishio.superbwarfare.tools.EntityFindUtil; import com.atsuishio.superbwarfare.tools.ParticleTool; +import com.atsuishio.superbwarfare.tools.SoundTool; import com.google.common.collect.Lists; import net.minecraft.core.BlockPos; import net.minecraft.core.particles.ParticleTypes; @@ -78,6 +79,8 @@ public class Ah6Entity extends ContainerMobileEntity implements GeoEntity, IHeli public int reloadCoolDown; public int decoyReloadCoolDown; public int fireIndex; + public boolean cannotFire; + public int heat; public Ah6Entity(PlayMessages.SpawnEntity packet, Level world) { this(ModEntities.AH_6.get(), world); @@ -127,10 +130,10 @@ public class Ah6Entity extends ContainerMobileEntity implements GeoEntity, IHeli sendParticle(serverLevel, ModParticleTypes.FIRE_STAR.get(), this.getX(), this.getY() + 2.5, this.getZ(), 4, 0.2, 0.2, 0.2, 0.2, false); } if (source.is(ModDamageTypes.PROJECTILE_BOOM)) { - amount *= 2f; + amount *= 1f; } if (source.is(ModDamageTypes.CANNON_FIRE)) { - amount *= 3f; + amount *= 1.5f; } if (source.is(ModDamageTypes.GUN_FIRE)) { amount *= 0.3f; @@ -138,6 +141,9 @@ public class Ah6Entity extends ContainerMobileEntity implements GeoEntity, IHeli if (source.is(ModDamageTypes.GUN_FIRE_ABSOLUTE)) { amount *= 0.7f; } + if (source.is(ModDamageTypes.VEHICLE_STRIKE)) { + amount *= 4f; + } this.level().playSound(null, this.getOnPos(), ModSounds.HIT.get(), SoundSource.PLAYERS, 1, 1); this.hurt(0.75f * Math.max(amount - 5, 0)); return true; @@ -148,6 +154,24 @@ public class Ah6Entity extends ContainerMobileEntity implements GeoEntity, IHeli propellerRotO = this.getPropellerRot(); super.baseTick(); + if (heat > 0) { + heat--; + } + + if (heat < 40) { + cannotFire = false; + } + + Entity driver = this.getFirstPassenger(); + if (driver instanceof Player player) { + if (heat > 100) { + cannotFire = true; + if (!player.level().isClientSide() && player instanceof ServerPlayer serverPlayer) { + SoundTool.playLocalSound(serverPlayer, ModSounds.MINIGUN_OVERHEAT.get(), 1f, 1f); + } + } + } + if (this.level() instanceof ServerLevel) { if (reloadCoolDown > 0) { reloadCoolDown--; @@ -486,6 +510,8 @@ public class Ah6Entity extends ContainerMobileEntity implements GeoEntity, IHeli Vector4f worldPositionLeft; if (entityData.get(WEAPON_TYPE) == 0) { + if (this.cannotFire) return; + x = 1.15f; y = 0.62f; z = 0.8f; @@ -656,7 +682,7 @@ public class Ah6Entity extends ContainerMobileEntity implements GeoEntity, IHeli @Override public boolean canShoot(Player player) { if (entityData.get(WEAPON_TYPE) == 0) { - return this.entityData.get(AMMO) > 0 || player.getInventory().hasAnyMatching(s -> s.is(ModItems.CREATIVE_AMMO_BOX.get())); + return (this.entityData.get(AMMO) > 0 || player.getInventory().hasAnyMatching(s -> s.is(ModItems.CREATIVE_AMMO_BOX.get()))) && !cannotFire; } else if (entityData.get(WEAPON_TYPE) == 1) { return this.entityData.get(AMMO) > 0; } @@ -668,6 +694,21 @@ public class Ah6Entity extends ContainerMobileEntity implements GeoEntity, IHeli return this.entityData.get(AMMO); } + @Override + public boolean banHand() { + return true; + } + + @Override + public boolean hidePassenger() { + return false; + } + + @Override + public int zoomFov() { + return 3; + } + @Override public float getRotX(float tickDelta) { return this.getPitch(tickDelta); diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/AnnihilatorEntity.java b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/AnnihilatorEntity.java index d03b21741..f5da8573d 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/AnnihilatorEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/AnnihilatorEntity.java @@ -511,4 +511,19 @@ public class AnnihilatorEntity extends EnergyVehicleEntity implements GeoEntity, public int getAmmoCount(Player player) { return -1; } + + @Override + public boolean banHand() { + return true; + } + + @Override + public boolean hidePassenger() { + return true; + } + + @Override + public int zoomFov() { + return 5; + } } diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/EnergyVehicleEntity.java b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/EnergyVehicleEntity.java index 510e62370..77d7d038d 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/EnergyVehicleEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/EnergyVehicleEntity.java @@ -21,7 +21,7 @@ public class EnergyVehicleEntity extends VehicleEntity implements IChargeEntity @Override protected void defineSynchedData() { super.defineSynchedData(); - this.entityData.define(ENERGY, this.getMaxEnergy()); + this.entityData.define(ENERGY, 0); } @Override diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/IArmedVehicleEntity.java b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/IArmedVehicleEntity.java index adb01fcaf..8260f95fb 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/IArmedVehicleEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/IArmedVehicleEntity.java @@ -13,4 +13,7 @@ public interface IArmedVehicleEntity { boolean canShoot(Player player); int getAmmoCount(Player player); + boolean banHand(); + boolean hidePassenger(); + int zoomFov(); } diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Lav150Entity.java b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Lav150Entity.java index 87967ff8f..f36557476 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Lav150Entity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Lav150Entity.java @@ -68,8 +68,8 @@ public class Lav150Entity extends ContainerMobileEntity implements GeoEntity, IC public static final EntityDataAccessor HEAT = SynchedEntityData.defineId(Lav150Entity.class, EntityDataSerializers.INT); public static final EntityDataAccessor AMMO = SynchedEntityData.defineId(Lav150Entity.class, EntityDataSerializers.INT); - public static final float MAX_HEALTH = 850; - public static final int MAX_ENERGY = 2000000; + public static final float MAX_HEALTH = VehicleConfig.LAV_150_HP.get(); + public static final int MAX_ENERGY = VehicleConfig.LAV_150_MAX_ENERGY.get(); private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this); public float turretYRot; @@ -124,17 +124,21 @@ public class Lav150Entity extends ContainerMobileEntity implements GeoEntity, IC sendParticle(serverLevel, ModParticleTypes.FIRE_STAR.get(), this.getX(), this.getY() + 2.5, this.getZ(), 4, 0.2, 0.2, 0.2, 0.2, false); } if (source.is(ModDamageTypes.PROJECTILE_BOOM)) { - amount *= 2f; + amount *= 1.5f; } if (source.is(ModDamageTypes.CANNON_FIRE)) { - amount *= 3f; + amount *= 2.5f; } if (source.is(ModDamageTypes.GUN_FIRE)) { amount *= 0.4f; } if (source.is(ModDamageTypes.GUN_FIRE_ABSOLUTE)) { + amount *= 0.6f; + } + if (source.is(ModDamageTypes.VEHICLE_STRIKE)) { amount *= 0.7f; } + this.level().playSound(null, this.getOnPos(), ModSounds.HIT.get(), SoundSource.PLAYERS, 1, 1); this.hurt(0.5f * Math.max(amount - 15, 0)); @@ -258,9 +262,9 @@ public class Lav150Entity extends ContainerMobileEntity implements GeoEntity, IC Vector4f worldPosition = transformPosition(transform, x, y, z); SmallCannonShellEntity smallCannonShell = new SmallCannonShellEntity(player, this.level(), - 36, - 22, - 3f); + VehicleConfig.LAV_150_CANNON_DAMAGE.get(), + VehicleConfig.LAV_150_CANNON_EXPLOSION_DAMAGE.get(), + VehicleConfig.LAV_150_CANNON_EXPLOSION_RADIUS.get()); smallCannonShell.setPos(worldPosition.x - 1.1 * this.getDeltaMovement().x, worldPosition.y, worldPosition.z - 1.1 * this.getDeltaMovement().z); smallCannonShell.shoot(getBarrelVector(1).x, getBarrelVector(1).y + 0.005f, getBarrelVector(1).z, 22, @@ -348,7 +352,7 @@ public class Lav150Entity extends ContainerMobileEntity implements GeoEntity, IC } if (backInputDown) { - this.entityData.set(POWER, this.entityData.get(POWER) - 0.005f); + this.entityData.set(POWER, this.entityData.get(POWER) - 0.008f); } if (rightInputDown) { @@ -384,7 +388,7 @@ public class Lav150Entity extends ContainerMobileEntity implements GeoEntity, IC if (this.isInWater() || onGround()) { this.setYRot((float) (this.getYRot() - Math.max(10 * this.getDeltaMovement().horizontalDistance(), 0) * this.getRudderRot() * (this.entityData.get(POWER) > 0 ? 1 : -1))); - this.setDeltaMovement(this.getDeltaMovement().add(Mth.sin(-this.getYRot() * 0.017453292F) * (isInWater() ? 0.3f : 1) * this.entityData.get(POWER), 0.0, Mth.cos(this.getYRot() * 0.017453292F) * (isInWater() ? 0.3f : 1) * this.entityData.get(POWER))); + this.setDeltaMovement(this.getDeltaMovement().add(Mth.sin(-this.getYRot() * 0.017453292F) * (isInWater() && !onGround() ? 0.3f : 1) * this.entityData.get(POWER), 0.0, Mth.cos(this.getYRot() * 0.017453292F) * (isInWater() && !onGround() ? 0.3f : 1) * this.entityData.get(POWER))); } } @@ -595,7 +599,6 @@ public class Lav150Entity extends ContainerMobileEntity implements GeoEntity, IC @Override public boolean canShoot(Player player) { return (this.entityData.get(AMMO) > 0 || player.getInventory().hasAnyMatching(s -> s.is(ModItems.CREATIVE_AMMO_BOX.get()))) - && !player.getMainHandItem().is(ModTags.Items.GUN) && !cannotFire; } @@ -603,4 +606,19 @@ public class Lav150Entity extends ContainerMobileEntity implements GeoEntity, IC public int getAmmoCount(Player player) { return this.entityData.get(AMMO); } + + @Override + public boolean banHand() { + return true; + } + + @Override + public boolean hidePassenger() { + return true; + } + + @Override + public int zoomFov() { + return 3; + } } diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Mk42Entity.java b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Mk42Entity.java index b232f1f21..a3d029b95 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Mk42Entity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Mk42Entity.java @@ -300,7 +300,7 @@ public class Mk42Entity extends VehicleEntity implements GeoEntity, ICannonEntit } private PlayState movementPredicate(AnimationState event) { - if (this.entityData.get(COOL_DOWN) > 10) { + if (this.entityData.get(COOL_DOWN) > 0) { return event.setAndContinue(RawAnimation.begin().thenPlay("animation.mk42.fire")); } return event.setAndContinue(RawAnimation.begin().thenLoop("animation.mk42.idle")); @@ -344,4 +344,19 @@ public class Mk42Entity extends VehicleEntity implements GeoEntity, ICannonEntit return -1; } } + + @Override + public boolean banHand() { + return true; + } + + @Override + public boolean hidePassenger() { + return true; + } + + @Override + public int zoomFov() { + return 5; + } } diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Mle1934Entity.java b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Mle1934Entity.java index d6bb5e328..0b6bbe88b 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Mle1934Entity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Mle1934Entity.java @@ -439,4 +439,19 @@ public class Mle1934Entity extends VehicleEntity implements GeoEntity, ICannonEn return -1; } } + + @Override + public boolean banHand() { + return true; + } + + @Override + public boolean hidePassenger() { + return true; + } + + @Override + public int zoomFov() { + return 5; + } } diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/SpeedboatEntity.java b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/SpeedboatEntity.java index dd6d47b8b..64a3a9fca 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/SpeedboatEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/SpeedboatEntity.java @@ -513,7 +513,6 @@ public class SpeedboatEntity extends ContainerMobileEntity implements GeoEntity, @Override public boolean canShoot(Player player) { return (this.entityData.get(AMMO) > 0 || player.getInventory().hasAnyMatching(s -> s.is(ModItems.CREATIVE_AMMO_BOX.get()))) - && !player.getMainHandItem().is(ModTags.Items.GUN) && !cannotFire; } @@ -521,4 +520,19 @@ public class SpeedboatEntity extends ContainerMobileEntity implements GeoEntity, public int getAmmoCount(Player player) { return this.entityData.get(AMMO); } + + @Override + public boolean banHand() { + return true; + } + + @Override + public boolean hidePassenger() { + return false; + } + + @Override + public int zoomFov() { + return 3; + } } diff --git a/src/main/java/com/atsuishio/superbwarfare/event/ClientEventHandler.java b/src/main/java/com/atsuishio/superbwarfare/event/ClientEventHandler.java index 3a7c98ad0..af9c1b185 100644 --- a/src/main/java/com/atsuishio/superbwarfare/event/ClientEventHandler.java +++ b/src/main/java/com/atsuishio/superbwarfare/event/ClientEventHandler.java @@ -4,7 +4,10 @@ import com.atsuishio.superbwarfare.ModUtils; import com.atsuishio.superbwarfare.client.ClickHandler; import com.atsuishio.superbwarfare.config.client.DisplayConfig; import com.atsuishio.superbwarfare.entity.DroneEntity; -import com.atsuishio.superbwarfare.entity.vehicle.*; +import com.atsuishio.superbwarfare.entity.vehicle.Ah6Entity; +import com.atsuishio.superbwarfare.entity.vehicle.IArmedVehicleEntity; +import com.atsuishio.superbwarfare.entity.vehicle.Lav150Entity; +import com.atsuishio.superbwarfare.entity.vehicle.SpeedboatEntity; import com.atsuishio.superbwarfare.init.*; import com.atsuishio.superbwarfare.item.gun.GunItem; import com.atsuishio.superbwarfare.network.ModVariables; @@ -124,6 +127,9 @@ public class ClientEventHandler { public static boolean holdFire = false; public static boolean zoom = false; + public static boolean holdFireVehicle = false; + + public static boolean zoomVehicle = false; public static int burstFireSize = 0; public static int customRpm = 0; @@ -141,8 +147,6 @@ public class ClientEventHandler { public static double shakeAmplitude = 0; public static double[] shakePos = {0, 0, 0}; public static double shakeType = 0; - public static double vehicleFov = 1; - public static double vehicleFovLerp = 1; public static int lungeAttack; public static int lungeDraw; public static int lungeSprint; @@ -382,7 +386,8 @@ public class ClientEventHandler { } if ((holdFire || burstFireSize > 0) - && !((player.getVehicle() instanceof Ah6Entity ah6Entity && ah6Entity.isDriver(player)) || player.getVehicle() instanceof Lav150Entity) + && !(player.getVehicle() instanceof IArmedVehicleEntity iArmedVehicle && iArmedVehicle.isDriver(player) && iArmedVehicle.banHand()) + && !holdFireVehicle && (stack.is(ModTags.Items.NORMAL_GUN) && cantFireTime == 0 && drawTime < 0.01 @@ -642,14 +647,9 @@ public class ClientEventHandler { if (player == null) return; if (level == null) return; - if (player.getMainHandItem().getItem() instanceof GunItem) { - clientTimerVehicle.stop(); - return; - } - if (notInGame()) { clientTimerVehicle.stop(); - holdFire = false; + holdFireVehicle = false; } if (player.getVehicle() instanceof IArmedVehicleEntity iVehicle && iVehicle.isDriver(player) && iVehicle.canShoot(player)) { @@ -661,7 +661,7 @@ public class ClientEventHandler { double rps = (double) rpm / 60; int cooldown = (int) (1000 / rps); - if ((holdFire)) { + if ((holdFireVehicle)) { if (!clientTimerVehicle.started()) { clientTimerVehicle.start(); ModUtils.PACKET_HANDLER.sendToServer(new VehicleFireMessage(0)); @@ -683,8 +683,10 @@ public class ClientEventHandler { player.playSound(ModSounds.SHELL_CASING_50CAL.get(), 0.3f, 1); } if (iVehicle instanceof Ah6Entity ah6Entity) { + float pitch = ah6Entity.heat <= 60 ? 1 : (float) (1 - 0.011 * java.lang.Math.abs(60 - ah6Entity.heat)); if (ah6Entity.getEntityData().get(WEAPON_TYPE) == 0) { - player.playSound(ModSounds.HELICOPTER_CANNON_FIRE_1P.get(), 1f, 1); + ah6Entity.heat += 5; + player.playSound(ModSounds.HELICOPTER_CANNON_FIRE_1P.get(), 1f, pitch); } else if (ah6Entity.getEntityData().get(WEAPON_TYPE) == 1) { player.playSound(ModSounds.HELICOPTER_ROCKET_FIRE_1P.get(), 1f, 1); } @@ -702,7 +704,7 @@ public class ClientEventHandler { if (player == null) return; ItemStack stack = player.getMainHandItem(); if (!stack.is(ModTags.Items.GUN)) return; - if (player.getVehicle() != null && player.getVehicle() instanceof ICannonEntity) return; + if (player.getVehicle() instanceof IArmedVehicleEntity iArmedVehicle && iArmedVehicle.isDriver(player) && iArmedVehicle.hidePassenger()) return; float pose; float times = 2 * (float) Math.min(Minecraft.getInstance().getDeltaFrameTime(), 0.8); @@ -741,7 +743,6 @@ public class ClientEventHandler { public static void computeCameraAngles(ViewportEvent.ComputeCameraAngles event) { ClientLevel level = Minecraft.getInstance().level; Entity entity = event.getCamera().getEntity(); - handlePlayerCamera(event); if (!(entity instanceof LivingEntity living)) return; ItemStack stack = living.getMainHandItem(); @@ -756,20 +757,6 @@ public class ClientEventHandler { } } - if (level != null && stack.is(ModTags.Items.GUN)) { - handleWeaponSway(living); - handleWeaponMove(living); - handleWeaponZoom(living); - handlePlayerBreath(living); - handleWeaponFire(event, living); - handleWeaponShell(); - handleGunRecoil(); - handleBowPullAnimation(living); - handleWeaponDraw(living); - } - - handleShockCamera(event, living); - float times = Minecraft.getInstance().getDeltaFrameTime(); LocalPlayer player = Minecraft.getInstance().player; @@ -794,6 +781,23 @@ public class ClientEventHandler { event.setRoll((float) (roll + (shakeTime * Math.sin(0.5 * Math.PI * shakeTime) * shakeAmplitude * shakeRadiusAmplitude * (onVehicle ? 0.15 : 1)))); } } + + if (player != null && player.getVehicle() instanceof IArmedVehicleEntity iArmedVehicle && iArmedVehicle.isDriver(player) && iArmedVehicle.banHand()) return; + + if (level != null && stack.is(ModTags.Items.GUN)) { + handleWeaponSway(living); + handleWeaponMove(living); + handleWeaponZoom(living); + handlePlayerBreath(living); + handleWeaponFire(event, living); + handleWeaponShell(); + handleGunRecoil(); + handleBowPullAnimation(living); + handleWeaponDraw(living); + handlePlayerCamera(event); + } + + handleShockCamera(event, living); } private static void handleDroneCamera(ViewportEvent.ComputeCameraAngles event, LivingEntity entity) { @@ -842,15 +846,7 @@ public class ClientEventHandler { } } - if (player.getVehicle() instanceof ICannonEntity || player.getVehicle() instanceof Lav150Entity) { - event.setCanceled(true); - } - - if (player.getVehicle() instanceof Ah6Entity ah6Entity && ah6Entity.getFirstPassenger() == player && !stack.getItem().isEdible()) { - event.setCanceled(true); - } - - if ((player.getVehicle() instanceof SpeedboatEntity boat && boat.getFirstPassenger() == player) && ClientEventHandler.zoom && stack.is(ItemStack.EMPTY.getItem())) { + if (player.getVehicle() instanceof IArmedVehicleEntity iArmedVehicle && iArmedVehicle.isDriver(player) && iArmedVehicle.banHand()) { event.setCanceled(true); } } @@ -946,7 +942,9 @@ public class ClientEventHandler { double weight = GunsTool.getGunDoubleTag(stack, "Weight") + GunsTool.getGunDoubleTag(stack, "CustomWeight"); double speed = 1.5 - (0.07 * weight); - if (zoom && !notInGame() + if (zoom + && !(player.getVehicle() instanceof IArmedVehicleEntity iArmedVehicle && iArmedVehicle.isDriver(player) && iArmedVehicle.banHand()) + && !notInGame() && drawTime < 0.01 && !player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables()).edit) { if (Minecraft.getInstance().player != null) { @@ -1202,16 +1200,14 @@ public class ClientEventHandler { angle = Math.atan(Mth.abs((float) cameraLocation) / (lookDistance + 2.9)) * Mth.RAD_TO_DEG; } - if (player.getMainHandItem().is(ModTags.Items.GUN) || player.getMainHandItem().is(ModItems.LUNGE_MINE.get())) { - event.setPitch((float) (pitch + cameraRot[0] + (DisplayConfig.CAMERA_ROTATE.get() ? 0.2 : 0) * turnRot[0] + 3 * velocityY)); - if (Minecraft.getInstance().options.getCameraType() == CameraType.THIRD_PERSON_BACK) { - event.setYaw((float) (yaw + cameraRot[1] + (DisplayConfig.CAMERA_ROTATE.get() ? 0.8 : 0) * turnRot[1] - (cameraLocation > 0 ? 1 : -1) * angle * zoomPos)); - } else { - event.setYaw((float) (yaw + cameraRot[1] + (DisplayConfig.CAMERA_ROTATE.get() ? 0.8 : 0) * turnRot[1])); - } - - event.setRoll((float) (roll + cameraRot[2] + (DisplayConfig.CAMERA_ROTATE.get() ? 0.35 : 0) * turnRot[2])); + event.setPitch((float) (pitch + cameraRot[0] + (DisplayConfig.CAMERA_ROTATE.get() ? 0.2 : 0) * turnRot[0] + 3 * velocityY)); + if (Minecraft.getInstance().options.getCameraType() == CameraType.THIRD_PERSON_BACK) { + event.setYaw((float) (yaw + cameraRot[1] + (DisplayConfig.CAMERA_ROTATE.get() ? 0.8 : 0) * turnRot[1] - (cameraLocation > 0 ? 1 : -1) * angle * zoomPos)); + } else { + event.setYaw((float) (yaw + cameraRot[1] + (DisplayConfig.CAMERA_ROTATE.get() ? 0.8 : 0) * turnRot[1])); } + + event.setRoll((float) (roll + cameraRot[2] + (DisplayConfig.CAMERA_ROTATE.get() ? 0.35 : 0) * turnRot[2])); } private static void handleBowPullAnimation(LivingEntity entity) { @@ -1245,18 +1241,8 @@ public class ClientEventHandler { ItemStack stack = player.getMainHandItem(); - if (player.isPassenger() && player.getVehicle() instanceof ICannonEntity && zoom) { - event.setFOV(event.getFOV() / 5); - return; - } - - if (player.getVehicle() instanceof Ah6Entity ah6Entity && ah6Entity.getFirstPassenger() == player && zoom) { - event.setFOV(event.getFOV() / 3); - return; - } - - if (player.getVehicle() instanceof Lav150Entity && zoom) { - event.setFOV(event.getFOV() / 3); + if (player.getVehicle() instanceof IArmedVehicleEntity iArmedVehicle && iArmedVehicle.isDriver(player) && iArmedVehicle.banHand() && zoomVehicle) { + event.setFOV(event.getFOV() / iArmedVehicle.zoomFov()); return; } @@ -1305,11 +1291,6 @@ public class ClientEventHandler { event.setFOV(event.getFOV() / droneFovLerp); fov = event.getFOV(); } - - if (player.getVehicle() instanceof IArmedVehicleEntity && !(player.getVehicle() instanceof ICannonEntity) && zoom) { - vehicleFovLerp = Mth.lerp(0.1 * Minecraft.getInstance().getDeltaFrameTime(), vehicleFovLerp, vehicleFov); - event.setFOV(event.getFOV() / vehicleFovLerp); - } } public static void look(Player player, Vec3 pTarget) { @@ -1328,7 +1309,7 @@ public class ClientEventHandler { public static void setPlayerInvisible(RenderPlayerEvent.Pre event) { var otherPlayer = event.getEntity(); - if (otherPlayer.getVehicle() instanceof ICannonEntity || otherPlayer.getVehicle() instanceof Lav150Entity) { + if (otherPlayer.getVehicle() instanceof IArmedVehicleEntity iArmedVehicle && iArmedVehicle.hidePassenger()) { event.setCanceled(true); } } @@ -1351,19 +1332,11 @@ public class ClientEventHandler { ItemStack stack = player.getMainHandItem(); - if (player.getVehicle() instanceof IHelicopterEntity iHelicopterEntity && iHelicopterEntity.isDriver(player)) { + if (stack.getItem() instanceof GunItem) { event.setCanceled(true); } - if (player.getVehicle() instanceof Lav150Entity) { - event.setCanceled(true); - } - - if (player.getVehicle() instanceof SpeedboatEntity && zoom) { - event.setCanceled(true); - } - - if (stack.is(ModTags.Items.GUN) || (player.getVehicle() != null && player.getVehicle() instanceof ICannonEntity)) { + if (player.getVehicle() instanceof IArmedVehicleEntity iArmedVehicle && iArmedVehicle.isDriver(player)) { event.setCanceled(true); } diff --git a/src/main/java/com/atsuishio/superbwarfare/mixins/CameraMixin.java b/src/main/java/com/atsuishio/superbwarfare/mixins/CameraMixin.java index 2592a0004..6ecd0501d 100644 --- a/src/main/java/com/atsuishio/superbwarfare/mixins/CameraMixin.java +++ b/src/main/java/com/atsuishio/superbwarfare/mixins/CameraMixin.java @@ -45,7 +45,7 @@ public abstract class CameraMixin { if (player != null) { ItemStack stack = player.getMainHandItem(); - if ((player.getVehicle() != null && player.getVehicle() instanceof SpeedboatEntity boat && boat.getFirstPassenger() == player) && ClientEventHandler.zoom && stack.is(ItemStack.EMPTY.getItem())) { + if ((player.getVehicle() != null && player.getVehicle() instanceof SpeedboatEntity boat && boat.getFirstPassenger() == player) && ClientEventHandler.zoomVehicle && stack.is(ItemStack.EMPTY.getItem())) { float yRot = boat.getYRot(); if (yRot < 0) { yRot += 360; @@ -117,7 +117,7 @@ public abstract class CameraMixin { move(-getMaxZoom(16), 1.3, 0.0); return; } - if (thirdPerson && entity.getVehicle() instanceof SpeedboatEntity && !ClientEventHandler.zoom) { + if (thirdPerson && entity.getVehicle() instanceof SpeedboatEntity && !ClientEventHandler.zoomVehicle) { move(-getMaxZoom(3), 1, 0.0); return; } @@ -126,7 +126,7 @@ public abstract class CameraMixin { return; } - if (thirdPerson && entity.getVehicle() instanceof Lav150Entity && !ClientEventHandler.zoom) { + if (thirdPerson && entity.getVehicle() instanceof Lav150Entity && !ClientEventHandler.zoomVehicle) { move(-getMaxZoom(2.5), 0.75, 0.0); return; } diff --git a/src/main/java/com/atsuishio/superbwarfare/mixins/MouseHandlerMixin.java b/src/main/java/com/atsuishio/superbwarfare/mixins/MouseHandlerMixin.java index 85c24170c..bb319c505 100644 --- a/src/main/java/com/atsuishio/superbwarfare/mixins/MouseHandlerMixin.java +++ b/src/main/java/com/atsuishio/superbwarfare/mixins/MouseHandlerMixin.java @@ -1,7 +1,5 @@ package com.atsuishio.superbwarfare.mixins; -import com.atsuishio.superbwarfare.entity.vehicle.Ah6Entity; -import com.atsuishio.superbwarfare.entity.vehicle.IArmedVehicleEntity; import com.atsuishio.superbwarfare.entity.vehicle.ICannonEntity; import com.atsuishio.superbwarfare.entity.vehicle.Lav150Entity; import com.atsuishio.superbwarfare.event.ClientEventHandler; @@ -20,7 +18,6 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.ModifyVariable; import static com.atsuishio.superbwarfare.event.ClientEventHandler.droneFovLerp; -import static com.atsuishio.superbwarfare.event.ClientEventHandler.vehicleFovLerp; /** * Author: MrCrayfish @@ -42,25 +39,21 @@ public class MouseHandlerMixin { ItemStack stack = mc.player.getMainHandItem(); if (player.getVehicle() instanceof ICannonEntity) { - return ClientEventHandler.zoom ? 0.15 : 0.3; + return ClientEventHandler.zoomVehicle ? 0.15 : 0.3; } - if (player.getVehicle() instanceof Ah6Entity ah6Entity && !ah6Entity.onGround() && ah6Entity.getFirstPassenger() == player) { - return 0.24; - } +// if (player.getVehicle() instanceof Ah6Entity ah6Entity && !ah6Entity.onGround() && ah6Entity.getFirstPassenger() == player) { +// return 0.24; +// } if (player.getVehicle() instanceof Lav150Entity) { - return ClientEventHandler.zoom ? 0.23 : 0.28; + return ClientEventHandler.zoomVehicle ? 0.23 : 0.28; } if (stack.is(ModItems.MONITOR.get()) && stack.getOrCreateTag().getBoolean("Using") && stack.getOrCreateTag().getBoolean("Linked")) { return 0.33 / (1 + 0.08 * (droneFovLerp - 1)); } - if (player.getVehicle() instanceof IArmedVehicleEntity iVehicle && iVehicle.isDriver(player) && ClientEventHandler.zoom) { - return 0.33 / (1 + 0.08 * (vehicleFovLerp - 1)); - } - if (!stack.is(ModTags.Items.GUN)) { return original; } diff --git a/src/main/java/com/atsuishio/superbwarfare/network/message/DroneMovementMessage.java b/src/main/java/com/atsuishio/superbwarfare/network/message/DroneMovementMessage.java deleted file mode 100644 index 1782a3231..000000000 --- a/src/main/java/com/atsuishio/superbwarfare/network/message/DroneMovementMessage.java +++ /dev/null @@ -1,68 +0,0 @@ -package com.atsuishio.superbwarfare.network.message; - -import com.atsuishio.superbwarfare.init.ModItems; -import com.atsuishio.superbwarfare.tools.EntityFindUtil; -import net.minecraft.network.FriendlyByteBuf; -import net.minecraft.world.entity.player.Player; -import net.minecraft.world.item.ItemStack; -import net.minecraftforge.network.NetworkEvent; - -import java.util.function.Supplier; - -public class DroneMovementMessage { - - private final int direction; - private final boolean clicked; - - public DroneMovementMessage(int direction, boolean clicked) { - this.direction = direction; - this.clicked = clicked; - } - - public static DroneMovementMessage decode(FriendlyByteBuf buffer) { - return new DroneMovementMessage(buffer.readInt(), buffer.readBoolean()); - } - - public static void encode(DroneMovementMessage message, FriendlyByteBuf buffer) { - buffer.writeInt(message.direction); - buffer.writeBoolean(message.clicked); - } - - public static void handler(DroneMovementMessage message, Supplier contextSupplier) { - NetworkEvent.Context context = contextSupplier.get(); - context.enqueueWork(() -> { - if (context.getSender() != null) { - Player player = context.getSender(); - - ItemStack stack = player.getMainHandItem(); - - if (stack.is(ModItems.MONITOR.get()) && stack.getOrCreateTag().getBoolean("Using") && stack.getOrCreateTag().getBoolean("Linked")) { - var drone = EntityFindUtil.findDrone(player.level(), stack.getOrCreateTag().getString("LinkedDrone")); - if (drone != null) { - switch (message.direction) { - case 0: - drone.leftInputDown = message.clicked; - break; - case 1: - drone.rightInputDown = message.clicked; - break; - case 2: - drone.forwardInputDown = message.clicked; - break; - case 3: - drone.backInputDown = message.clicked; - break; - case 4: - drone.upInputDown = message.clicked; - break; - case 5: - drone.downInputDown = message.clicked; - break; - } - } - } - } - }); - context.setPacketHandled(true); - } -}