diff --git a/src/main/java/net/mcreator/superbwarfare/client/model/item/MinigunItemModel.java b/src/main/java/net/mcreator/superbwarfare/client/model/item/MinigunItemModel.java index ca8a7ae54..18d5a463e 100644 --- a/src/main/java/net/mcreator/superbwarfare/client/model/item/MinigunItemModel.java +++ b/src/main/java/net/mcreator/superbwarfare/client/model/item/MinigunItemModel.java @@ -61,7 +61,7 @@ public class MinigunItemModel extends GeoModel { heat_barrels.setScaleZ(4 * heat); - gun.setRotZ((float) (gun.getRotZ() + times * -0.18f * stack.getOrCreateTag().getDouble("minigun_rotation"))); + gun.setRotZ(gun.getRotZ() + times * -0.18f * ClientEventHandler.miniGunRot); shen.setPosX((float) (0.75f * ClientEventHandler.recoilHorizon * fpz * fp)); shen.setPosY((float) (-0.03f * fp - 0.06f * fr)); diff --git a/src/main/java/net/mcreator/superbwarfare/event/ClientEventHandler.java b/src/main/java/net/mcreator/superbwarfare/event/ClientEventHandler.java index 8aaef1066..22649ea47 100644 --- a/src/main/java/net/mcreator/superbwarfare/event/ClientEventHandler.java +++ b/src/main/java/net/mcreator/superbwarfare/event/ClientEventHandler.java @@ -121,6 +121,9 @@ public class ClientEventHandler { public static double chamberRot = 0; public static double actionMove = 0; + public static int miniGunRot = 0; + + @SubscribeEvent public static void handleWeaponTurn(RenderHandEvent event) { LocalPlayer player = Minecraft.getInstance().player; @@ -157,6 +160,25 @@ public class ClientEventHandler { || (player != null && player.isSprinting()); } + @SubscribeEvent + public static void handleClientTick(TickEvent.ClientTickEvent event) { + LocalPlayer player = Minecraft.getInstance().player; + if (player == null) { + return; + } + ItemStack stack = player.getMainHandItem(); + if (stack.getItem() == ModItems.MINIGUN.get()) { + if (holdFire || GLFW.glfwGetMouseButton(Minecraft.getInstance().getWindow().getWindow(), GLFW.GLFW_MOUSE_BUTTON_RIGHT) == GLFW.GLFW_PRESS) { + miniGunRot = Math.min(miniGunRot + 5, 21); + player.playSound(ModSounds.MINIGUN_ROT.get(), 1, 1); + } + } + + if (miniGunRot > 0) { + miniGunRot -= 1; + } + } + @SubscribeEvent public static void handleWeaponFire(TickEvent.RenderTickEvent event) { ClientLevel level = Minecraft.getInstance().level; @@ -238,7 +260,7 @@ public class ClientEventHandler { && stack.getOrCreateTag().getInt("ammo") > 0 && !player.getCooldowns().isOnCooldown(stack.getItem()) && !stack.getOrCreateTag().getBoolean("need_bolt_action")) - || (stack.is(ModItems.MINIGUN.get()) && !player.isSprinting() && stack.getOrCreateTag().getDouble("overheat") == 0 && !player.getCooldowns().isOnCooldown(stack.getItem()) && stack.getOrCreateTag().getDouble("minigun_rotation") >= 10 + || (stack.is(ModItems.MINIGUN.get()) && !player.isSprinting() && stack.getOrCreateTag().getDouble("overheat") == 0 && !player.getCooldowns().isOnCooldown(stack.getItem()) && miniGunRot >= 20 ))) { if (mode == 0) { diff --git a/src/main/java/net/mcreator/superbwarfare/event/GunEventHandler.java b/src/main/java/net/mcreator/superbwarfare/event/GunEventHandler.java index 9537f59db..00f32ca00 100644 --- a/src/main/java/net/mcreator/superbwarfare/event/GunEventHandler.java +++ b/src/main/java/net/mcreator/superbwarfare/event/GunEventHandler.java @@ -46,7 +46,6 @@ public class GunEventHandler { if (event.phase == TickEvent.Phase.END && stack.is(ModTags.Items.GUN)) { handleGunBolt(player); - handleMiniGunFire(player); handleGunReload(player); handleGunSingleReload(player); handleSentinelCharge(player); @@ -73,29 +72,6 @@ public class GunEventHandler { } } - /** - * 加特林开火流程 - */ - private static void handleMiniGunFire(Player player) { - ItemStack stack = player.getMainHandItem(); - if (stack.getItem() != ModItems.MINIGUN.get()) { - return; - } - - var tag = stack.getOrCreateTag(); - - if ((player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables())).holdFire || (player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables())).zoom) { - if (tag.getDouble("minigun_rotation") < 10) { - tag.putDouble("minigun_rotation", (tag.getDouble("minigun_rotation") + 1)); - } - if (!player.level().isClientSide() && player instanceof ServerPlayer serverPlayer) { - SoundTool.playLocalSound(serverPlayer, ModSounds.MINIGUN_ROT.get(), 2f, 1f); - } - } else if (tag.getDouble("minigun_rotation") > 0) { - tag.putDouble("minigun_rotation", (tag.getDouble("minigun_rotation") - 0.5)); - } - } - /** * 根据武器的注册名来寻找音效并播放 */