diff --git a/src/main/java/net/mcreator/target/client/model/item/M870ItemModel.java b/src/main/java/net/mcreator/target/client/model/item/M870ItemModel.java index 93e803329..329da870c 100644 --- a/src/main/java/net/mcreator/target/client/model/item/M870ItemModel.java +++ b/src/main/java/net/mcreator/target/client/model/item/M870ItemModel.java @@ -90,7 +90,7 @@ public class M870ItemModel extends GeoModel { CoreGeoBone flare = getAnimationProcessor().getBone("flare"); - if (stack.getOrCreateTag().getInt("fire_animation") > 0) { + if (stack.getOrCreateTag().getDouble("flash_time") > 0) { flare.setScaleX((float) (1.0 + 0.5 * (Math.random() - 0.5))); flare.setScaleY((float) (1.0 + 0.5 * (Math.random() - 0.5))); flare.setRotZ((float) (0.5 * (Math.random() - 0.5))); diff --git a/src/main/java/net/mcreator/target/client/model/item/MarlinItemModel.java b/src/main/java/net/mcreator/target/client/model/item/MarlinItemModel.java index 008db39b0..d098ce57d 100644 --- a/src/main/java/net/mcreator/target/client/model/item/MarlinItemModel.java +++ b/src/main/java/net/mcreator/target/client/model/item/MarlinItemModel.java @@ -79,7 +79,7 @@ public class MarlinItemModel extends GeoModel { CoreGeoBone flare = getAnimationProcessor().getBone("flare"); - if (stack.getOrCreateTag().getInt("fire_animation") > 0) { + if (stack.getOrCreateTag().getDouble("flash_time") > 0) { flare.setScaleX((float) (1.0 + 0.5 * (Math.random() - 0.5))); flare.setScaleY((float) (1.0 + 0.5 * (Math.random() - 0.5))); flare.setRotZ((float) (0.5 * (Math.random() - 0.5))); diff --git a/src/main/java/net/mcreator/target/client/model/item/MinigunItemModel.java b/src/main/java/net/mcreator/target/client/model/item/MinigunItemModel.java index 772b495c1..637d55772 100644 --- a/src/main/java/net/mcreator/target/client/model/item/MinigunItemModel.java +++ b/src/main/java/net/mcreator/target/client/model/item/MinigunItemModel.java @@ -41,10 +41,8 @@ public class MinigunItemModel extends GeoModel { } float times = 250f / fps; - double RotZ = 0; - RotZ = stack.getOrCreateTag().getDouble("rot"); - gun.setRotZ((float) (gun.getRotZ() + times * -0.008f * RotZ)); + gun.setRotZ((float) (gun.getRotZ() + times * -0.008f * stack.getOrCreateTag().getDouble("minigun_rotation"))); double fp = 0; diff --git a/src/main/java/net/mcreator/target/event/GunEventHandler.java b/src/main/java/net/mcreator/target/event/GunEventHandler.java index 0831fb197..8c3a651b8 100644 --- a/src/main/java/net/mcreator/target/event/GunEventHandler.java +++ b/src/main/java/net/mcreator/target/event/GunEventHandler.java @@ -4,8 +4,10 @@ import net.mcreator.target.TargetMod; import net.mcreator.target.entity.ProjectileEntity; import net.mcreator.target.init.TargetModAttributes; import net.mcreator.target.init.TargetModItems; +import net.mcreator.target.init.TargetModSounds; import net.mcreator.target.init.TargetModTags; import net.mcreator.target.network.TargetModVariables; +import net.mcreator.target.tools.GunsTool; import net.mcreator.target.tools.SoundTool; import net.minecraft.commands.CommandSource; import net.minecraft.commands.CommandSourceStack; @@ -36,6 +38,7 @@ public class GunEventHandler { if (event.phase == TickEvent.Phase.END) { handleGunsDev(player); handleGunFire(player); + handleMiniGunFire(player); } } @@ -106,7 +109,9 @@ public class GunEventHandler { Thread recoilThread = new Thread(recoilRunnable); recoilThread.start(); } - + /* + 通用的武器开火流程 + */ private static void handleGunFire(Player player) { ItemStack stack = player.getMainHandItem(); if (stack.is(TargetModTags.Items.NORMAL_GUN)) { @@ -195,7 +200,20 @@ public class GunEventHandler { stack.getOrCreateTag().putDouble("crot", 20); } - int cooldown = interval + (int) stack.getOrCreateTag().getDouble("fire_sequence") - (int) stack.getOrCreateTag().getDouble("fire_increase") + burst_cooldown; + int zoom_add_cooldown = 0; + if (player.getMainHandItem().getItem() == TargetModItems.MARLIN.get()) { + if ((player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).zooming) { + zoom_add_cooldown = 5; + stack.getOrCreateTag().putDouble("marlin_animation_time", 15); + stack.getOrCreateTag().putDouble("fastfiring", 0); + } else { + zoom_add_cooldown = 0; + stack.getOrCreateTag().putDouble("marlin_animation_time", 10); + stack.getOrCreateTag().putDouble("fastfiring", 1); + } + } + + int cooldown = interval + (int) stack.getOrCreateTag().getDouble("fire_sequence") - (int) stack.getOrCreateTag().getDouble("fire_increase") + burst_cooldown + zoom_add_cooldown; player.getCooldowns().addCooldown(stack.getItem(), cooldown); for (int index0 = 0; index0 < (int) stack.getOrCreateTag().getDouble("projectile_amount"); index0++) { @@ -219,6 +237,68 @@ public class GunEventHandler { } } } + /* + 加特林开火流程 + */ + private static void handleMiniGunFire(Player player) { + ItemStack stack = player.getMainHandItem(); + var tag = stack.getOrCreateTag(); + + if (stack.getItem() != TargetModItems.MINIGUN.get()) { + return; + } + + if (player.getPersistentData().getBoolean("firing") && !player.isSprinting()) { + 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, TargetModSounds.MINIGUN_ROT.get(), 2f, 1f); + } + } else if (tag.getDouble("minigun_rotation") > 0) { + tag.putDouble("minigun_rotation", (tag.getDouble("minigun_rotation") - 0.5)); + } + + if (tag.getDouble("overheat") == 0 + && (player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).rifleAmmo > 0 + && !(player.getCooldowns().isOnCooldown(stack.getItem())) && tag.getDouble("minigun_rotation") >= 10) { + tag.putDouble("heat", (tag.getDouble("heat") + 1)); + if (tag.getDouble("heat") >= 50.5) { + tag.putDouble("overheat", 40); + player.getCooldowns().addCooldown(stack.getItem(), 40); + if (!player.level().isClientSide() && player instanceof ServerPlayer serverPlayer) { + SoundTool.playLocalSound(serverPlayer, TargetModSounds.MINIGUN_OVERHEAT.get(), 2f, 1f); + } + } + + if (!player.level().isClientSide() && player instanceof ServerPlayer serverPlayer) { + if (tag.getDouble("heat") <= 40) { + SoundTool.playLocalSound(serverPlayer, TargetModSounds.MINIGUN_FIRE_1P.get(), 2f, 1f); + player.playSound(TargetModSounds.MINIGUN_FIRE_3P.get(), 4f, 1f); + player.playSound(TargetModSounds.MINIGUN_FAR.get(), 12f, 1f); + player.playSound(TargetModSounds.MINIGUN_VERYFAR.get(), 24f, 1f); + } else { + float pitch = (float) (1 - 0.025 * Math.abs(40 - tag.getDouble("heat"))); + + SoundTool.playLocalSound(serverPlayer, TargetModSounds.MINIGUN_FIRE_1P.get(), 2f, pitch); + player.playSound(TargetModSounds.MINIGUN_FIRE_3P.get(), 4f, pitch); + player.playSound(TargetModSounds.MINIGUN_FAR.get(), 12f, pitch); + player.playSound(TargetModSounds.MINIGUN_VERYFAR.get(), 24f, pitch); + } + } + + for (int index0 = 0; index0 < (int) stack.getOrCreateTag().getDouble("projectile_amount"); index0++) { + gunShoot(player); + } + + player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> { + capability.rifleAmmo = player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables()).rifleAmmo - 1; + capability.syncPlayerVariables(player); + }); + + tag.putInt("fire_animation", 2); + } + } /** * 根据武器的注册名来寻找音效并播放 @@ -297,19 +377,8 @@ public class GunEventHandler { public static void gunShoot(Player player) { ItemStack heldItem = player.getMainHandItem(); - if (Math.random() < 0.5) { - player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> { - capability.recoilHorizon = -1; - capability.syncPlayerVariables(player); - }); - } else { - player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> { - capability.recoilHorizon = 1; - capability.syncPlayerVariables(player); - }); - } - player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> { + capability.recoilHorizon = Math.random() < 0.5 ? -1 : 1; capability.recoil = 0.1; capability.firing = 1; capability.syncPlayerVariables(player); diff --git a/src/main/java/net/mcreator/target/event/PlayerEventHandler.java b/src/main/java/net/mcreator/target/event/PlayerEventHandler.java index dc9f205d6..a5089e42f 100644 --- a/src/main/java/net/mcreator/target/event/PlayerEventHandler.java +++ b/src/main/java/net/mcreator/target/event/PlayerEventHandler.java @@ -68,7 +68,6 @@ public class PlayerEventHandler { handleRenderDamageIndicator(player); handleBocekPulling(player); handleGunRecoil(player); - handleMiniGunFire(player); } } @@ -447,61 +446,5 @@ public class PlayerEventHandler { recoilThread.start(); } - private static void handleMiniGunFire(Player player) { - ItemStack stack = player.getMainHandItem(); - if (stack.getItem() != TargetModItems.MINIGUN.get()) { - return; - } - - - if (player.getPersistentData().getDouble("mini_firing") == 1 && !player.isSprinting()) { - if (stack.getOrCreateTag().getDouble("rot") < 10) { - stack.getOrCreateTag().putDouble("rot", (stack.getOrCreateTag().getDouble("rot") + 1)); - } - if (!player.level().isClientSide() && player instanceof ServerPlayer serverPlayer) { - SoundTool.playLocalSound(serverPlayer, TargetModSounds.MINIGUN_ROT.get(), 2f, 1f); - } - } else if (stack.getOrCreateTag().getDouble("rot") > 0) { - stack.getOrCreateTag().putDouble("rot", (stack.getOrCreateTag().getDouble("rot") - 0.5)); - } - - if (stack.getOrCreateTag().getDouble("overheat") == 0 - && (player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).rifleAmmo > 0 - && !(player.getCooldowns().isOnCooldown(stack.getItem())) && stack.getOrCreateTag().getDouble("rot") >= 10) { - stack.getOrCreateTag().putDouble("heat", (stack.getOrCreateTag().getDouble("heat") + 1)); - if (stack.getOrCreateTag().getDouble("heat") >= 50.5) { - stack.getOrCreateTag().putDouble("overheat", 40); - player.getCooldowns().addCooldown(stack.getItem(), 40); - if (!player.level().isClientSide() && player instanceof ServerPlayer serverPlayer) { - SoundTool.playLocalSound(serverPlayer, TargetModSounds.MINIGUN_OVERHEAT.get(), 2f, 1f); - } - } - - if (!player.level().isClientSide() && player instanceof ServerPlayer serverPlayer) { - if (stack.getOrCreateTag().getDouble("heat") <= 40) { - SoundTool.playLocalSound(serverPlayer, TargetModSounds.MINIGUN_FIRE_1P.get(), 2f, 1f); - player.playSound(TargetModSounds.MINIGUN_FIRE_3P.get(), 4f, 1f); - player.playSound(TargetModSounds.MINIGUN_FAR.get(), 12f, 1f); - player.playSound(TargetModSounds.MINIGUN_VERYFAR.get(), 24f, 1f); - } else { - float pitch = (float) (1 - 0.025 * Math.abs(40 - stack.getOrCreateTag().getDouble("heat"))); - - SoundTool.playLocalSound(serverPlayer, TargetModSounds.MINIGUN_FIRE_1P.get(), 2f, pitch); - player.playSound(TargetModSounds.MINIGUN_FIRE_3P.get(), 4f, pitch); - player.playSound(TargetModSounds.MINIGUN_FAR.get(), 12f, pitch); - player.playSound(TargetModSounds.MINIGUN_VERYFAR.get(), 24f, pitch); - } - } - - GunsTool.spawnBullet(player); - - player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> { - capability.rifleAmmo = player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables()).rifleAmmo - 1; - capability.syncPlayerVariables(player); - }); - - stack.getOrCreateTag().putInt("fire_animation", 2); - } - } } diff --git a/src/main/java/net/mcreator/target/item/gun/M870Item.java b/src/main/java/net/mcreator/target/item/gun/M870Item.java index 3debf1b45..7396cea32 100644 --- a/src/main/java/net/mcreator/target/item/gun/M870Item.java +++ b/src/main/java/net/mcreator/target/item/gun/M870Item.java @@ -88,7 +88,7 @@ public class M870Item extends GunItem implements GeoItem, AnimatedItem { return event.setAndContinue(RawAnimation.begin().thenLoop("animation.m870.draw")); } - if (stack.getOrCreateTag().getDouble("firing") > 0 && stack.getOrCreateTag().getDouble("firing") < 15) { + if (stack.getOrCreateTag().getDouble("fire_animation") > 0 && stack.getOrCreateTag().getDouble("fire_animation") < 15) { return event.setAndContinue(RawAnimation.begin().thenPlay("animation.m870.shift")); } @@ -100,11 +100,11 @@ public class M870Item extends GunItem implements GeoItem, AnimatedItem { return event.setAndContinue(RawAnimation.begin().thenPlay("animation.m870.prepare")); } - if (!stack.getOrCreateTag().getBoolean("load_index") && stack.getOrCreateTag().getDouble("loading") > 0) { + if (stack.getOrCreateTag().getDouble("load_index") == 0 && stack.getOrCreateTag().getDouble("loading") > 0) { return event.setAndContinue(RawAnimation.begin().thenPlay("animation.m870.iterativeload")); } - if (stack.getOrCreateTag().getBoolean("load_index") && stack.getOrCreateTag().getDouble("loading") > 0) { + if (stack.getOrCreateTag().getDouble("load_index") == 1 && stack.getOrCreateTag().getDouble("loading") > 0) { return event.setAndContinue(RawAnimation.begin().thenPlay("animation.m870.iterativeload2")); } @@ -202,7 +202,11 @@ public class M870Item extends GunItem implements GeoItem, AnimatedItem { if (entity instanceof ServerPlayer serverPlayer) { SoundTool.playLocalSound(serverPlayer, TargetModSounds.M_870_RELOAD_LOOP.get(), 100, 1); } - tag.putBoolean("load_index", tag.getBoolean("load_index")); + if (tag.getDouble("load_index") == 1) { + tag.putDouble("load_index", 0); + } else { + tag.putDouble("load_index", 1); + } } } if (tag.getDouble("loading") == 9) { @@ -222,9 +226,6 @@ public class M870Item extends GunItem implements GeoItem, AnimatedItem { tag.putBoolean("empty_reload", false); } } - if (tag.getDouble("firing") > 0) { - tag.putDouble("firing", tag.getDouble("firing") - 1); - } } } diff --git a/src/main/java/net/mcreator/target/item/gun/MarlinItem.java b/src/main/java/net/mcreator/target/item/gun/MarlinItem.java index a810a840d..2c5b2dc81 100644 --- a/src/main/java/net/mcreator/target/item/gun/MarlinItem.java +++ b/src/main/java/net/mcreator/target/item/gun/MarlinItem.java @@ -87,19 +87,19 @@ public class MarlinItem extends GunItem implements GeoItem, AnimatedItem { return event.setAndContinue(RawAnimation.begin().thenLoop("animation.marlin.draw")); } - if (stack.getOrCreateTag().getInt("fire_animation") > 0 && stack.getOrCreateTag().getDouble("animindex") == 0) { + if (stack.getOrCreateTag().getInt("flash_time") > 0 && stack.getOrCreateTag().getDouble("animindex") == 0) { return event.setAndContinue(RawAnimation.begin().thenPlay("animation.marlin.fire")); } - if (stack.getOrCreateTag().getInt("fire_animation") > 0 && stack.getOrCreateTag().getDouble("animindex") == 1) { + if (stack.getOrCreateTag().getInt("flash_time") > 0 && stack.getOrCreateTag().getDouble("animindex") == 1) { return event.setAndContinue(RawAnimation.begin().thenPlay("animation.marlin.fire2")); } - if (stack.getOrCreateTag().getDouble("firing") > 0 && stack.getOrCreateTag().getDouble("firing") < 15 && stack.getOrCreateTag().getDouble("fastfiring") == 0) { + if (stack.getOrCreateTag().getDouble("marlin_animation_time") > 0 && stack.getOrCreateTag().getDouble("fastfiring") == 0) { return event.setAndContinue(RawAnimation.begin().thenPlay("animation.marlin.shift")); } - if (stack.getOrCreateTag().getDouble("firing") > 0 && stack.getOrCreateTag().getDouble("firing") < 10 && stack.getOrCreateTag().getDouble("fastfiring") == 1) { + if (stack.getOrCreateTag().getDouble("marlin_animation_time") > 0 && stack.getOrCreateTag().getDouble("fastfiring") == 1) { return event.setAndContinue(RawAnimation.begin().thenPlay("animation.marlin.shift2")); } @@ -107,11 +107,11 @@ public class MarlinItem extends GunItem implements GeoItem, AnimatedItem { return event.setAndContinue(RawAnimation.begin().thenPlay("animation.marlin.prepare")); } - if (!stack.getOrCreateTag().getBoolean("load_index") && stack.getOrCreateTag().getDouble("loading") > 0) { + if (stack.getOrCreateTag().getDouble("load_index") == 0 && stack.getOrCreateTag().getDouble("loading") > 0) { return event.setAndContinue(RawAnimation.begin().thenPlay("animation.marlin.iterativeload")); } - if (stack.getOrCreateTag().getBoolean("load_index") && stack.getOrCreateTag().getDouble("loading") > 0) { + if (stack.getOrCreateTag().getDouble("load_index") == 1 && stack.getOrCreateTag().getDouble("loading") > 0) { return event.setAndContinue(RawAnimation.begin().thenPlay("animation.marlin.iterativeload2")); } @@ -177,6 +177,9 @@ public class MarlinItem extends GunItem implements GeoItem, AnimatedItem { tag.putDouble("force_stop", 0); tag.putDouble("stop", 0); } + if (tag.getDouble("marlin_animation_time") > 0) { + tag.putDouble("marlin_animation_time", tag.getDouble("marlin_animation_time") - 1); + } if (tag.getDouble("prepare") > 0) { tag.putDouble("prepare", tag.getDouble("prepare") - 1); } @@ -200,7 +203,11 @@ public class MarlinItem extends GunItem implements GeoItem, AnimatedItem { if (entity instanceof ServerPlayer serverPlayer) { SoundTool.playLocalSound(serverPlayer, TargetModSounds.MARLIN_LOOP.get(), 100, 1); } - tag.putBoolean("load_index", tag.getBoolean("load_index")); + if (tag.getDouble("load_index") == 1) { + tag.putDouble("load_index", 0); + } else { + tag.putDouble("load_index", 1); + } } } if (tag.getDouble("loading") == 9) { @@ -222,9 +229,6 @@ public class MarlinItem extends GunItem implements GeoItem, AnimatedItem { } } } - if (tag.getDouble("firing") > 0) { - tag.putDouble("firing", tag.getDouble("firing") - 1); - } } } diff --git a/src/main/java/net/mcreator/target/item/gun/Minigun.java b/src/main/java/net/mcreator/target/item/gun/Minigun.java index bfe8a2af1..9e8963fc8 100644 --- a/src/main/java/net/mcreator/target/item/gun/Minigun.java +++ b/src/main/java/net/mcreator/target/item/gun/Minigun.java @@ -6,7 +6,6 @@ import net.mcreator.target.TargetMod; import net.mcreator.target.client.renderer.item.MinigunItemRenderer; import net.mcreator.target.init.TargetModItems; import net.mcreator.target.item.AnimatedItem; -import net.mcreator.target.procedures.MiniguninbackpackProcedure; import net.mcreator.target.tools.GunsTool; import net.mcreator.target.tools.ItemNBTTool; import net.mcreator.target.tools.RarityTool; @@ -183,7 +182,19 @@ public class Minigun extends GunItem implements GeoItem, AnimatedItem { @Override public void inventoryTick(ItemStack itemstack, Level world, Entity entity, int slot, boolean selected) { super.inventoryTick(itemstack, world, entity, slot, selected); - MiniguninbackpackProcedure.execute(entity, itemstack); + if (entity == null) + return; + if (itemstack.getOrCreateTag().getDouble("heat") > 0) { + itemstack.getOrCreateTag().putDouble("heat", (itemstack.getOrCreateTag().getDouble("heat") - 0.5)); + } + if (itemstack.getOrCreateTag().getDouble("heat") == 0) { + itemstack.getOrCreateTag().putDouble("heat_bar", 51); + } else { + itemstack.getOrCreateTag().putDouble("heat_bar", (itemstack.getOrCreateTag().getDouble("heat"))); + } + if (itemstack.getOrCreateTag().getDouble("overheat") > 0) { + itemstack.getOrCreateTag().putDouble("overheat", (itemstack.getOrCreateTag().getDouble("overheat") - 1)); + } } public static ItemStack getGunInstance() { diff --git a/src/main/java/net/mcreator/target/network/message/FireMessage.java b/src/main/java/net/mcreator/target/network/message/FireMessage.java index dcce988f2..6cf51918c 100644 --- a/src/main/java/net/mcreator/target/network/message/FireMessage.java +++ b/src/main/java/net/mcreator/target/network/message/FireMessage.java @@ -57,7 +57,6 @@ public class FireMessage { PressFireProcedure.execute(player); } else if (type == 1) { player.getPersistentData().putBoolean("firing", false); - player.getPersistentData().putDouble("mini_firing", 0); player.getPersistentData().putDouble("minigun_firing", 0); player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> { capability.bowPullHold = false; diff --git a/src/main/java/net/mcreator/target/procedures/M870fireProcedure.java b/src/main/java/net/mcreator/target/procedures/M870fireProcedure.java deleted file mode 100644 index 463c50284..000000000 --- a/src/main/java/net/mcreator/target/procedures/M870fireProcedure.java +++ /dev/null @@ -1,36 +0,0 @@ -package net.mcreator.target.procedures; - -import net.mcreator.target.init.TargetModItems; -import net.mcreator.target.init.TargetModSounds; -import net.mcreator.target.tools.GunsTool; -import net.mcreator.target.tools.SoundTool; -import net.minecraft.world.entity.player.Player; -import net.minecraft.world.item.ItemStack; - -public class M870fireProcedure { - public static void execute(Player player) { - if (player.isSpectator()) return; - - ItemStack usehand = player.getMainHandItem(); - if (usehand.getOrCreateTag().getBoolean("reloading") && usehand.getOrCreateTag().getDouble("prepare") == 0 && usehand.getOrCreateTag().getInt("ammo") > 0) { - usehand.getOrCreateTag().putDouble("force_stop", 1); - } - if (usehand.getItem() == TargetModItems.M_870.get() && !usehand.getOrCreateTag().getBoolean("reloading") && !player.getCooldowns().isOnCooldown(usehand.getItem()) - && usehand.getOrCreateTag().getInt("ammo") > 0) { - for (int index0 = 0; index0 < 12; index0++) { - GunsTool.spawnBullet(player); - } - player.getCooldowns().addCooldown(usehand.getItem(), 13); - usehand.getOrCreateTag().putDouble("firing", 13); - - if (!player.level().isClientSide()) { - SoundTool.playLocalSound(player, TargetModSounds.M_870_FIRE_1P.get(), 2, 1); - SoundTool.playLocalSound(player, TargetModSounds.M_870_FIRE_3P.get(), 4, 1); - SoundTool.playLocalSound(player, TargetModSounds.M_870_FAR.get(), 12, 1); - SoundTool.playLocalSound(player, TargetModSounds.M_870_VERYFAR.get(), 24, 1); - } - usehand.getOrCreateTag().putInt("ammo", (usehand.getOrCreateTag().getInt("ammo") - 1)); - usehand.getOrCreateTag().putInt("fire_animation", 2); - } - } -} diff --git a/src/main/java/net/mcreator/target/procedures/MarlinfireProcedure.java b/src/main/java/net/mcreator/target/procedures/MarlinfireProcedure.java deleted file mode 100644 index 52568c769..000000000 --- a/src/main/java/net/mcreator/target/procedures/MarlinfireProcedure.java +++ /dev/null @@ -1,47 +0,0 @@ -package net.mcreator.target.procedures; - -import net.mcreator.target.init.TargetModItems; -import net.mcreator.target.init.TargetModSounds; -import net.mcreator.target.network.TargetModVariables; -import net.mcreator.target.tools.GunsTool; -import net.mcreator.target.tools.SoundTool; -import net.minecraft.world.entity.player.Player; -import net.minecraft.world.item.ItemStack; - -public class MarlinfireProcedure { - public static void execute(Player player) { - if (player.isSpectator()) return; - - ItemStack usehand = player.getMainHandItem(); - if (usehand.getOrCreateTag().getBoolean("reloading") && usehand.getOrCreateTag().getDouble("prepare") == 0 && usehand.getOrCreateTag().getInt("ammo") > 0) { - usehand.getOrCreateTag().putDouble("force_stop", 1); - } - if (usehand.getItem() == TargetModItems.MARLIN.get() && !usehand.getOrCreateTag().getBoolean("reloading") && !player.getCooldowns().isOnCooldown(usehand.getItem()) - && usehand.getOrCreateTag().getInt("ammo") > 0) { - if ((player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).zooming) { - player.getCooldowns().addCooldown(usehand.getItem(), 15); - usehand.getOrCreateTag().putDouble("firing", 15); - usehand.getOrCreateTag().putDouble("fastfiring", 0); - } else { - player.getCooldowns().addCooldown(usehand.getItem(), 10); - usehand.getOrCreateTag().putDouble("fastfiring", 1); - usehand.getOrCreateTag().putDouble("firing", 10); - } - GunsTool.spawnBullet(player); - - if (!player.level().isClientSide() && player.getServer() != null) { - SoundTool.playLocalSound(player, TargetModSounds.MARLIN_FIRE_1P.get(), 2, 1); - SoundTool.playLocalSound(player, TargetModSounds.MARLIN_FIRE_3P.get(), 4, 1); - SoundTool.playLocalSound(player, TargetModSounds.MARLIN_FAR.get(), 12, 1); - SoundTool.playLocalSound(player, TargetModSounds.MARLIN_VERYFAR.get(), 24, 1); - } - usehand.getOrCreateTag().putInt("ammo", (usehand.getOrCreateTag().getInt("ammo") - 1)); - if (usehand.getOrCreateTag().getDouble("animindex") == 1) { - usehand.getOrCreateTag().putDouble("animindex", 0); - } else { - usehand.getOrCreateTag().putDouble("animindex", 1); - } - usehand.getOrCreateTag().putInt("fire_animation", 2); - } - } -} diff --git a/src/main/java/net/mcreator/target/procedures/MiniguninbackpackProcedure.java b/src/main/java/net/mcreator/target/procedures/MiniguninbackpackProcedure.java deleted file mode 100644 index ddf955a61..000000000 --- a/src/main/java/net/mcreator/target/procedures/MiniguninbackpackProcedure.java +++ /dev/null @@ -1,28 +0,0 @@ -package net.mcreator.target.procedures; - -import net.mcreator.target.init.TargetModItems; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.LivingEntity; -import net.minecraft.world.item.ItemStack; - -public class MiniguninbackpackProcedure { - public static void execute(Entity entity, ItemStack itemstack) { - if (entity == null) - return; - if (itemstack.getOrCreateTag().getDouble("heat") > 0) { - itemstack.getOrCreateTag().putDouble("heat", (itemstack.getOrCreateTag().getDouble("heat") - 0.5)); - } - if (itemstack.getOrCreateTag().getDouble("heat") == 0) { - itemstack.getOrCreateTag().putDouble("heat_bar", 51); - } else { - itemstack.getOrCreateTag().putDouble("heat_bar", (itemstack.getOrCreateTag().getDouble("heat"))); - } - if (!((entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getItem() == TargetModItems.MINIGUN.get())) { - entity.getPersistentData().putDouble("minigun_firing", 0); - } - if (itemstack.getOrCreateTag().getDouble("overheat") > 0) { - entity.getPersistentData().putDouble("mini_firing", 0); - itemstack.getOrCreateTag().putDouble("overheat", (itemstack.getOrCreateTag().getDouble("overheat") - 1)); - } - } -} diff --git a/src/main/java/net/mcreator/target/procedures/PressFireProcedure.java b/src/main/java/net/mcreator/target/procedures/PressFireProcedure.java index 810336cd3..a64b9576b 100644 --- a/src/main/java/net/mcreator/target/procedures/PressFireProcedure.java +++ b/src/main/java/net/mcreator/target/procedures/PressFireProcedure.java @@ -16,17 +16,17 @@ public class PressFireProcedure { TaserfireProcedure.execute(player); M79fireProcedure.execute(player); RpgFireProcedure.execute(player); - MarlinfireProcedure.execute(player); - M870fireProcedure.execute(player); if (mainHandItem.is(TargetModTags.Items.GUN)) { - if (tag.getInt("fire_mode") == 1) { player.getPersistentData().putBoolean("firing", false); tag.putInt("burst_fire", (int) tag.getDouble("burst_size")); } else { player.getPersistentData().putBoolean("firing", true); } + if (tag.getDouble("force_stop_reloading") == 1 && tag.getBoolean("reloading") && tag.getDouble("prepare") == 0 && tag.getInt("ammo") > 0) { + tag.putDouble("force_stop", 1); + } } @@ -41,8 +41,6 @@ public class PressFireProcedure { } if (mainHandItem.getItem() == TargetModItems.MINIGUN.get()) { - player.getPersistentData().putDouble("mini_firing", 1); - if ((player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).rifleAmmo == 0) { if (!player.level().isClientSide()) { SoundTool.playLocalSound(player, TargetModSounds.TRIGGER_CLICK.get(), 10, 1); diff --git a/src/main/resources/data/target/guns/m_870.json b/src/main/resources/data/target/guns/m_870.json index d9ab8ba6d..7032afe57 100644 --- a/src/main/resources/data/target/guns/m_870.json +++ b/src/main/resources/data/target/guns/m_870.json @@ -8,6 +8,9 @@ "headshot": 1.5, "velocity": 20, "mag": 8, + "force_stop_reloading": 1, + "projectile_amount": 12, + "fire_interval": 13, "weight": 1, "fire_mode": 0, "semi": 1, diff --git a/src/main/resources/data/target/guns/marlin.json b/src/main/resources/data/target/guns/marlin.json index 4c7f69999..8be509942 100644 --- a/src/main/resources/data/target/guns/marlin.json +++ b/src/main/resources/data/target/guns/marlin.json @@ -8,6 +8,9 @@ "headshot": 2.5, "velocity": 27, "mag": 8, + "force_stop_reloading": 1, + "projectile_amount": 1, + "fire_interval": 10, "weight": 1, "fire_mode": 0, "semi": 1, diff --git a/src/main/resources/data/target/guns/minigun.json b/src/main/resources/data/target/guns/minigun.json index f77e266ba..46020a08c 100644 --- a/src/main/resources/data/target/guns/minigun.json +++ b/src/main/resources/data/target/guns/minigun.json @@ -9,8 +9,5 @@ "fire_interval": 1, "weight": 2, "fire_mode": 2, - "semi": 0, - "burst": 0, - "auto": 1, - "burst_size": 1 + "projectile_amount": 1 } \ No newline at end of file diff --git a/src/main/resources/data/target/tags/items/normal_gun.json b/src/main/resources/data/target/tags/items/normal_gun.json index 734b0132b..cf3127c4b 100644 --- a/src/main/resources/data/target/tags/items/normal_gun.json +++ b/src/main/resources/data/target/tags/items/normal_gun.json @@ -17,6 +17,8 @@ "target:hunting_rifle", "target:kraber", "target:m_98b", - "target:sentinel" + "target:sentinel", + "target:m_870", + "target:marlin" ] } \ No newline at end of file