移除加特林、M870和Marlin的开火procedure

This commit is contained in:
Atsuihsio 2024-05-21 13:23:27 +08:00
parent e6f6bd0679
commit 58df69ba68
17 changed files with 134 additions and 217 deletions

View file

@ -90,7 +90,7 @@ public class M870ItemModel extends GeoModel<M870Item> {
CoreGeoBone flare = getAnimationProcessor().getBone("flare"); 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.setScaleX((float) (1.0 + 0.5 * (Math.random() - 0.5)));
flare.setScaleY((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))); flare.setRotZ((float) (0.5 * (Math.random() - 0.5)));

View file

@ -79,7 +79,7 @@ public class MarlinItemModel extends GeoModel<MarlinItem> {
CoreGeoBone flare = getAnimationProcessor().getBone("flare"); 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.setScaleX((float) (1.0 + 0.5 * (Math.random() - 0.5)));
flare.setScaleY((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))); flare.setRotZ((float) (0.5 * (Math.random() - 0.5)));

View file

@ -41,10 +41,8 @@ public class MinigunItemModel extends GeoModel<Minigun> {
} }
float times = 250f / fps; 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; double fp = 0;

View file

@ -4,8 +4,10 @@ import net.mcreator.target.TargetMod;
import net.mcreator.target.entity.ProjectileEntity; import net.mcreator.target.entity.ProjectileEntity;
import net.mcreator.target.init.TargetModAttributes; import net.mcreator.target.init.TargetModAttributes;
import net.mcreator.target.init.TargetModItems; import net.mcreator.target.init.TargetModItems;
import net.mcreator.target.init.TargetModSounds;
import net.mcreator.target.init.TargetModTags; import net.mcreator.target.init.TargetModTags;
import net.mcreator.target.network.TargetModVariables; import net.mcreator.target.network.TargetModVariables;
import net.mcreator.target.tools.GunsTool;
import net.mcreator.target.tools.SoundTool; import net.mcreator.target.tools.SoundTool;
import net.minecraft.commands.CommandSource; import net.minecraft.commands.CommandSource;
import net.minecraft.commands.CommandSourceStack; import net.minecraft.commands.CommandSourceStack;
@ -36,6 +38,7 @@ public class GunEventHandler {
if (event.phase == TickEvent.Phase.END) { if (event.phase == TickEvent.Phase.END) {
handleGunsDev(player); handleGunsDev(player);
handleGunFire(player); handleGunFire(player);
handleMiniGunFire(player);
} }
} }
@ -106,7 +109,9 @@ public class GunEventHandler {
Thread recoilThread = new Thread(recoilRunnable); Thread recoilThread = new Thread(recoilRunnable);
recoilThread.start(); recoilThread.start();
} }
/*
通用的武器开火流程
*/
private static void handleGunFire(Player player) { private static void handleGunFire(Player player) {
ItemStack stack = player.getMainHandItem(); ItemStack stack = player.getMainHandItem();
if (stack.is(TargetModTags.Items.NORMAL_GUN)) { if (stack.is(TargetModTags.Items.NORMAL_GUN)) {
@ -195,7 +200,20 @@ public class GunEventHandler {
stack.getOrCreateTag().putDouble("crot", 20); 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); player.getCooldowns().addCooldown(stack.getItem(), cooldown);
for (int index0 = 0; index0 < (int) stack.getOrCreateTag().getDouble("projectile_amount"); index0++) { 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) { public static void gunShoot(Player player) {
ItemStack heldItem = player.getMainHandItem(); 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 -> { player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
capability.recoilHorizon = Math.random() < 0.5 ? -1 : 1;
capability.recoil = 0.1; capability.recoil = 0.1;
capability.firing = 1; capability.firing = 1;
capability.syncPlayerVariables(player); capability.syncPlayerVariables(player);

View file

@ -68,7 +68,6 @@ public class PlayerEventHandler {
handleRenderDamageIndicator(player); handleRenderDamageIndicator(player);
handleBocekPulling(player); handleBocekPulling(player);
handleGunRecoil(player); handleGunRecoil(player);
handleMiniGunFire(player);
} }
} }
@ -447,61 +446,5 @@ public class PlayerEventHandler {
recoilThread.start(); 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);
}
}
} }

View file

@ -88,7 +88,7 @@ public class M870Item extends GunItem implements GeoItem, AnimatedItem {
return event.setAndContinue(RawAnimation.begin().thenLoop("animation.m870.draw")); 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")); 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")); 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")); 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")); 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) { if (entity instanceof ServerPlayer serverPlayer) {
SoundTool.playLocalSound(serverPlayer, TargetModSounds.M_870_RELOAD_LOOP.get(), 100, 1); 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) { if (tag.getDouble("loading") == 9) {
@ -222,9 +226,6 @@ public class M870Item extends GunItem implements GeoItem, AnimatedItem {
tag.putBoolean("empty_reload", false); tag.putBoolean("empty_reload", false);
} }
} }
if (tag.getDouble("firing") > 0) {
tag.putDouble("firing", tag.getDouble("firing") - 1);
}
} }
} }

View file

@ -87,19 +87,19 @@ public class MarlinItem extends GunItem implements GeoItem, AnimatedItem {
return event.setAndContinue(RawAnimation.begin().thenLoop("animation.marlin.draw")); 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")); 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")); 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")); 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")); 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")); 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")); 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")); 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("force_stop", 0);
tag.putDouble("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) { if (tag.getDouble("prepare") > 0) {
tag.putDouble("prepare", tag.getDouble("prepare") - 1); tag.putDouble("prepare", tag.getDouble("prepare") - 1);
} }
@ -200,7 +203,11 @@ public class MarlinItem extends GunItem implements GeoItem, AnimatedItem {
if (entity instanceof ServerPlayer serverPlayer) { if (entity instanceof ServerPlayer serverPlayer) {
SoundTool.playLocalSound(serverPlayer, TargetModSounds.MARLIN_LOOP.get(), 100, 1); 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) { 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);
}
} }
} }

View file

@ -6,7 +6,6 @@ import net.mcreator.target.TargetMod;
import net.mcreator.target.client.renderer.item.MinigunItemRenderer; import net.mcreator.target.client.renderer.item.MinigunItemRenderer;
import net.mcreator.target.init.TargetModItems; import net.mcreator.target.init.TargetModItems;
import net.mcreator.target.item.AnimatedItem; import net.mcreator.target.item.AnimatedItem;
import net.mcreator.target.procedures.MiniguninbackpackProcedure;
import net.mcreator.target.tools.GunsTool; import net.mcreator.target.tools.GunsTool;
import net.mcreator.target.tools.ItemNBTTool; import net.mcreator.target.tools.ItemNBTTool;
import net.mcreator.target.tools.RarityTool; import net.mcreator.target.tools.RarityTool;
@ -183,7 +182,19 @@ public class Minigun extends GunItem implements GeoItem, AnimatedItem {
@Override @Override
public void inventoryTick(ItemStack itemstack, Level world, Entity entity, int slot, boolean selected) { public void inventoryTick(ItemStack itemstack, Level world, Entity entity, int slot, boolean selected) {
super.inventoryTick(itemstack, world, entity, slot, 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() { public static ItemStack getGunInstance() {

View file

@ -57,7 +57,6 @@ public class FireMessage {
PressFireProcedure.execute(player); PressFireProcedure.execute(player);
} else if (type == 1) { } else if (type == 1) {
player.getPersistentData().putBoolean("firing", false); player.getPersistentData().putBoolean("firing", false);
player.getPersistentData().putDouble("mini_firing", 0);
player.getPersistentData().putDouble("minigun_firing", 0); player.getPersistentData().putDouble("minigun_firing", 0);
player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> { player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
capability.bowPullHold = false; capability.bowPullHold = false;

View file

@ -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);
}
}
}

View file

@ -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);
}
}
}

View file

@ -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));
}
}
}

View file

@ -16,17 +16,17 @@ public class PressFireProcedure {
TaserfireProcedure.execute(player); TaserfireProcedure.execute(player);
M79fireProcedure.execute(player); M79fireProcedure.execute(player);
RpgFireProcedure.execute(player); RpgFireProcedure.execute(player);
MarlinfireProcedure.execute(player);
M870fireProcedure.execute(player);
if (mainHandItem.is(TargetModTags.Items.GUN)) { if (mainHandItem.is(TargetModTags.Items.GUN)) {
if (tag.getInt("fire_mode") == 1) { if (tag.getInt("fire_mode") == 1) {
player.getPersistentData().putBoolean("firing", false); player.getPersistentData().putBoolean("firing", false);
tag.putInt("burst_fire", (int) tag.getDouble("burst_size")); tag.putInt("burst_fire", (int) tag.getDouble("burst_size"));
} else { } else {
player.getPersistentData().putBoolean("firing", true); 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()) { 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.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).rifleAmmo == 0) {
if (!player.level().isClientSide()) { if (!player.level().isClientSide()) {
SoundTool.playLocalSound(player, TargetModSounds.TRIGGER_CLICK.get(), 10, 1); SoundTool.playLocalSound(player, TargetModSounds.TRIGGER_CLICK.get(), 10, 1);

View file

@ -8,6 +8,9 @@
"headshot": 1.5, "headshot": 1.5,
"velocity": 20, "velocity": 20,
"mag": 8, "mag": 8,
"force_stop_reloading": 1,
"projectile_amount": 12,
"fire_interval": 13,
"weight": 1, "weight": 1,
"fire_mode": 0, "fire_mode": 0,
"semi": 1, "semi": 1,

View file

@ -8,6 +8,9 @@
"headshot": 2.5, "headshot": 2.5,
"velocity": 27, "velocity": 27,
"mag": 8, "mag": 8,
"force_stop_reloading": 1,
"projectile_amount": 1,
"fire_interval": 10,
"weight": 1, "weight": 1,
"fire_mode": 0, "fire_mode": 0,
"semi": 1, "semi": 1,

View file

@ -9,8 +9,5 @@
"fire_interval": 1, "fire_interval": 1,
"weight": 2, "weight": 2,
"fire_mode": 2, "fire_mode": 2,
"semi": 0, "projectile_amount": 1
"burst": 0,
"auto": 1,
"burst_size": 1
} }

View file

@ -17,6 +17,8 @@
"target:hunting_rifle", "target:hunting_rifle",
"target:kraber", "target:kraber",
"target:m_98b", "target:m_98b",
"target:sentinel" "target:sentinel",
"target:m_870",
"target:marlin"
] ]
} }