优化大量代码

This commit is contained in:
Light_Quanta 2024-05-06 14:25:05 +08:00
parent b669e5038e
commit 363fa4d284
No known key found for this signature in database
GPG key ID: 11A39A1B8C890959
35 changed files with 763 additions and 1580 deletions

View file

@ -147,7 +147,7 @@ public class TargetModVariables {
public double killind = 0; public double killind = 0;
public void syncPlayerVariables(Entity entity) { public void syncPlayerVariables(Entity entity) {
if (entity instanceof ServerPlayer serverPlayer) if (entity instanceof ServerPlayer)
TargetMod.PACKET_HANDLER.send(PacketDistributor.DIMENSION.with(entity.level()::dimension), new PlayerVariablesSyncMessage(this, entity.getId())); TargetMod.PACKET_HANDLER.send(PacketDistributor.DIMENSION.with(entity.level()::dimension), new PlayerVariablesSyncMessage(this, entity.getId()));
} }

View file

@ -1,56 +1,31 @@
package net.mcreator.target.procedures; package net.mcreator.target.procedures;
import net.mcreator.target.init.TargetModItems; import net.mcreator.target.init.TargetModItems;
import net.minecraft.client.Minecraft;
import net.minecraft.commands.CommandSource; import net.minecraft.commands.CommandSource;
import net.minecraft.commands.CommandSourceStack; import net.minecraft.commands.CommandSourceStack;
import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.GameType;
public class AKfireProcedure { public class AKfireProcedure {
public static void execute(Entity entity) { public static void execute(Entity entity) {
if (entity == null) if (entity == null) return;
return; if (entity instanceof Player player && !player.isSpectator()) {
ItemStack usehand = ItemStack.EMPTY; ItemStack usehand = player.getMainHandItem();
if (!(new Object() {
public boolean checkGamemode(Entity _ent) {
if (_ent instanceof ServerPlayer _serverPlayer) {
return _serverPlayer.gameMode.getGameModeForPlayer() == GameType.SPECTATOR;
} else if (_ent.level().isClientSide() && _ent instanceof Player _player) {
return Minecraft.getInstance().getConnection().getPlayerInfo(_player.getGameProfile().getId()) != null && Minecraft.getInstance().getConnection().getPlayerInfo(_player.getGameProfile().getId()).getGameMode() == GameType.SPECTATOR;
}
return false;
}
}.checkGamemode(entity))) {
usehand = (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY);
if (usehand.getItem() == TargetModItems.AK_47.get()) { if (usehand.getItem() == TargetModItems.AK_47.get()) {
if (usehand.getOrCreateTag().getDouble("firemode") == 0) { if (usehand.getOrCreateTag().getDouble("firemode") == 0) {
if (usehand.getOrCreateTag().getDouble("reloading") == 0 && usehand.getOrCreateTag().getDouble("ammo") > 0 && !(entity instanceof Player _plrCldCheck6 && _plrCldCheck6.getCooldowns().isOnCooldown(usehand.getItem()))) { if (usehand.getOrCreateTag().getDouble("reloading") == 0 && usehand.getOrCreateTag().getDouble("ammo") > 0 && !(entity instanceof Player _plrCldCheck6 && _plrCldCheck6.getCooldowns().isOnCooldown(usehand.getItem()))) {
if (entity instanceof Player _player) player.getCooldowns().addCooldown(usehand.getItem(), 2);
_player.getCooldowns().addCooldown(usehand.getItem(), 2);
{
if (!entity.level().isClientSide() && entity.getServer() != null) { if (!entity.level().isClientSide() && entity.getServer() != null) {
entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), entity.level() instanceof ServerLevel ? (ServerLevel) entity.level() : null, 4, entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), entity.level() instanceof ServerLevel ? (ServerLevel) entity.level() : null, 4,
entity.getName().getString(), entity.getDisplayName(), entity.level().getServer(), entity), "playsound target:ak47_fire_1p player @s ~ ~ ~ 2 1"); entity.getName().getString(), entity.getDisplayName(), entity.level().getServer(), entity), "playsound target:ak47_fire_1p player @s ~ ~ ~ 2 1");
}
}
{
if (!entity.level().isClientSide() && entity.getServer() != null) {
entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), entity.level() instanceof ServerLevel ? (ServerLevel) entity.level() : null, 4, entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), entity.level() instanceof ServerLevel ? (ServerLevel) entity.level() : null, 4,
entity.getName().getString(), entity.getDisplayName(), entity.level().getServer(), entity), "playsound target:ak47_fire_3p player @a ~ ~ ~ 4 1"); entity.getName().getString(), entity.getDisplayName(), entity.level().getServer(), entity), "playsound target:ak47_fire_3p player @a ~ ~ ~ 4 1");
}
}
{
if (!entity.level().isClientSide() && entity.getServer() != null) {
entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), entity.level() instanceof ServerLevel ? (ServerLevel) entity.level() : null, 4, entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), entity.level() instanceof ServerLevel ? (ServerLevel) entity.level() : null, 4,
entity.getName().getString(), entity.getDisplayName(), entity.level().getServer(), entity), "stopsound @s player target:ak47_fire_3p"); entity.getName().getString(), entity.getDisplayName(), entity.level().getServer(), entity), "stopsound @s player target:ak47_fire_3p");
} }
}
BulletFireNormalProcedure.execute(entity); BulletFireNormalProcedure.execute(entity);
AkDsProcedure.execute(entity); AkDsProcedure.execute(entity);
usehand.getOrCreateTag().putDouble("fireanim", 2); usehand.getOrCreateTag().putDouble("fireanim", 2);

View file

@ -1,30 +1,16 @@
package net.mcreator.target.procedures; package net.mcreator.target.procedures;
import net.mcreator.target.init.TargetModItems; import net.mcreator.target.init.TargetModItems;
import net.minecraft.client.Minecraft;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.GameType;
public class Aa12fireProcedure { public class Aa12fireProcedure {
public static void execute(Entity entity) { public static void execute(Entity entity) {
if (entity == null) if (entity == null) return;
return;
ItemStack usehand; ItemStack usehand;
if (!(new Object() { if (entity instanceof Player player && !player.isSpectator()) {
public boolean checkGamemode(Entity _ent) { usehand = player.getMainHandItem();
if (_ent instanceof ServerPlayer _serverPlayer) {
return _serverPlayer.gameMode.getGameModeForPlayer() == GameType.SPECTATOR;
} else if (_ent.level().isClientSide() && _ent instanceof Player _player) {
return Minecraft.getInstance().getConnection().getPlayerInfo(_player.getGameProfile().getId()) != null && Minecraft.getInstance().getConnection().getPlayerInfo(_player.getGameProfile().getId()).getGameMode() == GameType.SPECTATOR;
}
return false;
}
}.checkGamemode(entity))) {
usehand = (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY);
if (usehand.getItem() == TargetModItems.AA_12.get()) { if (usehand.getItem() == TargetModItems.AA_12.get()) {
entity.getPersistentData().putDouble("firing", 1); entity.getPersistentData().putDouble("firing", 1);
} }

View file

@ -1,46 +1,28 @@
package net.mcreator.target.procedures; package net.mcreator.target.procedures;
import net.mcreator.target.init.TargetModItems; import net.mcreator.target.init.TargetModItems;
import net.minecraft.client.Minecraft;
import net.minecraft.commands.CommandSource; import net.minecraft.commands.CommandSource;
import net.minecraft.commands.CommandSourceStack; import net.minecraft.commands.CommandSourceStack;
import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.util.RandomSource; import net.minecraft.util.RandomSource;
import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.GameType;
public class AbkrfireProcedure { public class AbkrfireProcedure {
public static void execute(Entity entity) { public static void execute(Entity entity) {
if (entity == null) if (entity == null) return;
return; if (entity instanceof Player player && !player.isSpectator()) {
ItemStack usehand = ItemStack.EMPTY; ItemStack usehand = player.getMainHandItem();
if (!(new Object() {
public boolean checkGamemode(Entity _ent) {
if (_ent instanceof ServerPlayer _serverPlayer) {
return _serverPlayer.gameMode.getGameModeForPlayer() == GameType.SPECTATOR;
} else if (_ent.level().isClientSide() && _ent instanceof Player _player) {
return Minecraft.getInstance().getConnection().getPlayerInfo(_player.getGameProfile().getId()) != null && Minecraft.getInstance().getConnection().getPlayerInfo(_player.getGameProfile().getId()).getGameMode() == GameType.SPECTATOR;
}
return false;
}
}.checkGamemode(entity))) {
usehand = (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY);
if (usehand.getItem() == TargetModItems.ABEKIRI.get() && usehand.getOrCreateTag().getDouble("reloading") == 0 && !(entity instanceof Player _plrCldCheck4 && _plrCldCheck4.getCooldowns().isOnCooldown(usehand.getItem())) if (usehand.getItem() == TargetModItems.ABEKIRI.get() && usehand.getOrCreateTag().getDouble("reloading") == 0 && !(entity instanceof Player _plrCldCheck4 && _plrCldCheck4.getCooldowns().isOnCooldown(usehand.getItem()))
&& usehand.getOrCreateTag().getDouble("ammo") > 0) { && usehand.getOrCreateTag().getDouble("ammo") > 0) {
for (int index0 = 0; index0 < 8; index0++) { for (int index0 = 0; index0 < 8; index0++) {
BulletFireNormalProcedure.execute(entity); BulletFireNormalProcedure.execute(entity);
} }
{
if (usehand.hurt(1, RandomSource.create(), null)) { if (usehand.hurt(1, RandomSource.create(), null)) {
usehand.shrink(1); usehand.shrink(1);
usehand.setDamageValue(0); usehand.setDamageValue(0);
} }
}
{
if (!entity.level().isClientSide() && entity.getServer() != null) { if (!entity.level().isClientSide() && entity.getServer() != null) {
entity.getServer().getCommands().performPrefixedCommand( entity.getServer().getCommands().performPrefixedCommand(
new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), entity.level() instanceof ServerLevel ? (ServerLevel) entity.level() : null, 4, entity.getName().getString(), entity.getDisplayName(), new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), entity.level() instanceof ServerLevel ? (ServerLevel) entity.level() : null, 4, entity.getName().getString(), entity.getDisplayName(),
@ -48,15 +30,12 @@ public class AbkrfireProcedure {
("particle minecraft:cloud" + (" " + (entity.getX() + 1.8 * entity.getLookAngle().x)) + (" " + (entity.getY() + entity.getBbHeight() - 0.1 + 1.8 * entity.getLookAngle().y)) ("particle minecraft:cloud" + (" " + (entity.getX() + 1.8 * entity.getLookAngle().x)) + (" " + (entity.getY() + entity.getBbHeight() - 0.1 + 1.8 * entity.getLookAngle().y))
+ (" " + (entity.getZ() + 1.8 * entity.getLookAngle().z)) + " 0.4 0.4 0.4 0.005 30 force @s")); + (" " + (entity.getZ() + 1.8 * entity.getLookAngle().z)) + " 0.4 0.4 0.4 0.005 30 force @s"));
} }
} player.getCooldowns().addCooldown(usehand.getItem(), 2);
if (entity instanceof Player _player)
_player.getCooldowns().addCooldown(usehand.getItem(), 2);
{
if (!entity.level().isClientSide() && entity.getServer() != null) { if (!entity.level().isClientSide() && entity.getServer() != null) {
entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), entity.level() instanceof ServerLevel ? (ServerLevel) entity.level() : null, 4, entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), entity.level() instanceof ServerLevel ? (ServerLevel) entity.level() : null, 4,
entity.getName().getString(), entity.getDisplayName(), entity.level().getServer(), entity), "playsound target:abkr_fire_3p player @a ~ ~ ~ 4 1"); entity.getName().getString(), entity.getDisplayName(), entity.level().getServer(), entity), "playsound target:abkr_fire_3p player @a ~ ~ ~ 4 1");
} }
}
usehand.getOrCreateTag().putDouble("fireanim", 2); usehand.getOrCreateTag().putDouble("fireanim", 2);
usehand.getOrCreateTag().putDouble("ammo", (usehand.getOrCreateTag().getDouble("ammo") - 1)); usehand.getOrCreateTag().putDouble("ammo", (usehand.getOrCreateTag().getDouble("ammo") - 1));
} }

View file

@ -5,11 +5,9 @@ import net.mcreator.target.entity.ProjectileEntity;
import net.mcreator.target.init.TargetModEntities; import net.mcreator.target.init.TargetModEntities;
import net.mcreator.target.init.TargetModItems; import net.mcreator.target.init.TargetModItems;
import net.mcreator.target.network.TargetModVariables; import net.mcreator.target.network.TargetModVariables;
import net.minecraft.client.Minecraft;
import net.minecraft.commands.CommandSource; import net.minecraft.commands.CommandSource;
import net.minecraft.commands.CommandSourceStack; import net.minecraft.commands.CommandSourceStack;
import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.player.Player;
@ -17,34 +15,25 @@ import net.minecraft.world.entity.projectile.AbstractArrow;
import net.minecraft.world.entity.projectile.Projectile; import net.minecraft.world.entity.projectile.Projectile;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items; import net.minecraft.world.item.Items;
import net.minecraft.world.level.GameType;
import net.minecraft.world.level.Level; import net.minecraft.world.level.Level;
public class BowlooseProcedure { public class BowlooseProcedure {
public static void execute(Entity entity) { public static void execute(Entity entity) {
if (entity == null) if (entity == null) return;
return;
ItemStack usehand = ItemStack.EMPTY; ItemStack usehand = ItemStack.EMPTY;
double power = 0; double power;
power = (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("power"); power = (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("power");
{
if (!entity.level().isClientSide() && entity.getServer() != null) { if (!entity.level().isClientSide() && entity.getServer() != null) {
entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), entity.level() instanceof ServerLevel ? (ServerLevel) entity.level() : null, 4, entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), entity.level() instanceof ServerLevel ? (ServerLevel) entity.level() : null, 4,
entity.getName().getString(), entity.getDisplayName(), entity.level().getServer(), entity), "stopsound @s player target:bowpull"); entity.getName().getString(), entity.getDisplayName(), entity.level().getServer(), entity), "stopsound @s player target:bowpull");
}
}
{
if (!entity.level().isClientSide() && entity.getServer() != null) {
entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), entity.level() instanceof ServerLevel ? (ServerLevel) entity.level() : null, 4, entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), entity.level() instanceof ServerLevel ? (ServerLevel) entity.level() : null, 4,
entity.getName().getString(), entity.getDisplayName(), entity.level().getServer(), entity), "stopsound @s player target:bowpull1p"); entity.getName().getString(), entity.getDisplayName(), entity.level().getServer(), entity), "stopsound @s player target:bowpull1p");
} }
}
if ((entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getItem() == TargetModItems.BOCEK.get() if ((entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getItem() == TargetModItems.BOCEK.get()
&& (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("power") >= 6) { && (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("power") >= 6) {
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("speed", (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("speed",
((entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("power"))); ((entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("power")));
if ((entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).zooming) { if ((entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).zooming) {
{
Level projectileLevel = entity.level(); Level projectileLevel = entity.level();
if (!projectileLevel.isClientSide()) { if (!projectileLevel.isClientSide()) {
Projectile _entityToSpawn = new Object() { Projectile _entityToSpawn = new Object() {
@ -63,25 +52,14 @@ public class BowlooseProcedure {
_entityToSpawn.shoot(entity.getLookAngle().x, entity.getLookAngle().y, entity.getLookAngle().z, (float) (4 * power), (float) 0.05); _entityToSpawn.shoot(entity.getLookAngle().x, entity.getLookAngle().y, entity.getLookAngle().z, (float) (4 * power), (float) 0.05);
projectileLevel.addFreshEntity(_entityToSpawn); projectileLevel.addFreshEntity(_entityToSpawn);
} }
}
{
if (!entity.level().isClientSide() && entity.getServer() != null) { if (!entity.level().isClientSide() && entity.getServer() != null) {
entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), entity.level() instanceof ServerLevel ? (ServerLevel) entity.level() : null, 4, entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), entity.level() instanceof ServerLevel ? (ServerLevel) entity.level() : null, 4,
entity.getName().getString(), entity.getDisplayName(), entity.level().getServer(), entity), "playsound target:bowfire1p player @s ~ ~ ~ 10 1"); entity.getName().getString(), entity.getDisplayName(), entity.level().getServer(), entity), "playsound target:bowfire1p player @s ~ ~ ~ 10 1");
}
}
{
if (!entity.level().isClientSide() && entity.getServer() != null) {
entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), entity.level() instanceof ServerLevel ? (ServerLevel) entity.level() : null, 4, entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), entity.level() instanceof ServerLevel ? (ServerLevel) entity.level() : null, 4,
entity.getName().getString(), entity.getDisplayName(), entity.level().getServer(), entity), "playsound target:bowfire3p player @a ~ ~ ~ 2 1"); entity.getName().getString(), entity.getDisplayName(), entity.level().getServer(), entity), "playsound target:bowfire3p player @a ~ ~ ~ 2 1");
}
}
{
if (!entity.level().isClientSide() && entity.getServer() != null) {
entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), entity.level() instanceof ServerLevel ? (ServerLevel) entity.level() : null, 4, entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), entity.level() instanceof ServerLevel ? (ServerLevel) entity.level() : null, 4,
entity.getName().getString(), entity.getDisplayName(), entity.level().getServer(), entity), "stopsound @s player target:bowfire3p"); entity.getName().getString(), entity.getDisplayName(), entity.level().getServer(), entity), "stopsound @s player target:bowfire3p");
} }
}
} else { } else {
for (int index0 = 0; index0 < 10; index0++) { for (int index0 = 0; index0 < 10; index0++) {
if (!entity.level().isClientSide() && entity instanceof LivingEntity living) { if (!entity.level().isClientSide() && entity instanceof LivingEntity living) {
@ -91,77 +69,33 @@ public class BowlooseProcedure {
entity.level().addFreshEntity(projectile); entity.level().addFreshEntity(projectile);
} }
} }
{
if (!entity.level().isClientSide() && entity.getServer() != null) { if (!entity.level().isClientSide() && entity.getServer() != null) {
entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), entity.level() instanceof ServerLevel ? (ServerLevel) entity.level() : null, 4, entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), entity.level() instanceof ServerLevel ? (ServerLevel) entity.level() : null, 4,
entity.getName().getString(), entity.getDisplayName(), entity.level().getServer(), entity), "playsound target:shotfire player @s ~ ~ ~ 10 1"); entity.getName().getString(), entity.getDisplayName(), entity.level().getServer(), entity), "playsound target:shotfire player @s ~ ~ ~ 10 1");
}
}
{
if (!entity.level().isClientSide() && entity.getServer() != null) {
entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), entity.level() instanceof ServerLevel ? (ServerLevel) entity.level() : null, 4, entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), entity.level() instanceof ServerLevel ? (ServerLevel) entity.level() : null, 4,
entity.getName().getString(), entity.getDisplayName(), entity.level().getServer(), entity), "playsound target:shotfire3p player @a ~ ~ ~ 2 1"); entity.getName().getString(), entity.getDisplayName(), entity.level().getServer(), entity), "playsound target:shotfire3p player @a ~ ~ ~ 2 1");
}
}
{
if (!entity.level().isClientSide() && entity.getServer() != null) {
entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), entity.level() instanceof ServerLevel ? (ServerLevel) entity.level() : null, 4, entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), entity.level() instanceof ServerLevel ? (ServerLevel) entity.level() : null, 4,
entity.getName().getString(), entity.getDisplayName(), entity.level().getServer(), entity), "stopsound @s player target:shotfire3p"); entity.getName().getString(), entity.getDisplayName(), entity.level().getServer(), entity), "stopsound @s player target:shotfire3p");
} }
} }
}
if (Math.random() < 0.5) {
{
double _setval = -1;
entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> { entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
capability.recoilhorizon = _setval; capability.recoilhorizon = Math.random() < 0.5 ? -1 : 1;
capability.recoil = 0.1;
capability.firing = 1;
capability.syncPlayerVariables(entity); capability.syncPlayerVariables(entity);
}); });
}
} else {
{
double _setval = 1;
entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
capability.recoilhorizon = _setval;
capability.syncPlayerVariables(entity);
});
}
}
{
double _setval = 0.1;
entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
capability.recoil = _setval;
capability.syncPlayerVariables(entity);
});
}
if (entity instanceof Player _player) { if (entity instanceof Player _player) {
_player.getCooldowns().addCooldown(_player.getMainHandItem().getItem(), 7); _player.getCooldowns().addCooldown(_player.getMainHandItem().getItem(), 7);
} }
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("arrowempty", 7); (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("arrowempty", 7);
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("power", 0); (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("power", 0);
usehand.getOrCreateTag().putDouble("fireanim", 2); usehand.getOrCreateTag().putDouble("fireanim", 2);
{
double _setval = 1; if (entity instanceof Player player && !player.isCreative()) {
entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
capability.firing = _setval;
capability.syncPlayerVariables(entity);
});
}
if (!(new Object() {
public boolean checkGamemode(Entity _ent) {
if (_ent instanceof ServerPlayer _serverPlayer) {
return _serverPlayer.gameMode.getGameModeForPlayer() == GameType.CREATIVE;
} else if (_ent.level().isClientSide() && _ent instanceof Player _player) {
return Minecraft.getInstance().getConnection().getPlayerInfo(_player.getGameProfile().getId()) != null
&& Minecraft.getInstance().getConnection().getPlayerInfo(_player.getGameProfile().getId()).getGameMode() == GameType.CREATIVE;
}
return false;
}
}.checkGamemode(entity))) {
if (entity instanceof Player _player) {
ItemStack _stktoremove = new ItemStack(Items.ARROW); ItemStack _stktoremove = new ItemStack(Items.ARROW);
_player.getInventory().clearOrCountMatchingItems(p -> _stktoremove.getItem() == p.getItem(), 1, _player.inventoryMenu.getCraftSlots()); player.getInventory().clearOrCountMatchingItems(p -> _stktoremove.getItem() == p.getItem(), 1, player.inventoryMenu.getCraftSlots());
}
} }
} }
} }

View file

@ -2,20 +2,19 @@ package net.mcreator.target.procedures;
import net.mcreator.target.entity.ClaymoreEntity; import net.mcreator.target.entity.ClaymoreEntity;
import net.mcreator.target.init.TargetModEntities; import net.mcreator.target.init.TargetModEntities;
import net.minecraft.client.Minecraft;
import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionHand;
import net.minecraft.world.entity.*; import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.MobSpawnType;
import net.minecraft.world.entity.TamableAnimal;
import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.GameType;
import net.minecraft.world.level.LevelAccessor; import net.minecraft.world.level.LevelAccessor;
public class ClaymoreMineYouJiFangKuaiShiFangKuaiDeWeiZhiProcedure { public class ClaymoreMineYouJiFangKuaiShiFangKuaiDeWeiZhiProcedure {
public static void execute(LevelAccessor world, double x, double y, double z, Entity entity, ItemStack itemstack) { public static void execute(LevelAccessor world, double x, double y, double z, Entity entity, ItemStack itemstack) {
if (entity == null) if (entity == null) return;
return;
if (entity instanceof LivingEntity _entity) if (entity instanceof LivingEntity _entity)
_entity.swing(InteractionHand.MAIN_HAND, true); _entity.swing(InteractionHand.MAIN_HAND, true);
if (world instanceof ServerLevel _level) { if (world instanceof ServerLevel _level) {
@ -30,20 +29,10 @@ public class ClaymoreMineYouJiFangKuaiShiFangKuaiDeWeiZhiProcedure {
} }
_level.addFreshEntity(entityToSpawn); _level.addFreshEntity(entityToSpawn);
} }
if (entity instanceof Player _player) if (entity instanceof Player player) {
_player.getCooldowns().addCooldown(itemstack.getItem(), 20); player.getCooldowns().addCooldown(itemstack.getItem(), 20);
if (!(new Object() { if (!player.isCreative()) {
public boolean checkGamemode(Entity _ent) { player.getInventory().clearOrCountMatchingItems(p -> itemstack.getItem() == p.getItem(), 1, player.inventoryMenu.getCraftSlots());
if (_ent instanceof ServerPlayer _serverPlayer) {
return _serverPlayer.gameMode.getGameModeForPlayer() == GameType.CREATIVE;
} else if (_ent.level().isClientSide() && _ent instanceof Player _player) {
return Minecraft.getInstance().getConnection().getPlayerInfo(_player.getGameProfile().getId()) != null && Minecraft.getInstance().getConnection().getPlayerInfo(_player.getGameProfile().getId()).getGameMode() == GameType.CREATIVE;
}
return false;
}
}.checkGamemode(entity))) {
if (entity instanceof Player _player) {
_player.getInventory().clearOrCountMatchingItems(p -> itemstack.getItem() == p.getItem(), 1, _player.inventoryMenu.getCraftSlots());
} }
} }
} }

View file

@ -1,30 +1,15 @@
package net.mcreator.target.procedures; package net.mcreator.target.procedures;
import net.mcreator.target.init.TargetModItems; import net.mcreator.target.init.TargetModItems;
import net.minecraft.client.Minecraft;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.GameType;
public class DevotiongfireProcedure { public class DevotiongfireProcedure {
public static void execute(Entity entity) { public static void execute(Entity entity) {
if (entity == null) if (entity == null) return;
return; if (entity instanceof Player player && !player.isSpectator()) {
ItemStack usehand; ItemStack usehand = player.getMainHandItem();
if (!(new Object() {
public boolean checkGamemode(Entity _ent) {
if (_ent instanceof ServerPlayer _serverPlayer) {
return _serverPlayer.gameMode.getGameModeForPlayer() == GameType.SPECTATOR;
} else if (_ent.level().isClientSide() && _ent instanceof Player _player) {
return Minecraft.getInstance().getConnection().getPlayerInfo(_player.getGameProfile().getId()) != null && Minecraft.getInstance().getConnection().getPlayerInfo(_player.getGameProfile().getId()).getGameMode() == GameType.SPECTATOR;
}
return false;
}
}.checkGamemode(entity))) {
usehand = (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY);
if (usehand.getItem() == TargetModItems.DEVOTION.get()) { if (usehand.getItem() == TargetModItems.DEVOTION.get()) {
entity.getPersistentData().putDouble("firing", 1); entity.getPersistentData().putDouble("firing", 1);
} }

View file

@ -1,33 +1,18 @@
package net.mcreator.target.procedures; package net.mcreator.target.procedures;
import net.mcreator.target.init.TargetModItems; import net.mcreator.target.init.TargetModItems;
import net.minecraft.client.Minecraft;
import net.minecraft.commands.CommandSource; import net.minecraft.commands.CommandSource;
import net.minecraft.commands.CommandSourceStack; import net.minecraft.commands.CommandSourceStack;
import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.GameType;
public class Hk416fireProcedure { public class Hk416fireProcedure {
public static void execute(Entity entity) { public static void execute(Entity entity) {
if (entity == null) if (entity == null) return;
return; if (entity instanceof Player player && !player.isSpectator()) {
ItemStack usehand = ItemStack.EMPTY; ItemStack usehand = player.getMainHandItem();
if (!(new Object() {
public boolean checkGamemode(Entity _ent) {
if (_ent instanceof ServerPlayer _serverPlayer) {
return _serverPlayer.gameMode.getGameModeForPlayer() == GameType.SPECTATOR;
} else if (_ent.level().isClientSide() && _ent instanceof Player _player) {
return Minecraft.getInstance().getConnection().getPlayerInfo(_player.getGameProfile().getId()) != null && Minecraft.getInstance().getConnection().getPlayerInfo(_player.getGameProfile().getId()).getGameMode() == GameType.SPECTATOR;
}
return false;
}
}.checkGamemode(entity))) {
usehand = (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY);
if (usehand.getItem() == TargetModItems.HK_416.get()) { if (usehand.getItem() == TargetModItems.HK_416.get()) {
if (usehand.getOrCreateTag().getDouble("firemode") == 0) { if (usehand.getOrCreateTag().getDouble("firemode") == 0) {
if (usehand.getOrCreateTag().getDouble("reloading") == 0 && usehand.getOrCreateTag().getDouble("ammo") > 0 && !(entity instanceof Player _plrCldCheck6 && _plrCldCheck6.getCooldowns().isOnCooldown(usehand.getItem()))) { if (usehand.getOrCreateTag().getDouble("reloading") == 0 && usehand.getOrCreateTag().getDouble("ammo") > 0 && !(entity instanceof Player _plrCldCheck6 && _plrCldCheck6.getCooldowns().isOnCooldown(usehand.getItem()))) {
@ -35,24 +20,15 @@ public class Hk416fireProcedure {
_player.getCooldowns().addCooldown(usehand.getItem(), 2); _player.getCooldowns().addCooldown(usehand.getItem(), 2);
BulletFireNormalProcedure.execute(entity); BulletFireNormalProcedure.execute(entity);
HkDsProcedure.execute(entity); HkDsProcedure.execute(entity);
{
if (!entity.level().isClientSide() && entity.getServer() != null) { if (!entity.level().isClientSide() && entity.getServer() != null) {
entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), entity.level() instanceof ServerLevel ? (ServerLevel) entity.level() : null, 4, entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), entity.level() instanceof ServerLevel ? (ServerLevel) entity.level() : null, 4,
entity.getName().getString(), entity.getDisplayName(), entity.level().getServer(), entity), "playsound target:hk416_fire1p player @s ~ ~ ~ 2 1"); entity.getName().getString(), entity.getDisplayName(), entity.level().getServer(), entity), "playsound target:hk416_fire1p player @s ~ ~ ~ 2 1");
}
}
{
if (!entity.level().isClientSide() && entity.getServer() != null) {
entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), entity.level() instanceof ServerLevel ? (ServerLevel) entity.level() : null, 4, entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), entity.level() instanceof ServerLevel ? (ServerLevel) entity.level() : null, 4,
entity.getName().getString(), entity.getDisplayName(), entity.level().getServer(), entity), "playsound target:hk416fire player @a ~ ~ ~ 4 1"); entity.getName().getString(), entity.getDisplayName(), entity.level().getServer(), entity), "playsound target:hk416fire player @a ~ ~ ~ 4 1");
}
}
{
if (!entity.level().isClientSide() && entity.getServer() != null) {
entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), entity.level() instanceof ServerLevel ? (ServerLevel) entity.level() : null, 4, entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), entity.level() instanceof ServerLevel ? (ServerLevel) entity.level() : null, 4,
entity.getName().getString(), entity.getDisplayName(), entity.level().getServer(), entity), "stopsound @s player target:hk416fire"); entity.getName().getString(), entity.getDisplayName(), entity.level().getServer(), entity), "stopsound @s player target:hk416fire");
} }
}
usehand.getOrCreateTag().putDouble("fireanim", 2); usehand.getOrCreateTag().putDouble("fireanim", 2);
usehand.getOrCreateTag().putDouble("ammo", (usehand.getOrCreateTag().getDouble("ammo") - 1)); usehand.getOrCreateTag().putDouble("ammo", (usehand.getOrCreateTag().getDouble("ammo") - 1));
} }

View file

@ -1,44 +1,27 @@
package net.mcreator.target.procedures; package net.mcreator.target.procedures;
import net.mcreator.target.init.TargetModItems; import net.mcreator.target.init.TargetModItems;
import net.minecraft.client.Minecraft;
import net.minecraft.commands.CommandSource; import net.minecraft.commands.CommandSource;
import net.minecraft.commands.CommandSourceStack; import net.minecraft.commands.CommandSourceStack;
import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.GameType;
public class HrfireProcedure { public class HrfireProcedure {
public static void execute(Entity entity) { public static void execute(Entity entity) {
if (entity == null) if (entity == null) return;
return; if (entity instanceof Player player && !player.isSpectator()) {
ItemStack usehand = ItemStack.EMPTY; ItemStack usehand = player.getMainHandItem();
if (!(new Object() {
public boolean checkGamemode(Entity _ent) {
if (_ent instanceof ServerPlayer _serverPlayer) {
return _serverPlayer.gameMode.getGameModeForPlayer() == GameType.SPECTATOR;
} else if (_ent.level().isClientSide() && _ent instanceof Player _player) {
return Minecraft.getInstance().getConnection().getPlayerInfo(_player.getGameProfile().getId()) != null && Minecraft.getInstance().getConnection().getPlayerInfo(_player.getGameProfile().getId()).getGameMode() == GameType.SPECTATOR;
}
return false;
}
}.checkGamemode(entity))) {
usehand = (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY);
if (usehand.getItem() == TargetModItems.HUNTING_RIFLE.get() && usehand.getOrCreateTag().getDouble("reloading") == 0 && !(entity instanceof Player _plrCldCheck4 && _plrCldCheck4.getCooldowns().isOnCooldown(usehand.getItem())) if (usehand.getItem() == TargetModItems.HUNTING_RIFLE.get() && usehand.getOrCreateTag().getDouble("reloading") == 0 && !(entity instanceof Player _plrCldCheck4 && _plrCldCheck4.getCooldowns().isOnCooldown(usehand.getItem()))
&& usehand.getOrCreateTag().getDouble("ammo") > 0) { && usehand.getOrCreateTag().getDouble("ammo") > 0) {
BulletFireNormalProcedure.execute(entity); BulletFireNormalProcedure.execute(entity);
if (entity instanceof Player _player) player.getCooldowns().addCooldown(usehand.getItem(), 13);
_player.getCooldowns().addCooldown(usehand.getItem(), 13);
{
if (!entity.level().isClientSide() && entity.getServer() != null) { if (!entity.level().isClientSide() && entity.getServer() != null) {
entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), entity.level() instanceof ServerLevel ? (ServerLevel) entity.level() : null, 4, entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), entity.level() instanceof ServerLevel ? (ServerLevel) entity.level() : null, 4,
entity.getName().getString(), entity.getDisplayName(), entity.level().getServer(), entity), "playsound target:hr_fire_1p player @a ~ ~ ~ 4 1"); entity.getName().getString(), entity.getDisplayName(), entity.level().getServer(), entity), "playsound target:hr_fire_1p player @a ~ ~ ~ 4 1");
} }
}
usehand.getOrCreateTag().putDouble("fireanim", 2); usehand.getOrCreateTag().putDouble("fireanim", 2);
usehand.getOrCreateTag().putDouble("ammo", (usehand.getOrCreateTag().getDouble("ammo") - 1)); usehand.getOrCreateTag().putDouble("ammo", (usehand.getOrCreateTag().getDouble("ammo") - 1));
} }

View file

@ -1,15 +1,12 @@
package net.mcreator.target.procedures; package net.mcreator.target.procedures;
import net.minecraft.client.Minecraft;
import net.minecraft.core.registries.Registries; import net.minecraft.core.registries.Registries;
import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.damagesource.DamageTypes; import net.minecraft.world.damagesource.DamageTypes;
import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.GameType;
import net.minecraftforge.event.entity.living.LivingAttackEvent; import net.minecraftforge.event.entity.living.LivingAttackEvent;
import net.minecraftforge.eventbus.api.Event; import net.minecraftforge.eventbus.api.Event;
import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.eventbus.api.SubscribeEvent;
@ -33,16 +30,7 @@ public class HurtcancelProcedure {
private static void execute(@Nullable Event event, DamageSource damagesource, Entity sourceentity) { private static void execute(@Nullable Event event, DamageSource damagesource, Entity sourceentity) {
if (damagesource == null || sourceentity == null) if (damagesource == null || sourceentity == null)
return; return;
if (sourceentity instanceof Player && (!sourceentity.isAlive() || new Object() { if (sourceentity instanceof Player player && (!sourceentity.isAlive() || player.isSpectator()) && (damagesource.is(ResourceKey.create(Registries.DAMAGE_TYPE, new ResourceLocation("target:arrow_in_brain"))) || damagesource.is(ResourceKey.create(Registries.DAMAGE_TYPE, new ResourceLocation("target:mine"))) || damagesource.is(DamageTypes.ARROW))) {
public boolean checkGamemode(Entity _ent) {
if (_ent instanceof ServerPlayer _serverPlayer) {
return _serverPlayer.gameMode.getGameModeForPlayer() == GameType.SPECTATOR;
} else if (_ent.level().isClientSide() && _ent instanceof Player _player) {
return Minecraft.getInstance().getConnection().getPlayerInfo(_player.getGameProfile().getId()) != null && Minecraft.getInstance().getConnection().getPlayerInfo(_player.getGameProfile().getId()).getGameMode() == GameType.SPECTATOR;
}
return false;
}
}.checkGamemode(sourceentity)) && (damagesource.is(ResourceKey.create(Registries.DAMAGE_TYPE, new ResourceLocation("target:arrow_in_brain"))) || damagesource.is(ResourceKey.create(Registries.DAMAGE_TYPE, new ResourceLocation("target:mine"))) || damagesource.is(DamageTypes.ARROW))) {
if (event != null && event.isCancelable()) { if (event != null && event.isCancelable()) {
event.setCanceled(true); event.setCanceled(true);
} }

View file

@ -1,33 +1,18 @@
package net.mcreator.target.procedures; package net.mcreator.target.procedures;
import net.mcreator.target.init.TargetModItems; import net.mcreator.target.init.TargetModItems;
import net.minecraft.client.Minecraft;
import net.minecraft.commands.CommandSource; import net.minecraft.commands.CommandSource;
import net.minecraft.commands.CommandSourceStack; import net.minecraft.commands.CommandSourceStack;
import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.GameType;
public class KraberfireProcedure { public class KraberfireProcedure {
public static void execute(Entity entity) { public static void execute(Entity entity) {
if (entity == null) if (entity == null) return;
return; if (entity instanceof Player player && !player.isSpectator()) {
ItemStack usehand = ItemStack.EMPTY; ItemStack usehand = player.getMainHandItem();
if (!(new Object() {
public boolean checkGamemode(Entity _ent) {
if (_ent instanceof ServerPlayer _serverPlayer) {
return _serverPlayer.gameMode.getGameModeForPlayer() == GameType.SPECTATOR;
} else if (_ent.level().isClientSide() && _ent instanceof Player _player) {
return Minecraft.getInstance().getConnection().getPlayerInfo(_player.getGameProfile().getId()) != null && Minecraft.getInstance().getConnection().getPlayerInfo(_player.getGameProfile().getId()).getGameMode() == GameType.SPECTATOR;
}
return false;
}
}.checkGamemode(entity))) {
usehand = (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY);
if (usehand.getItem() == TargetModItems.KRABER.get() && usehand.getOrCreateTag().getDouble("reloading") == 0 && !(entity instanceof Player _plrCldCheck4 && _plrCldCheck4.getCooldowns().isOnCooldown(usehand.getItem())) if (usehand.getItem() == TargetModItems.KRABER.get() && usehand.getOrCreateTag().getDouble("reloading") == 0 && !(entity instanceof Player _plrCldCheck4 && _plrCldCheck4.getCooldowns().isOnCooldown(usehand.getItem()))
&& usehand.getOrCreateTag().getDouble("ammo") > 0) { && usehand.getOrCreateTag().getDouble("ammo") > 0) {
usehand.getOrCreateTag().putDouble("fireanim", 40); usehand.getOrCreateTag().putDouble("fireanim", 40);
@ -35,24 +20,15 @@ public class KraberfireProcedure {
KraberDsProcedure.execute(entity); KraberDsProcedure.execute(entity);
if (entity instanceof Player _player) if (entity instanceof Player _player)
_player.getCooldowns().addCooldown(usehand.getItem(), 40); _player.getCooldowns().addCooldown(usehand.getItem(), 40);
{
if (!entity.level().isClientSide() && entity.getServer() != null) { if (!entity.level().isClientSide() && entity.getServer() != null) {
entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), entity.level() instanceof ServerLevel ? (ServerLevel) entity.level() : null, 4, entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), entity.level() instanceof ServerLevel ? (ServerLevel) entity.level() : null, 4,
entity.getName().getString(), entity.getDisplayName(), entity.level().getServer(), entity), "playsound target:kraber_fire_1p player @s ~ ~ ~ 2 1"); entity.getName().getString(), entity.getDisplayName(), entity.level().getServer(), entity), "playsound target:kraber_fire_1p player @s ~ ~ ~ 2 1");
}
}
{
if (!entity.level().isClientSide() && entity.getServer() != null) {
entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), entity.level() instanceof ServerLevel ? (ServerLevel) entity.level() : null, 4, entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), entity.level() instanceof ServerLevel ? (ServerLevel) entity.level() : null, 4,
entity.getName().getString(), entity.getDisplayName(), entity.level().getServer(), entity), "playsound target:kraber_fire_3p player @a ~ ~ ~ 6 1"); entity.getName().getString(), entity.getDisplayName(), entity.level().getServer(), entity), "playsound target:kraber_fire_3p player @a ~ ~ ~ 6 1");
}
}
{
if (!entity.level().isClientSide() && entity.getServer() != null) {
entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), entity.level() instanceof ServerLevel ? (ServerLevel) entity.level() : null, 4, entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), entity.level() instanceof ServerLevel ? (ServerLevel) entity.level() : null, 4,
entity.getName().getString(), entity.getDisplayName(), entity.level().getServer(), entity), "stopsound @s player target:kraber_fire_3p"); entity.getName().getString(), entity.getDisplayName(), entity.level().getServer(), entity), "stopsound @s player target:kraber_fire_3p");
} }
}
usehand.getOrCreateTag().putDouble("ammo", (usehand.getOrCreateTag().getDouble("ammo") - 1)); usehand.getOrCreateTag().putDouble("ammo", (usehand.getOrCreateTag().getDouble("ammo") - 1));
} }
} }

View file

@ -1,34 +1,19 @@
package net.mcreator.target.procedures; package net.mcreator.target.procedures;
import net.mcreator.target.init.TargetModItems; import net.mcreator.target.init.TargetModItems;
import net.minecraft.client.Minecraft;
import net.minecraft.commands.CommandSource; import net.minecraft.commands.CommandSource;
import net.minecraft.commands.CommandSourceStack; import net.minecraft.commands.CommandSourceStack;
import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.GameType;
public class M4fireProcedure { public class M4fireProcedure {
public static void execute(Entity entity) { public static void execute(Entity entity) {
if (entity == null) if (entity == null) return;
return;
ItemStack usehand;
ItemStack weaponzoom = ItemStack.EMPTY; ItemStack weaponzoom = ItemStack.EMPTY;
if (!(new Object() { if (entity instanceof Player player && !player.isSpectator()) {
public boolean checkGamemode(Entity _ent) { ItemStack usehand = player.getMainHandItem();
if (_ent instanceof ServerPlayer _serverPlayer) {
return _serverPlayer.gameMode.getGameModeForPlayer() == GameType.SPECTATOR;
} else if (_ent.level().isClientSide() && _ent instanceof Player _player) {
return Minecraft.getInstance().getConnection().getPlayerInfo(_player.getGameProfile().getId()) != null && Minecraft.getInstance().getConnection().getPlayerInfo(_player.getGameProfile().getId()).getGameMode() == GameType.SPECTATOR;
}
return false;
}
}.checkGamemode(entity))) {
usehand = (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY);
if (usehand.getItem() == TargetModItems.M_4.get()) { if (usehand.getItem() == TargetModItems.M_4.get()) {
if (usehand.getOrCreateTag().getDouble("firemode") == 0) { if (usehand.getOrCreateTag().getDouble("firemode") == 0) {
if (usehand.getOrCreateTag().getDouble("reloading") == 0 && usehand.getOrCreateTag().getDouble("ammo") > 0 && !(entity instanceof Player _plrCldCheck6 && _plrCldCheck6.getCooldowns().isOnCooldown(usehand.getItem()))) { if (usehand.getOrCreateTag().getDouble("reloading") == 0 && usehand.getOrCreateTag().getDouble("ammo") > 0 && !(entity instanceof Player _plrCldCheck6 && _plrCldCheck6.getCooldowns().isOnCooldown(usehand.getItem()))) {
@ -36,24 +21,15 @@ public class M4fireProcedure {
_player.getCooldowns().addCooldown(usehand.getItem(), 2); _player.getCooldowns().addCooldown(usehand.getItem(), 2);
BulletFireNormalProcedure.execute(entity); BulletFireNormalProcedure.execute(entity);
ArDsProcedure.execute(entity); ArDsProcedure.execute(entity);
{
if (!entity.level().isClientSide() && entity.getServer() != null) { if (!entity.level().isClientSide() && entity.getServer() != null) {
entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), entity.level() instanceof ServerLevel ? (ServerLevel) entity.level() : null, 4, entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), entity.level() instanceof ServerLevel ? (ServerLevel) entity.level() : null, 4,
entity.getName().getString(), entity.getDisplayName(), entity.level().getServer(), entity), "playsound target:m4fire player @s ~ ~ ~ 2 1"); entity.getName().getString(), entity.getDisplayName(), entity.level().getServer(), entity), "playsound target:m4fire player @s ~ ~ ~ 2 1");
}
}
{
if (!entity.level().isClientSide() && entity.getServer() != null) {
entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), entity.level() instanceof ServerLevel ? (ServerLevel) entity.level() : null, 4, entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), entity.level() instanceof ServerLevel ? (ServerLevel) entity.level() : null, 4,
entity.getName().getString(), entity.getDisplayName(), entity.level().getServer(), entity), "playsound target:m4fire_3p player @a ~ ~ ~ 4 1"); entity.getName().getString(), entity.getDisplayName(), entity.level().getServer(), entity), "playsound target:m4fire_3p player @a ~ ~ ~ 4 1");
}
}
{
if (!entity.level().isClientSide() && entity.getServer() != null) {
entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), entity.level() instanceof ServerLevel ? (ServerLevel) entity.level() : null, 4, entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), entity.level() instanceof ServerLevel ? (ServerLevel) entity.level() : null, 4,
entity.getName().getString(), entity.getDisplayName(), entity.level().getServer(), entity), "stopsound @s player target:m4fire_3p"); entity.getName().getString(), entity.getDisplayName(), entity.level().getServer(), entity), "stopsound @s player target:m4fire_3p");
} }
}
usehand.getOrCreateTag().putDouble("fireanim", 2); usehand.getOrCreateTag().putDouble("fireanim", 2);
usehand.getOrCreateTag().putDouble("ammo", (usehand.getOrCreateTag().getDouble("ammo") - 1)); usehand.getOrCreateTag().putDouble("ammo", (usehand.getOrCreateTag().getDouble("ammo") - 1));
} }

View file

@ -1,31 +1,15 @@
package net.mcreator.target.procedures; package net.mcreator.target.procedures;
import net.minecraft.world.level.GameType;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.Entity;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.client.Minecraft;
import net.mcreator.target.init.TargetModItems; import net.mcreator.target.init.TargetModItems;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
public class M60fireProcedure { public class M60fireProcedure {
public static void execute(Entity entity) { public static void execute(Entity entity) {
if (entity == null) if (entity == null) return;
return; if (entity instanceof Player player && !player.isSpectator()) {
ItemStack usehand; ItemStack usehand = player.getMainHandItem();
if (!(new Object() {
public boolean checkGamemode(Entity _ent) {
if (_ent instanceof ServerPlayer _serverPlayer) {
return _serverPlayer.gameMode.getGameModeForPlayer() == GameType.SPECTATOR;
} else if (_ent.level().isClientSide() && _ent instanceof Player _player) {
return Minecraft.getInstance().getConnection().getPlayerInfo(_player.getGameProfile().getId()) != null && Minecraft.getInstance().getConnection().getPlayerInfo(_player.getGameProfile().getId()).getGameMode() == GameType.SPECTATOR;
}
return false;
}
}.checkGamemode(entity))) {
usehand = (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY);
if (usehand.getItem() == TargetModItems.M_60.get()) { if (usehand.getItem() == TargetModItems.M_60.get()) {
entity.getPersistentData().putDouble("firing", 1); entity.getPersistentData().putDouble("firing", 1);
} }

View file

@ -1,77 +1,36 @@
package net.mcreator.target.procedures; package net.mcreator.target.procedures;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.GameType;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.entity.projectile.Projectile;
import net.minecraft.world.entity.projectile.AbstractArrow;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.Entity;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.CommandSource;
import net.minecraft.client.Minecraft;
import net.mcreator.target.network.TargetModVariables;
import net.mcreator.target.init.TargetModItems;
import net.mcreator.target.init.TargetModEntities;
import net.mcreator.target.init.TargetModAttributes;
import net.mcreator.target.entity.GunGrenadeEntity; import net.mcreator.target.entity.GunGrenadeEntity;
import net.mcreator.target.init.TargetModAttributes;
import net.mcreator.target.init.TargetModEntities;
import net.mcreator.target.init.TargetModItems;
import net.mcreator.target.network.TargetModVariables;
import net.minecraft.commands.CommandSource;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.entity.projectile.AbstractArrow;
import net.minecraft.world.entity.projectile.Projectile;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
public class M79fireProcedure { public class M79fireProcedure {
public static void execute(Entity entity) { public static void execute(Entity entity) {
if (entity == null) if (entity == null) return;
return; if (entity instanceof Player player && !player.isSpectator()) {
ItemStack usehand = ItemStack.EMPTY; ItemStack usehand = player.getMainHandItem();
if (!(new Object() {
public boolean checkGamemode(Entity _ent) {
if (_ent instanceof ServerPlayer _serverPlayer) {
return _serverPlayer.gameMode.getGameModeForPlayer() == GameType.SPECTATOR;
} else if (_ent.level().isClientSide() && _ent instanceof Player _player) {
return Minecraft.getInstance().getConnection().getPlayerInfo(_player.getGameProfile().getId()) != null && Minecraft.getInstance().getConnection().getPlayerInfo(_player.getGameProfile().getId()).getGameMode() == GameType.SPECTATOR;
}
return false;
}
}.checkGamemode(entity))) {
usehand = (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY);
if (usehand.getItem() == TargetModItems.M_79.get() && usehand.getOrCreateTag().getDouble("reloading") == 0 && !(entity instanceof Player _plrCldCheck4 && _plrCldCheck4.getCooldowns().isOnCooldown(usehand.getItem())) if (usehand.getItem() == TargetModItems.M_79.get() && usehand.getOrCreateTag().getDouble("reloading") == 0 && !(entity instanceof Player _plrCldCheck4 && _plrCldCheck4.getCooldowns().isOnCooldown(usehand.getItem()))
&& usehand.getOrCreateTag().getDouble("ammo") > 0) { && usehand.getOrCreateTag().getDouble("ammo") > 0) {
if (Math.random() < 0.5) {
{
double _setval = -1;
entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> { entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
capability.recoilhorizon = _setval; capability.recoilhorizon = Math.random() < 0.5 ? -1 : 1;
capability.recoil = 0.1;
capability.firing = 1;
capability.syncPlayerVariables(entity); capability.syncPlayerVariables(entity);
}); });
}
} else { Level projectileLevel = entity.level();
{
double _setval = 1;
entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
capability.recoilhorizon = _setval;
capability.syncPlayerVariables(entity);
});
}
}
{
double _setval = 0.1;
entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
capability.recoil = _setval;
capability.syncPlayerVariables(entity);
});
}
{
double _setval = 1;
entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
capability.firing = _setval;
capability.syncPlayerVariables(entity);
});
}
{
Entity _shootFrom = entity;
Level projectileLevel = _shootFrom.level();
if (!projectileLevel.isClientSide()) { if (!projectileLevel.isClientSide()) {
Projectile _entityToSpawn = new Object() { Projectile _entityToSpawn = new Object() {
public Projectile getArrow(Level level, Entity shooter, float damage, int knockback) { public Projectile getArrow(Level level, Entity shooter, float damage, int knockback) {
@ -83,13 +42,12 @@ public class M79fireProcedure {
return entityToSpawn; return entityToSpawn;
} }
}.getArrow(projectileLevel, entity, (float) ((usehand.getOrCreateTag().getDouble("damage") / usehand.getOrCreateTag().getDouble("velocity")) * (1 + 0.05 * usehand.getOrCreateTag().getDouble("level"))), 0); }.getArrow(projectileLevel, entity, (float) ((usehand.getOrCreateTag().getDouble("damage") / usehand.getOrCreateTag().getDouble("velocity")) * (1 + 0.05 * usehand.getOrCreateTag().getDouble("level"))), 0);
_entityToSpawn.setPos(_shootFrom.getX(), _shootFrom.getEyeY() - 0.1, _shootFrom.getZ()); _entityToSpawn.setPos(entity.getX(), entity.getEyeY() - 0.1, entity.getZ());
_entityToSpawn.shoot(_shootFrom.getLookAngle().x, _shootFrom.getLookAngle().y, _shootFrom.getLookAngle().z, (float) usehand.getOrCreateTag().getDouble("velocity"), _entityToSpawn.shoot(entity.getLookAngle().x, entity.getLookAngle().y, entity.getLookAngle().z, (float) usehand.getOrCreateTag().getDouble("velocity"),
(float) ((LivingEntity) entity).getAttribute(TargetModAttributes.SPREAD.get()).getBaseValue()); (float) ((LivingEntity) entity).getAttribute(TargetModAttributes.SPREAD.get()).getBaseValue());
projectileLevel.addFreshEntity(_entityToSpawn); projectileLevel.addFreshEntity(_entityToSpawn);
} }
}
{
if (!entity.level().isClientSide() && entity.getServer() != null) { if (!entity.level().isClientSide() && entity.getServer() != null) {
entity.getServer().getCommands().performPrefixedCommand( entity.getServer().getCommands().performPrefixedCommand(
new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), entity.level() instanceof ServerLevel ? (ServerLevel) entity.level() : null, 4, entity.getName().getString(), entity.getDisplayName(), new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), entity.level() instanceof ServerLevel ? (ServerLevel) entity.level() : null, 4, entity.getName().getString(), entity.getDisplayName(),
@ -97,15 +55,12 @@ public class M79fireProcedure {
("particle minecraft:cloud" + (" " + (entity.getX() + 1.8 * entity.getLookAngle().x)) + (" " + (entity.getY() + entity.getBbHeight() - 0.1 + 1.8 * entity.getLookAngle().y)) ("particle minecraft:cloud" + (" " + (entity.getX() + 1.8 * entity.getLookAngle().x)) + (" " + (entity.getY() + entity.getBbHeight() - 0.1 + 1.8 * entity.getLookAngle().y))
+ (" " + (entity.getZ() + 1.8 * entity.getLookAngle().z)) + " 0.1 0.1 0.1 0.002 4 force @s")); + (" " + (entity.getZ() + 1.8 * entity.getLookAngle().z)) + " 0.1 0.1 0.1 0.002 4 force @s"));
} }
} player.getCooldowns().addCooldown(usehand.getItem(), 15);
if (entity instanceof Player _player)
_player.getCooldowns().addCooldown(usehand.getItem(), 15);
{
if (!entity.level().isClientSide() && entity.getServer() != null) { if (!entity.level().isClientSide() && entity.getServer() != null) {
entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), entity.level() instanceof ServerLevel ? (ServerLevel) entity.level() : null, 4, entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), entity.level() instanceof ServerLevel ? (ServerLevel) entity.level() : null, 4,
entity.getName().getString(), entity.getDisplayName(), entity.level().getServer(), entity), "playsound target:m79_fire_1p player @a ~ ~ ~ 4 1"); entity.getName().getString(), entity.getDisplayName(), entity.level().getServer(), entity), "playsound target:m79_fire_1p player @a ~ ~ ~ 4 1");
} }
}
usehand.getOrCreateTag().putDouble("fireanim", 2); usehand.getOrCreateTag().putDouble("fireanim", 2);
usehand.getOrCreateTag().putDouble("ammo", (usehand.getOrCreateTag().getDouble("ammo") - 1)); usehand.getOrCreateTag().putDouble("ammo", (usehand.getOrCreateTag().getDouble("ammo") - 1));
} }

View file

@ -1,33 +1,18 @@
package net.mcreator.target.procedures; package net.mcreator.target.procedures;
import net.mcreator.target.init.TargetModItems; import net.mcreator.target.init.TargetModItems;
import net.minecraft.client.Minecraft;
import net.minecraft.commands.CommandSource; import net.minecraft.commands.CommandSource;
import net.minecraft.commands.CommandSourceStack; import net.minecraft.commands.CommandSourceStack;
import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.GameType;
public class M870fireProcedure { public class M870fireProcedure {
public static void execute(Entity entity) { public static void execute(Entity entity) {
if (entity == null) if (entity == null) return;
return; if (entity instanceof Player player && !player.isSpectator()) {
ItemStack usehand = ItemStack.EMPTY; ItemStack usehand = player.getMainHandItem();
if (!(new Object() {
public boolean checkGamemode(Entity _ent) {
if (_ent instanceof ServerPlayer _serverPlayer) {
return _serverPlayer.gameMode.getGameModeForPlayer() == GameType.SPECTATOR;
} else if (_ent.level().isClientSide() && _ent instanceof Player _player) {
return Minecraft.getInstance().getConnection().getPlayerInfo(_player.getGameProfile().getId()) != null && Minecraft.getInstance().getConnection().getPlayerInfo(_player.getGameProfile().getId()).getGameMode() == GameType.SPECTATOR;
}
return false;
}
}.checkGamemode(entity))) {
usehand = (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY);
if (usehand.getOrCreateTag().getDouble("reloading") == 1 && usehand.getOrCreateTag().getDouble("prepare") == 0 && usehand.getOrCreateTag().getDouble("ammo") > 0) { if (usehand.getOrCreateTag().getDouble("reloading") == 1 && usehand.getOrCreateTag().getDouble("prepare") == 0 && usehand.getOrCreateTag().getDouble("ammo") > 0) {
usehand.getOrCreateTag().putDouble("forcestop", 1); usehand.getOrCreateTag().putDouble("forcestop", 1);
} }
@ -40,24 +25,15 @@ public class M870fireProcedure {
_player.getCooldowns().addCooldown(usehand.getItem(), 13); _player.getCooldowns().addCooldown(usehand.getItem(), 13);
usehand.getOrCreateTag().putDouble("recoil", 1); usehand.getOrCreateTag().putDouble("recoil", 1);
usehand.getOrCreateTag().putDouble("firing", 13); usehand.getOrCreateTag().putDouble("firing", 13);
{
if (!entity.level().isClientSide() && entity.getServer() != null) { if (!entity.level().isClientSide() && entity.getServer() != null) {
entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), entity.level() instanceof ServerLevel ? (ServerLevel) entity.level() : null, 4, entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), entity.level() instanceof ServerLevel ? (ServerLevel) entity.level() : null, 4,
entity.getName().getString(), entity.getDisplayName(), entity.level().getServer(), entity), "playsound target:m870_fire1p player @s ~ ~ ~ 100 1"); entity.getName().getString(), entity.getDisplayName(), entity.level().getServer(), entity), "playsound target:m870_fire1p player @s ~ ~ ~ 100 1");
}
}
{
if (!entity.level().isClientSide() && entity.getServer() != null) {
entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), entity.level() instanceof ServerLevel ? (ServerLevel) entity.level() : null, 4, entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), entity.level() instanceof ServerLevel ? (ServerLevel) entity.level() : null, 4,
entity.getName().getString(), entity.getDisplayName(), entity.level().getServer(), entity), "playsound target:m870_fire3p player @a ~ ~ ~ 4 1"); entity.getName().getString(), entity.getDisplayName(), entity.level().getServer(), entity), "playsound target:m870_fire3p player @a ~ ~ ~ 4 1");
}
}
{
if (!entity.level().isClientSide() && entity.getServer() != null) {
entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), entity.level() instanceof ServerLevel ? (ServerLevel) entity.level() : null, 4, entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), entity.level() instanceof ServerLevel ? (ServerLevel) entity.level() : null, 4,
entity.getName().getString(), entity.getDisplayName(), entity.level().getServer(), entity), "stopsound @s player target:m870_fire3p"); entity.getName().getString(), entity.getDisplayName(), entity.level().getServer(), entity), "stopsound @s player target:m870_fire3p");
} }
}
usehand.getOrCreateTag().putDouble("ammo", (usehand.getOrCreateTag().getDouble("ammo") - 1)); usehand.getOrCreateTag().putDouble("ammo", (usehand.getOrCreateTag().getDouble("ammo") - 1));
usehand.getOrCreateTag().putDouble("fireanim", 2); usehand.getOrCreateTag().putDouble("fireanim", 2);
} }

View file

@ -1,69 +1,36 @@
package net.mcreator.target.procedures; package net.mcreator.target.procedures;
import net.mcreator.target.init.TargetModItems; import net.mcreator.target.init.TargetModItems;
import net.minecraft.client.Minecraft;
import net.minecraft.commands.CommandSource; import net.minecraft.commands.CommandSource;
import net.minecraft.commands.CommandSourceStack; import net.minecraft.commands.CommandSourceStack;
import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.GameType;
public class M98bfireProcedure { public class M98bfireProcedure {
public static void execute(Entity entity) { public static void execute(Entity entity) {
if (entity == null) if (entity == null) return;
return; if (entity instanceof Player player && !player.isSpectator()) {
ItemStack usehand; ItemStack usehand = player.getMainHandItem();
if (!(new Object() {
public boolean checkGamemode(Entity _ent) {
if (_ent instanceof ServerPlayer _serverPlayer) {
return _serverPlayer.gameMode.getGameModeForPlayer() == GameType.SPECTATOR;
} else if (_ent.level().isClientSide() && _ent instanceof Player _player) {
return Minecraft.getInstance().getConnection().getPlayerInfo(_player.getGameProfile().getId()) != null && Minecraft.getInstance().getConnection().getPlayerInfo(_player.getGameProfile().getId()).getGameMode() == GameType.SPECTATOR;
}
return false;
}
}.checkGamemode(entity))) {
usehand = (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY);
if (usehand.getItem() == TargetModItems.M_98B.get() && usehand.getOrCreateTag().getDouble("reloading") == 0 && !(entity instanceof Player _plrCldCheck4 && _plrCldCheck4.getCooldowns().isOnCooldown(usehand.getItem())) if (usehand.getItem() == TargetModItems.M_98B.get() && usehand.getOrCreateTag().getDouble("reloading") == 0 && !(entity instanceof Player _plrCldCheck4 && _plrCldCheck4.getCooldowns().isOnCooldown(usehand.getItem()))
&& usehand.getOrCreateTag().getDouble("ammo") > 0) { && usehand.getOrCreateTag().getDouble("ammo") > 0) {
usehand.getOrCreateTag().putDouble("fireanim", 17); usehand.getOrCreateTag().putDouble("fireanim", 17);
BulletFireNormalProcedure.execute(entity); BulletFireNormalProcedure.execute(entity);
if (entity instanceof Player _player) player.getCooldowns().addCooldown(usehand.getItem(), 17);
_player.getCooldowns().addCooldown(usehand.getItem(), 17);
{
if (!entity.level().isClientSide() && entity.getServer() != null) { if (!entity.level().isClientSide() && entity.getServer() != null) {
entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), entity.level() instanceof ServerLevel ? (ServerLevel) entity.level() : null, 4, entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), entity.level() instanceof ServerLevel ? (ServerLevel) entity.level() : null, 4,
entity.getName().getString(), entity.getDisplayName(), entity.level().getServer(), entity), "playsound target:m98b_fire_1p player @s ~ ~ ~ 100 1"); entity.getName().getString(), entity.getDisplayName(), entity.level().getServer(), entity), "playsound target:m98b_fire_1p player @s ~ ~ ~ 100 1");
}
}
{
if (!entity.level().isClientSide() && entity.getServer() != null) {
entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), entity.level() instanceof ServerLevel ? (ServerLevel) entity.level() : null, 4, entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), entity.level() instanceof ServerLevel ? (ServerLevel) entity.level() : null, 4,
entity.getName().getString(), entity.getDisplayName(), entity.level().getServer(), entity), "playsound target:m98b_fire_3p player @a ~ ~ ~ 4 1"); entity.getName().getString(), entity.getDisplayName(), entity.level().getServer(), entity), "playsound target:m98b_fire_3p player @a ~ ~ ~ 4 1");
}
}
{
if (!entity.level().isClientSide() && entity.getServer() != null) {
entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), entity.level() instanceof ServerLevel ? (ServerLevel) entity.level() : null, 4, entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), entity.level() instanceof ServerLevel ? (ServerLevel) entity.level() : null, 4,
entity.getName().getString(), entity.getDisplayName(), entity.level().getServer(), entity), "playsound target:shift @a ~ ~ ~ 1 1"); entity.getName().getString(), entity.getDisplayName(), entity.level().getServer(), entity), "playsound target:shift @a ~ ~ ~ 1 1");
}
}
{
if (!entity.level().isClientSide() && entity.getServer() != null) {
entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), entity.level() instanceof ServerLevel ? (ServerLevel) entity.level() : null, 4, entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), entity.level() instanceof ServerLevel ? (ServerLevel) entity.level() : null, 4,
entity.getName().getString(), entity.getDisplayName(), entity.level().getServer(), entity), "stopsound @s player target:m98b_fire_3p"); entity.getName().getString(), entity.getDisplayName(), entity.level().getServer(), entity), "stopsound @s player target:m98b_fire_3p");
}
}
{
if (!entity.level().isClientSide() && entity.getServer() != null) {
entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), entity.level() instanceof ServerLevel ? (ServerLevel) entity.level() : null, 4, entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), entity.level() instanceof ServerLevel ? (ServerLevel) entity.level() : null, 4,
entity.getName().getString(), entity.getDisplayName(), entity.level().getServer(), entity), "stopsound @s player target:shift"); entity.getName().getString(), entity.getDisplayName(), entity.level().getServer(), entity), "stopsound @s player target:shift");
} }
}
usehand.getOrCreateTag().putDouble("ammo", (usehand.getOrCreateTag().getDouble("ammo") - 1)); usehand.getOrCreateTag().putDouble("ammo", (usehand.getOrCreateTag().getDouble("ammo") - 1));
} }
} }

View file

@ -2,35 +2,18 @@ package net.mcreator.target.procedures;
import net.mcreator.target.init.TargetModItems; import net.mcreator.target.init.TargetModItems;
import net.mcreator.target.network.TargetModVariables; import net.mcreator.target.network.TargetModVariables;
import net.minecraft.client.Minecraft;
import net.minecraft.commands.CommandSource; import net.minecraft.commands.CommandSource;
import net.minecraft.commands.CommandSourceStack; import net.minecraft.commands.CommandSourceStack;
import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.GameType;
public class MarlinfireProcedure { public class MarlinfireProcedure {
public static void execute(Entity entity) { public static void execute(Entity entity) {
if (entity == null) if (entity == null) return;
return; if (entity instanceof Player player && !player.isSpectator()) {
ItemStack usehand = ItemStack.EMPTY; ItemStack usehand = player.getMainHandItem();
double ammo1 = 0;
double id = 0;
if (!(new Object() {
public boolean checkGamemode(Entity _ent) {
if (_ent instanceof ServerPlayer _serverPlayer) {
return _serverPlayer.gameMode.getGameModeForPlayer() == GameType.SPECTATOR;
} else if (_ent.level().isClientSide() && _ent instanceof Player _player) {
return Minecraft.getInstance().getConnection().getPlayerInfo(_player.getGameProfile().getId()) != null && Minecraft.getInstance().getConnection().getPlayerInfo(_player.getGameProfile().getId()).getGameMode() == GameType.SPECTATOR;
}
return false;
}
}.checkGamemode(entity))) {
usehand = (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY);
if (usehand.getOrCreateTag().getDouble("reloading") == 1 && usehand.getOrCreateTag().getDouble("prepare") == 0 && usehand.getOrCreateTag().getDouble("ammo") > 0) { if (usehand.getOrCreateTag().getDouble("reloading") == 1 && usehand.getOrCreateTag().getDouble("prepare") == 0 && usehand.getOrCreateTag().getDouble("ammo") > 0) {
usehand.getOrCreateTag().putDouble("forcestop", 1); usehand.getOrCreateTag().putDouble("forcestop", 1);
} }
@ -48,24 +31,15 @@ public class MarlinfireProcedure {
usehand.getOrCreateTag().putDouble("firing", 10); usehand.getOrCreateTag().putDouble("firing", 10);
} }
BulletFireNormalProcedure.execute(entity); BulletFireNormalProcedure.execute(entity);
{
if (!entity.level().isClientSide() && entity.getServer() != null) { if (!entity.level().isClientSide() && entity.getServer() != null) {
entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), entity.level() instanceof ServerLevel ? (ServerLevel) entity.level() : null, 4, entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), entity.level() instanceof ServerLevel ? (ServerLevel) entity.level() : null, 4,
entity.getName().getString(), entity.getDisplayName(), entity.level().getServer(), entity), "playsound target:marlin_fire1p player @s ~ ~ ~ 100 1"); entity.getName().getString(), entity.getDisplayName(), entity.level().getServer(), entity), "playsound target:marlin_fire1p player @s ~ ~ ~ 100 1");
}
}
{
if (!entity.level().isClientSide() && entity.getServer() != null) {
entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), entity.level() instanceof ServerLevel ? (ServerLevel) entity.level() : null, 4, entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), entity.level() instanceof ServerLevel ? (ServerLevel) entity.level() : null, 4,
entity.getName().getString(), entity.getDisplayName(), entity.level().getServer(), entity), "playsound target:marlin_fire3p player @a ~ ~ ~ 4 1"); entity.getName().getString(), entity.getDisplayName(), entity.level().getServer(), entity), "playsound target:marlin_fire3p player @a ~ ~ ~ 4 1");
}
}
{
if (!entity.level().isClientSide() && entity.getServer() != null) {
entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), entity.level() instanceof ServerLevel ? (ServerLevel) entity.level() : null, 4, entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), entity.level() instanceof ServerLevel ? (ServerLevel) entity.level() : null, 4,
entity.getName().getString(), entity.getDisplayName(), entity.level().getServer(), entity), "stopsound @s player target:marlin_fire3p"); entity.getName().getString(), entity.getDisplayName(), entity.level().getServer(), entity), "stopsound @s player target:marlin_fire3p");
} }
}
usehand.getOrCreateTag().putDouble("ammo", (usehand.getOrCreateTag().getDouble("ammo") - 1)); usehand.getOrCreateTag().putDouble("ammo", (usehand.getOrCreateTag().getDouble("ammo") - 1));
if (usehand.getOrCreateTag().getDouble("animindex") == 1) { if (usehand.getOrCreateTag().getDouble("animindex") == 1) {
usehand.getOrCreateTag().putDouble("animindex", 0); usehand.getOrCreateTag().putDouble("animindex", 0);

View file

@ -1,30 +1,15 @@
package net.mcreator.target.procedures; package net.mcreator.target.procedures;
import net.mcreator.target.init.TargetModItems; import net.mcreator.target.init.TargetModItems;
import net.minecraft.client.Minecraft;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.GameType;
public class MinigunfireProcedure { public class MinigunfireProcedure {
public static void execute(Entity entity) { public static void execute(Entity entity) {
if (entity == null) if (entity == null) return;
return; if (entity instanceof Player player && !player.isSpectator()) {
ItemStack usehand; ItemStack usehand = player.getMainHandItem();
if (!(new Object() {
public boolean checkGamemode(Entity _ent) {
if (_ent instanceof ServerPlayer _serverPlayer) {
return _serverPlayer.gameMode.getGameModeForPlayer() == GameType.SPECTATOR;
} else if (_ent.level().isClientSide() && _ent instanceof Player _player) {
return Minecraft.getInstance().getConnection().getPlayerInfo(_player.getGameProfile().getId()) != null && Minecraft.getInstance().getConnection().getPlayerInfo(_player.getGameProfile().getId()).getGameMode() == GameType.SPECTATOR;
}
return false;
}
}.checkGamemode(entity))) {
usehand = (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY);
if (usehand.getItem() == TargetModItems.MINIGUN.get()) { if (usehand.getItem() == TargetModItems.MINIGUN.get()) {
entity.getPersistentData().putDouble("minifiring", 1); entity.getPersistentData().putDouble("minifiring", 1);
} }

View file

@ -1,45 +1,29 @@
package net.mcreator.target.procedures; package net.mcreator.target.procedures;
import net.mcreator.target.init.TargetModItems; import net.mcreator.target.init.TargetModItems;
import net.minecraft.client.Minecraft;
import net.minecraft.commands.CommandSource; import net.minecraft.commands.CommandSource;
import net.minecraft.commands.CommandSourceStack; import net.minecraft.commands.CommandSourceStack;
import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.GameType;
public class Mk14fireProcedure { public class Mk14fireProcedure {
public static void execute(Entity entity) { public static void execute(Entity entity) {
if (entity == null) if (entity == null) return;
return; if (entity instanceof Player player && !player.isSpectator()) {
ItemStack usehand = ItemStack.EMPTY; ItemStack usehand = player.getMainHandItem();
if (!(new Object() {
public boolean checkGamemode(Entity _ent) {
if (_ent instanceof ServerPlayer _serverPlayer) {
return _serverPlayer.gameMode.getGameModeForPlayer() == GameType.SPECTATOR;
} else if (_ent.level().isClientSide() && _ent instanceof Player _player) {
return Minecraft.getInstance().getConnection().getPlayerInfo(_player.getGameProfile().getId()) != null && Minecraft.getInstance().getConnection().getPlayerInfo(_player.getGameProfile().getId()).getGameMode() == GameType.SPECTATOR;
}
return false;
}
}.checkGamemode(entity))) {
usehand = (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY);
if (usehand.getItem() == TargetModItems.MK_14.get()) { if (usehand.getItem() == TargetModItems.MK_14.get()) {
if (usehand.getOrCreateTag().getDouble("firemode") == 0) { if (usehand.getOrCreateTag().getDouble("firemode") == 0) {
if (usehand.getOrCreateTag().getDouble("reloading") == 0 && usehand.getOrCreateTag().getDouble("ammo") > 0 && !(entity instanceof Player _plrCldCheck6 && _plrCldCheck6.getCooldowns().isOnCooldown(usehand.getItem()))) { if (usehand.getOrCreateTag().getDouble("reloading") == 0 && usehand.getOrCreateTag().getDouble("ammo") > 0 && !(entity instanceof Player _plrCldCheck6 && _plrCldCheck6.getCooldowns().isOnCooldown(usehand.getItem()))) {
BulletFireNormalProcedure.execute(entity); BulletFireNormalProcedure.execute(entity);
if (entity instanceof Player _player) if (entity instanceof Player _player)
_player.getCooldowns().addCooldown(usehand.getItem(), 2); _player.getCooldowns().addCooldown(usehand.getItem(), 2);
{
if (!entity.level().isClientSide() && entity.getServer() != null) { if (!entity.level().isClientSide() && entity.getServer() != null) {
entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), entity.level() instanceof ServerLevel ? (ServerLevel) entity.level() : null, 4, entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), entity.level() instanceof ServerLevel ? (ServerLevel) entity.level() : null, 4,
entity.getName().getString(), entity.getDisplayName(), entity.level().getServer(), entity), "playsound target:mk14fire player @a ~ ~ ~ 4 1"); entity.getName().getString(), entity.getDisplayName(), entity.level().getServer(), entity), "playsound target:mk14fire player @a ~ ~ ~ 4 1");
} }
}
usehand.getOrCreateTag().putDouble("fireanim", 2); usehand.getOrCreateTag().putDouble("fireanim", 2);
usehand.getOrCreateTag().putDouble("ammo", (usehand.getOrCreateTag().getDouble("ammo") - 1)); usehand.getOrCreateTag().putDouble("ammo", (usehand.getOrCreateTag().getDouble("ammo") - 1));
} }

View file

@ -6,7 +6,6 @@ import net.mcreator.target.entity.MortarShellEntity;
import net.mcreator.target.init.TargetModEntities; import net.mcreator.target.init.TargetModEntities;
import net.mcreator.target.init.TargetModItems; import net.mcreator.target.init.TargetModItems;
import net.mcreator.target.world.inventory.MortarGUIMenu; import net.mcreator.target.world.inventory.MortarGUIMenu;
import net.minecraft.client.Minecraft;
import net.minecraft.commands.CommandSource; import net.minecraft.commands.CommandSource;
import net.minecraft.commands.CommandSourceStack; import net.minecraft.commands.CommandSourceStack;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
@ -24,7 +23,6 @@ import net.minecraft.world.entity.projectile.AbstractArrow;
import net.minecraft.world.entity.projectile.Projectile; import net.minecraft.world.entity.projectile.Projectile;
import net.minecraft.world.inventory.AbstractContainerMenu; import net.minecraft.world.inventory.AbstractContainerMenu;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.GameType;
import net.minecraft.world.level.Level; import net.minecraft.world.level.Level;
import net.minecraft.world.level.LevelAccessor; import net.minecraft.world.level.LevelAccessor;
import net.minecraftforge.network.NetworkHooks; import net.minecraftforge.network.NetworkHooks;
@ -35,19 +33,17 @@ public class MortarYouJiShiTiShiProcedure {
return; return;
if ((sourceentity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getItem() == ItemStack.EMPTY.getItem()) { if ((sourceentity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getItem() == ItemStack.EMPTY.getItem()) {
if (sourceentity.isShiftKeyDown()) { if (sourceentity.isShiftKeyDown()) {
{
Entity _ent = entity; entity.setYRot(sourceentity.getYRot());
_ent.setYRot(sourceentity.getYRot()); entity.setXRot(entity.getXRot());
_ent.setXRot(entity.getXRot()); entity.setYBodyRot(entity.getYRot());
_ent.setYBodyRot(_ent.getYRot()); entity.setYHeadRot(entity.getYRot());
_ent.setYHeadRot(_ent.getYRot()); entity.yRotO = entity.getYRot();
_ent.yRotO = _ent.getYRot(); entity.xRotO = entity.getXRot();
_ent.xRotO = _ent.getXRot(); if (entity instanceof LivingEntity _entity) {
if (_ent instanceof LivingEntity _entity) {
_entity.yBodyRotO = _entity.getYRot(); _entity.yBodyRotO = _entity.getYRot();
_entity.yHeadRotO = _entity.getYRot(); _entity.yHeadRotO = _entity.getYRot();
} }
}
} else { } else {
if (sourceentity instanceof ServerPlayer _ent) { if (sourceentity instanceof ServerPlayer _ent) {
BlockPos _bpos = BlockPos.containing(x, y, z); BlockPos _bpos = BlockPos.containing(x, y, z);
@ -67,49 +63,23 @@ public class MortarYouJiShiTiShiProcedure {
} }
if ((sourceentity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getItem() == TargetModItems.MORTAR_SHELLS.get() if ((sourceentity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getItem() == TargetModItems.MORTAR_SHELLS.get()
&& !(sourceentity instanceof Player _plrCldCheck10 && _plrCldCheck10.getCooldowns().isOnCooldown(TargetModItems.MORTAR_SHELLS.get()))) { && !(sourceentity instanceof Player _plrCldCheck10 && _plrCldCheck10.getCooldowns().isOnCooldown(TargetModItems.MORTAR_SHELLS.get()))) {
if (sourceentity instanceof Player _player) if (sourceentity instanceof Player player) {
_player.getCooldowns().addCooldown(TargetModItems.MORTAR_SHELLS.get(), 30); player.getCooldowns().addCooldown(TargetModItems.MORTAR_SHELLS.get(), 30);
if (!(new Object() { if (!player.isCreative()) {
public boolean checkGamemode(Entity _ent) {
if (_ent instanceof ServerPlayer _serverPlayer) {
return _serverPlayer.gameMode.getGameModeForPlayer() == GameType.CREATIVE;
} else if (_ent.level().isClientSide() && _ent instanceof Player _player) {
return Minecraft.getInstance().getConnection().getPlayerInfo(_player.getGameProfile().getId()) != null
&& Minecraft.getInstance().getConnection().getPlayerInfo(_player.getGameProfile().getId()).getGameMode() == GameType.CREATIVE;
}
return false;
}
}.checkGamemode(sourceentity))) {
if (sourceentity instanceof Player _player) {
ItemStack _stktoremove = new ItemStack(TargetModItems.MORTAR_SHELLS.get()); ItemStack _stktoremove = new ItemStack(TargetModItems.MORTAR_SHELLS.get());
_player.getInventory().clearOrCountMatchingItems(p -> _stktoremove.getItem() == p.getItem(), 1, _player.inventoryMenu.getCraftSlots()); player.getInventory().clearOrCountMatchingItems(p -> _stktoremove.getItem() == p.getItem(), 1, player.inventoryMenu.getCraftSlots());
} }
} }
{ if (!entity.level().isClientSide() && entity.getServer() != null) {
Entity _ent = entity; entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), entity.level() instanceof ServerLevel ? (ServerLevel) entity.level() : null, 4,
if (!_ent.level().isClientSide() && _ent.getServer() != null) { entity.getName().getString(), entity.getDisplayName(), entity.level().getServer(), entity), "playsound target:mortar_load player @a ~ ~ ~ 1 1");
_ent.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, _ent.position(), _ent.getRotationVector(), _ent.level() instanceof ServerLevel ? (ServerLevel) _ent.level() : null, 4, entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), entity.level() instanceof ServerLevel ? (ServerLevel) entity.level() : null, 4,
_ent.getName().getString(), _ent.getDisplayName(), _ent.level().getServer(), _ent), "playsound target:mortar_load player @a ~ ~ ~ 1 1"); entity.getName().getString(), entity.getDisplayName(), entity.level().getServer(), entity), "playsound target:mortar_fire player @a ~ ~ ~ 8 1");
} entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), entity.level() instanceof ServerLevel ? (ServerLevel) entity.level() : null, 4,
} entity.getName().getString(), entity.getDisplayName(), entity.level().getServer(), entity), "playsound target:mortar_distant player @a ~ ~ ~ 32 1");
{
Entity _ent = entity;
if (!_ent.level().isClientSide() && _ent.getServer() != null) {
_ent.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, _ent.position(), _ent.getRotationVector(), _ent.level() instanceof ServerLevel ? (ServerLevel) _ent.level() : null, 4,
_ent.getName().getString(), _ent.getDisplayName(), _ent.level().getServer(), _ent), "playsound target:mortar_fire player @a ~ ~ ~ 8 1");
}
}
{
Entity _ent = entity;
if (!_ent.level().isClientSide() && _ent.getServer() != null) {
_ent.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, _ent.position(), _ent.getRotationVector(), _ent.level() instanceof ServerLevel ? (ServerLevel) _ent.level() : null, 4,
_ent.getName().getString(), _ent.getDisplayName(), _ent.level().getServer(), _ent), "playsound target:mortar_distant player @a ~ ~ ~ 32 1");
}
} }
TargetMod.queueServerWork(20, () -> { TargetMod.queueServerWork(20, () -> {
{ Level projectileLevel = entity.level();
Entity _shootFrom = entity;
Level projectileLevel = _shootFrom.level();
if (!projectileLevel.isClientSide()) { if (!projectileLevel.isClientSide()) {
Projectile _entityToSpawn = new Object() { Projectile _entityToSpawn = new Object() {
public Projectile getArrow(Level level, Entity shooter, float damage, int knockback) { public Projectile getArrow(Level level, Entity shooter, float damage, int knockback) {
@ -121,11 +91,10 @@ public class MortarYouJiShiTiShiProcedure {
return entityToSpawn; return entityToSpawn;
} }
}.getArrow(projectileLevel, sourceentity, 100, 0); }.getArrow(projectileLevel, sourceentity, 100, 0);
_entityToSpawn.setPos(_shootFrom.getX(), _shootFrom.getEyeY() - 0.1, _shootFrom.getZ()); _entityToSpawn.setPos(entity.getX(), entity.getEyeY() - 0.1, entity.getZ());
_entityToSpawn.shoot(_shootFrom.getLookAngle().x, _shootFrom.getLookAngle().y, _shootFrom.getLookAngle().z, 8, (float) 0.5); _entityToSpawn.shoot(entity.getLookAngle().x, entity.getLookAngle().y, entity.getLookAngle().z, 8, (float) 0.5);
projectileLevel.addFreshEntity(_entityToSpawn); projectileLevel.addFreshEntity(_entityToSpawn);
} }
}
if (world instanceof ServerLevel _level) if (world instanceof ServerLevel _level)
_level.sendParticles(ParticleTypes.CAMPFIRE_COSY_SMOKE, (entity.getX() + 2.2 * entity.getLookAngle().x), (entity.getY() + 0.1 + 2.2 * entity.getLookAngle().y), (entity.getZ() + 2.2 * entity.getLookAngle().z), 40, 0.4, 0.4, 0.4, _level.sendParticles(ParticleTypes.CAMPFIRE_COSY_SMOKE, (entity.getX() + 2.2 * entity.getLookAngle().x), (entity.getY() + 0.1 + 2.2 * entity.getLookAngle().y), (entity.getZ() + 2.2 * entity.getLookAngle().z), 40, 0.4, 0.4, 0.4,
0.015); 0.015);

View file

@ -2,366 +2,345 @@ package net.mcreator.target.procedures;
import net.mcreator.target.init.TargetModItems; import net.mcreator.target.init.TargetModItems;
import net.mcreator.target.network.TargetModVariables; import net.mcreator.target.network.TargetModVariables;
import net.minecraft.client.Minecraft;
import net.minecraft.commands.CommandSource; import net.minecraft.commands.CommandSource;
import net.minecraft.commands.CommandSourceStack; import net.minecraft.commands.CommandSourceStack;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.util.Mth; import net.minecraft.util.Mth;
import net.minecraft.util.RandomSource; import net.minecraft.util.RandomSource;
import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.GameType;
public class PlayerReloadProcedure { public class PlayerReloadProcedure {
public static void execute(Entity entity) { public static void execute(Entity entity) {
if (entity == null) if (entity == null) return;
return; if (entity instanceof Player player && !player.isSpectator()) {
double ammo1 = 0;
double id = 0;
if (!(new Object() {
public boolean checkGamemode(Entity _ent) {
if (_ent instanceof ServerPlayer _serverPlayer) {
return _serverPlayer.gameMode.getGameModeForPlayer() == GameType.SPECTATOR;
} else if (_ent.level().isClientSide() && _ent instanceof Player _player) {
return Minecraft.getInstance().getConnection().getPlayerInfo(_player.getGameProfile().getId()) != null && Minecraft.getInstance().getConnection().getPlayerInfo(_player.getGameProfile().getId()).getGameMode() == GameType.SPECTATOR;
}
return false;
}
}.checkGamemode(entity))) {
if (!(entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).zooming) { if (!(entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).zooming) {
if ((entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getItem() == TargetModItems.TASER.get() CompoundTag tag = player.getMainHandItem().getOrCreateTag();
&& !(entity instanceof Player _plrCldCheck4 && _plrCldCheck4.getCooldowns().isOnCooldown((entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getItem()))
&& (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("reloading") == 0 if (player.getMainHandItem().getItem() == TargetModItems.TASER.get()
&& (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("ammo") < 1) { && !(player.getCooldowns().isOnCooldown(player.getMainHandItem().getItem()))
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("reloading", 1); && tag.getDouble("reloading") == 0
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("id", (Mth.nextDouble(RandomSource.create(), 1, 1919810))); && tag.getDouble("ammo") < 1) {
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("reloadtime", 55); tag.putDouble("reloading", 1);
tag.putDouble("id", (Mth.nextDouble(RandomSource.create(), 1, 1919810)));
tag.putDouble("reloadtime", 55);
} }
if ((entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getItem() == TargetModItems.TRACHELIUM.get() if (player.getMainHandItem().getItem() == TargetModItems.TRACHELIUM.get()
&& !(entity instanceof Player _plrCldCheck19 && _plrCldCheck19.getCooldowns().isOnCooldown((entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getItem())) && !(player.getCooldowns().isOnCooldown(player.getMainHandItem().getItem()))
&& (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("reloading") == 0 && tag.getDouble("reloading") == 0
&& (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("ammo") < 8 && tag.getDouble("ammo") < 8
&& (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).handgunammo > 0) { && (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).handgunammo > 0) {
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("reloading", 1); tag.putDouble("reloading", 1);
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("emptyreload", 1); tag.putDouble("emptyreload", 1);
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("id", (Mth.nextDouble(RandomSource.create(), 1, 1919810))); tag.putDouble("id", (Mth.nextDouble(RandomSource.create(), 1, 1919810)));
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("reloadtime", 57); tag.putDouble("reloadtime", 57);
} }
if ((entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getItem() == TargetModItems.HUNTING_RIFLE.get() if (player.getMainHandItem().getItem() == TargetModItems.HUNTING_RIFLE.get()
&& !(entity instanceof Player _plrCldCheck36 && _plrCldCheck36.getCooldowns().isOnCooldown((entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getItem())) && !(player.getCooldowns().isOnCooldown(player.getMainHandItem().getItem()))
&& (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("reloading") == 0 && tag.getDouble("reloading") == 0
&& (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("ammo") < 1 && tag.getDouble("ammo") < 1
&& (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).sniperammo > 0) { && (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).sniperammo > 0) {
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("reloading", 1); tag.putDouble("reloading", 1);
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("reloadtime", 61); tag.putDouble("reloadtime", 61);
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("emptyreload", 1); tag.putDouble("emptyreload", 1);
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("id", (Mth.nextDouble(RandomSource.create(), 1, 1919810))); tag.putDouble("id", (Mth.nextDouble(RandomSource.create(), 1, 1919810)));
} }
if ((entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getItem() == TargetModItems.M_79.get() if (player.getMainHandItem().getItem() == TargetModItems.M_79.get()
&& !(entity instanceof Player _plrCldCheck53 && _plrCldCheck53.getCooldowns().isOnCooldown((entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getItem())) && !(player.getCooldowns().isOnCooldown(player.getMainHandItem().getItem()))
&& (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("reloading") == 0 && tag.getDouble("reloading") == 0
&& (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("ammo") < 1 && tag.getDouble("ammo") < 1
&& (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("maxammo") > 0) { && tag.getDouble("maxammo") > 0) {
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("reloading", 1); tag.putDouble("reloading", 1);
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("emptyreload", 1); tag.putDouble("emptyreload", 1);
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("id", (Mth.nextDouble(RandomSource.create(), 1, 1919810))); tag.putDouble("id", (Mth.nextDouble(RandomSource.create(), 1, 1919810)));
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("reloadtime", 86); tag.putDouble("reloadtime", 86);
} }
if ((entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getItem() == TargetModItems.RPG.get() if (player.getMainHandItem().getItem() == TargetModItems.RPG.get()
&& !(entity instanceof Player _plrCldCheck72 && _plrCldCheck72.getCooldowns().isOnCooldown((entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getItem())) && !(player.getCooldowns().isOnCooldown(player.getMainHandItem().getItem()))
&& (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("reloading") == 0 && tag.getDouble("reloading") == 0
&& (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("ammo") < 1 && tag.getDouble("ammo") < 1
&& (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("maxammo") > 0) { && tag.getDouble("maxammo") > 0) {
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("reloading", 1); tag.putDouble("reloading", 1);
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("emptyreload", 1); tag.putDouble("emptyreload", 1);
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("id", (Mth.nextDouble(RandomSource.create(), 1, 1919810))); tag.putDouble("id", (Mth.nextDouble(RandomSource.create(), 1, 1919810)));
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("reloadtime", 91); tag.putDouble("reloadtime", 91);
} }
if ((entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getItem() == TargetModItems.ABEKIRI.get() if (player.getMainHandItem().getItem() == TargetModItems.ABEKIRI.get()
&& !(entity instanceof Player _plrCldCheck91 && _plrCldCheck91.getCooldowns().isOnCooldown((entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getItem())) && !(player.getCooldowns().isOnCooldown(player.getMainHandItem().getItem()))
&& (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("reloading") == 0 && tag.getDouble("reloading") == 0
&& (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("ammo") < 2 && tag.getDouble("ammo") < 2
&& (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).shotgunammo > 0) { && (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).shotgunammo > 0) {
if ((entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("ammo") == 1) { if (tag.getDouble("ammo") == 1) {
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("reloading", 1); tag.putDouble("reloading", 1);
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("emptyreload", 0); tag.putDouble("emptyreload", 0);
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("id", (Mth.nextDouble(RandomSource.create(), 1, 1919810))); tag.putDouble("id", (Mth.nextDouble(RandomSource.create(), 1, 1919810)));
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("reloadtime", 83); tag.putDouble("reloadtime", 83);
} else if ((entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("ammo") == 0) { } else if (tag.getDouble("ammo") == 0) {
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("reloading", 1); tag.putDouble("reloading", 1);
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("emptyreload", 1); tag.putDouble("emptyreload", 1);
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("id", (Mth.nextDouble(RandomSource.create(), 1, 1919810))); tag.putDouble("id", (Mth.nextDouble(RandomSource.create(), 1, 1919810)));
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("reloadtime", 99); tag.putDouble("reloadtime", 99);
} }
} }
if ((entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getItem() == TargetModItems.M_98B.get() if (player.getMainHandItem().getItem() == TargetModItems.M_98B.get()
&& !(entity instanceof Player _plrCldCheck121 && _plrCldCheck121.getCooldowns().isOnCooldown((entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getItem())) && !(player.getCooldowns().isOnCooldown(player.getMainHandItem().getItem()))
&& (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("reloading") == 0 && tag.getDouble("reloading") == 0
&& (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("ammo") < 6 && tag.getDouble("ammo") < 6
&& (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).sniperammo > 0) { && (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).sniperammo > 0) {
if ((entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("ammo") > 0) { if (tag.getDouble("ammo") > 0) {
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("reloading", 1); tag.putDouble("reloading", 1);
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("emptyreload", 0); tag.putDouble("emptyreload", 0);
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("id", (Mth.nextDouble(RandomSource.create(), 1, 1919810))); tag.putDouble("id", (Mth.nextDouble(RandomSource.create(), 1, 1919810)));
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("reloadtime", 57); tag.putDouble("reloadtime", 57);
} else if ((entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("ammo") == 0) { } else if (tag.getDouble("ammo") == 0) {
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("reloading", 1); tag.putDouble("reloading", 1);
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("emptyreload", 1); tag.putDouble("emptyreload", 1);
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("id", (Mth.nextDouble(RandomSource.create(), 1, 1919810))); tag.putDouble("id", (Mth.nextDouble(RandomSource.create(), 1, 1919810)));
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("reloadtime", 79); tag.putDouble("reloadtime", 79);
} }
} }
if ((entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getItem() == TargetModItems.KRABER.get() if (player.getMainHandItem().getItem() == TargetModItems.KRABER.get()
&& !(entity instanceof Player _plrCldCheck151 && _plrCldCheck151.getCooldowns().isOnCooldown((entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getItem())) && !(player.getCooldowns().isOnCooldown(player.getMainHandItem().getItem()))
&& (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("reloading") == 0 && tag.getDouble("reloading") == 0
&& (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("ammo") < 5 && tag.getDouble("ammo") < 5
&& (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).sniperammo > 0) { && (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).sniperammo > 0) {
if ((entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("ammo") > 0) { if (tag.getDouble("ammo") > 0) {
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("reloading", 1); tag.putDouble("reloading", 1);
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("emptyreload", 0); tag.putDouble("emptyreload", 0);
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("id", (Mth.nextDouble(RandomSource.create(), 1, 1919810))); tag.putDouble("id", (Mth.nextDouble(RandomSource.create(), 1, 1919810)));
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("reloadtime", 65); tag.putDouble("reloadtime", 65);
} else if ((entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("ammo") == 0) { } else if (tag.getDouble("ammo") == 0) {
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("reloading", 1); tag.putDouble("reloading", 1);
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("emptyreload", 1); tag.putDouble("emptyreload", 1);
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("id", (Mth.nextDouble(RandomSource.create(), 1, 1919810))); tag.putDouble("id", (Mth.nextDouble(RandomSource.create(), 1, 1919810)));
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("reloadtime", 83); tag.putDouble("reloadtime", 83);
} }
} }
if ((entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getItem() == TargetModItems.VECTOR.get() if (player.getMainHandItem().getItem() == TargetModItems.VECTOR.get()
&& !(entity instanceof Player _plrCldCheck181 && _plrCldCheck181.getCooldowns().isOnCooldown((entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getItem())) && !(player.getCooldowns().isOnCooldown(player.getMainHandItem().getItem()))
&& (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("reloading") == 0 && tag.getDouble("reloading") == 0
&& (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("ammo") < 34 && tag.getDouble("ammo") < 34
&& (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).handgunammo > 0) { && (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).handgunammo > 0) {
if ((entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("ammo") > 0) { if (tag.getDouble("ammo") > 0) {
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("reloading", 1); tag.putDouble("reloading", 1);
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("emptyreload", 0); tag.putDouble("emptyreload", 0);
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("id", (Mth.nextDouble(RandomSource.create(), 1, 1919810))); tag.putDouble("id", (Mth.nextDouble(RandomSource.create(), 1, 1919810)));
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("reloadtime", 47); tag.putDouble("reloadtime", 47);
} else if ((entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("ammo") == 0) { } else if (tag.getDouble("ammo") == 0) {
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("reloading", 1); tag.putDouble("reloading", 1);
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("emptyreload", 1); tag.putDouble("emptyreload", 1);
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("id", (Mth.nextDouble(RandomSource.create(), 1, 1919810))); tag.putDouble("id", (Mth.nextDouble(RandomSource.create(), 1, 1919810)));
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("reloadtime", 61); tag.putDouble("reloadtime", 61);
} }
} }
if ((entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getItem() == TargetModItems.MK_14.get() if (player.getMainHandItem().getItem() == TargetModItems.MK_14.get()
&& !(entity instanceof Player _plrCldCheck211 && _plrCldCheck211.getCooldowns().isOnCooldown((entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getItem())) && !(player.getCooldowns().isOnCooldown(player.getMainHandItem().getItem()))
&& (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("reloading") == 0 && tag.getDouble("reloading") == 0
&& (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("ammo") < 21 && tag.getDouble("ammo") < 21
&& (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).rifleammo > 0) { && (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).rifleammo > 0) {
if ((entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("ammo") > 0) { if (tag.getDouble("ammo") > 0) {
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("reloading", 1); tag.putDouble("reloading", 1);
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("emptyreload", 0); tag.putDouble("emptyreload", 0);
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("id", (Mth.nextDouble(RandomSource.create(), 1, 1919810))); tag.putDouble("id", (Mth.nextDouble(RandomSource.create(), 1, 1919810)));
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("reloadtime", 45); tag.putDouble("reloadtime", 45);
} else if ((entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("ammo") == 0) { } else if (tag.getDouble("ammo") == 0) {
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("reloading", 1); tag.putDouble("reloading", 1);
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("emptyreload", 1); tag.putDouble("emptyreload", 1);
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("id", (Mth.nextDouble(RandomSource.create(), 1, 1919810))); tag.putDouble("id", (Mth.nextDouble(RandomSource.create(), 1, 1919810)));
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("reloadtime", 55); tag.putDouble("reloadtime", 55);
} }
} }
if ((entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getItem() == TargetModItems.SKS.get() if (player.getMainHandItem().getItem() == TargetModItems.SKS.get()
&& !(entity instanceof Player _plrCldCheck241 && _plrCldCheck241.getCooldowns().isOnCooldown((entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getItem())) && !(player.getCooldowns().isOnCooldown(player.getMainHandItem().getItem()))
&& (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("reloading") == 0 && tag.getDouble("reloading") == 0
&& (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("ammo") < 21 && tag.getDouble("ammo") < 21
&& (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).rifleammo > 0) { && (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).rifleammo > 0) {
if ((entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("ammo") > 0) { if (tag.getDouble("ammo") > 0) {
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("reloading", 1); tag.putDouble("reloading", 1);
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("emptyreload", 0); tag.putDouble("emptyreload", 0);
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("id", (Mth.nextDouble(RandomSource.create(), 1, 1919810))); tag.putDouble("id", (Mth.nextDouble(RandomSource.create(), 1, 1919810)));
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("reloadtime", 41); tag.putDouble("reloadtime", 41);
} else if ((entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("ammo") == 0) { } else if (tag.getDouble("ammo") == 0) {
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("reloading", 1); tag.putDouble("reloading", 1);
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("emptyreload", 1); tag.putDouble("emptyreload", 1);
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("id", (Mth.nextDouble(RandomSource.create(), 1, 1919810))); tag.putDouble("id", (Mth.nextDouble(RandomSource.create(), 1, 1919810)));
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("reloadtime", 57); tag.putDouble("reloadtime", 57);
} }
} }
if ((entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getItem() == TargetModItems.AK_47.get() if (player.getMainHandItem().getItem() == TargetModItems.AK_47.get()
&& !(entity instanceof Player _plrCldCheck271 && _plrCldCheck271.getCooldowns().isOnCooldown((entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getItem())) && !(player.getCooldowns().isOnCooldown(player.getMainHandItem().getItem()))
&& (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("reloading") == 0 && tag.getDouble("reloading") == 0
&& (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("ammo") < 31 && tag.getDouble("ammo") < 31
&& (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).rifleammo > 0) { && (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).rifleammo > 0) {
if ((entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("ammo") > 0) { if (tag.getDouble("ammo") > 0) {
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("reloading", 1); tag.putDouble("reloading", 1);
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("emptyreload", 0); tag.putDouble("emptyreload", 0);
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("id", (Mth.nextDouble(RandomSource.create(), 1, 1919810))); tag.putDouble("id", (Mth.nextDouble(RandomSource.create(), 1, 1919810)));
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("reloadtime", 41); tag.putDouble("reloadtime", 41);
} else if ((entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("ammo") == 0) { } else if (tag.getDouble("ammo") == 0) {
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("reloading", 1); tag.putDouble("reloading", 1);
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("emptyreload", 1); tag.putDouble("emptyreload", 1);
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("id", (Mth.nextDouble(RandomSource.create(), 1, 1919810))); tag.putDouble("id", (Mth.nextDouble(RandomSource.create(), 1, 1919810)));
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("reloadtime", 57); tag.putDouble("reloadtime", 57);
} }
} }
if (((entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getItem() == TargetModItems.M_4.get() if ((player.getMainHandItem().getItem() == TargetModItems.M_4.get()
|| (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getItem() == TargetModItems.HK_416.get()) || player.getMainHandItem().getItem() == TargetModItems.HK_416.get())
&& !(entity instanceof Player _plrCldCheck303 && _plrCldCheck303.getCooldowns().isOnCooldown((entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getItem())) && !(player.getCooldowns().isOnCooldown(player.getMainHandItem().getItem()))
&& (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("reloading") == 0 && tag.getDouble("reloading") == 0
&& (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("ammo") < 31 && tag.getDouble("ammo") < 31
&& (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).rifleammo > 0) { && (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).rifleammo > 0) {
if ((entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("ammo") > 0) { if (tag.getDouble("ammo") > 0) {
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("reloading", 1); tag.putDouble("reloading", 1);
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("emptyreload", 0); tag.putDouble("emptyreload", 0);
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("id", (Mth.nextDouble(RandomSource.create(), 1, 1919810))); tag.putDouble("id", (Mth.nextDouble(RandomSource.create(), 1, 1919810)));
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("reloadtime", 41); tag.putDouble("reloadtime", 41);
} else if ((entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("ammo") == 0) { } else if (tag.getDouble("ammo") == 0) {
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("reloading", 1); tag.putDouble("reloading", 1);
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("emptyreload", 1); tag.putDouble("emptyreload", 1);
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("id", (Mth.nextDouble(RandomSource.create(), 1, 1919810))); tag.putDouble("id", (Mth.nextDouble(RandomSource.create(), 1, 1919810)));
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("reloadtime", 55); tag.putDouble("reloadtime", 55);
} }
} }
if ((entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getItem() == TargetModItems.AA_12.get() if (player.getMainHandItem().getItem() == TargetModItems.AA_12.get()
&& !(entity instanceof Player _plrCldCheck333 && _plrCldCheck333.getCooldowns().isOnCooldown((entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getItem())) && !(player.getCooldowns().isOnCooldown(player.getMainHandItem().getItem()))
&& (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("reloading") == 0 && tag.getDouble("reloading") == 0
&& (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("ammo") < 26 && tag.getDouble("ammo") < 26
&& (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).shotgunammo > 0) { && (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).shotgunammo > 0) {
if ((entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("ammo") > 0) { if (tag.getDouble("ammo") > 0) {
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("reloading", 1); tag.putDouble("reloading", 1);
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("emptyreload", 0); tag.putDouble("emptyreload", 0);
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("id", (Mth.nextDouble(RandomSource.create(), 1, 1919810))); tag.putDouble("id", (Mth.nextDouble(RandomSource.create(), 1, 1919810)));
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("reloadtime", 41); tag.putDouble("reloadtime", 41);
} else if ((entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("ammo") == 0) { } else if (tag.getDouble("ammo") == 0) {
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("reloading", 1); tag.putDouble("reloading", 1);
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("emptyreload", 1); tag.putDouble("emptyreload", 1);
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("id", (Mth.nextDouble(RandomSource.create(), 1, 1919810))); tag.putDouble("id", (Mth.nextDouble(RandomSource.create(), 1, 1919810)));
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("reloadtime", 52); tag.putDouble("reloadtime", 52);
} }
} }
if ((entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getItem() == TargetModItems.DEVOTION.get() if (player.getMainHandItem().getItem() == TargetModItems.DEVOTION.get()
&& !(entity instanceof Player _plrCldCheck363 && _plrCldCheck363.getCooldowns().isOnCooldown((entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getItem())) && !(player.getCooldowns().isOnCooldown(player.getMainHandItem().getItem()))
&& (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("reloading") == 0 && tag.getDouble("reloading") == 0
&& (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).rifleammo > 0 && (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).rifleammo > 0
&& (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("ammo") < 56) { && tag.getDouble("ammo") < 56) {
if ((entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("ammo") > 0) { if (tag.getDouble("ammo") > 0) {
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("reloading", 1); tag.putDouble("reloading", 1);
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("emptyreload", 0); tag.putDouble("emptyreload", 0);
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("id", (Mth.nextDouble(RandomSource.create(), 1, 1919810))); tag.putDouble("id", (Mth.nextDouble(RandomSource.create(), 1, 1919810)));
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("reloadtime", 51); tag.putDouble("reloadtime", 51);
} else if ((entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("ammo") == 0) { } else if (tag.getDouble("ammo") == 0) {
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("reloading", 1); tag.putDouble("reloading", 1);
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("emptyreload", 1); tag.putDouble("emptyreload", 1);
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("id", (Mth.nextDouble(RandomSource.create(), 1, 1919810))); tag.putDouble("id", (Mth.nextDouble(RandomSource.create(), 1, 1919810)));
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("reloadtime", 71); tag.putDouble("reloadtime", 71);
} }
} }
if ((entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getItem() == TargetModItems.RPK.get() if (player.getMainHandItem().getItem() == TargetModItems.RPK.get()
&& !(entity instanceof Player _plrCldCheck393 && _plrCldCheck393.getCooldowns().isOnCooldown((entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getItem())) && !(player.getCooldowns().isOnCooldown(player.getMainHandItem().getItem()))
&& (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("reloading") == 0 && tag.getDouble("reloading") == 0
&& (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).rifleammo > 0 && (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).rifleammo > 0
&& (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("ammo") < 51) { && tag.getDouble("ammo") < 51) {
if ((entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("ammo") > 0) { if (tag.getDouble("ammo") > 0) {
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("reloading", 1); tag.putDouble("reloading", 1);
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("emptyreload", 0); tag.putDouble("emptyreload", 0);
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("id", (Mth.nextDouble(RandomSource.create(), 1, 1919810))); tag.putDouble("id", (Mth.nextDouble(RandomSource.create(), 1, 1919810)));
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("reloadtime", 41); tag.putDouble("reloadtime", 41);
} else if ((entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("ammo") == 0) { } else if (tag.getDouble("ammo") == 0) {
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("reloading", 1); tag.putDouble("reloading", 1);
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("emptyreload", 1); tag.putDouble("emptyreload", 1);
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("id", (Mth.nextDouble(RandomSource.create(), 1, 1919810))); tag.putDouble("id", (Mth.nextDouble(RandomSource.create(), 1, 1919810)));
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("reloadtime", 57); tag.putDouble("reloadtime", 57);
} }
} }
if ((entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getItem() == TargetModItems.SENTINEL.get() if (player.getMainHandItem().getItem() == TargetModItems.SENTINEL.get()
&& !(entity instanceof Player _plrCldCheck423 && _plrCldCheck423.getCooldowns().isOnCooldown((entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getItem())) && !(player.getCooldowns().isOnCooldown(player.getMainHandItem().getItem()))
&& (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("reloading") == 0 && tag.getDouble("reloading") == 0
&& (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("ammo") < 6 && tag.getDouble("ammo") < 6
&& (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).sniperammo > 0) { && (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).sniperammo > 0) {
if ((entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("ammo") > 0) { if (tag.getDouble("ammo") > 0) {
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("reloading", 1); tag.putDouble("reloading", 1);
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("emptyreload", 0); tag.putDouble("emptyreload", 0);
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("id", (Mth.nextDouble(RandomSource.create(), 1, 1919810))); tag.putDouble("id", (Mth.nextDouble(RandomSource.create(), 1, 1919810)));
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("reloadtime", 53); tag.putDouble("reloadtime", 53);
} else if ((entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("ammo") == 0) { } else if (tag.getDouble("ammo") == 0) {
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("reloading", 1); tag.putDouble("reloading", 1);
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("emptyreload", 1); tag.putDouble("emptyreload", 1);
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("id", (Mth.nextDouble(RandomSource.create(), 1, 1919810))); tag.putDouble("id", (Mth.nextDouble(RandomSource.create(), 1, 1919810)));
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("reloadtime", 73); tag.putDouble("reloadtime", 73);
} }
} }
if ((entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getItem() == TargetModItems.SVD.get() if (player.getMainHandItem().getItem() == TargetModItems.SVD.get()
&& !(entity instanceof Player _plrCldCheck453 && _plrCldCheck453.getCooldowns().isOnCooldown((entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getItem())) && !(player.getCooldowns().isOnCooldown(player.getMainHandItem().getItem()))
&& (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("reloading") == 0 && tag.getDouble("reloading") == 0
&& (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("ammo") < 11 && tag.getDouble("ammo") < 11
&& (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).sniperammo > 0) { && (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).sniperammo > 0) {
if ((entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("ammo") > 0) { if (tag.getDouble("ammo") > 0) {
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("reloading", 1); tag.putDouble("reloading", 1);
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("emptyreload", 0); tag.putDouble("emptyreload", 0);
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("id", (Mth.nextDouble(RandomSource.create(), 1, 1919810))); tag.putDouble("id", (Mth.nextDouble(RandomSource.create(), 1, 1919810)));
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("reloadtime", 41); tag.putDouble("reloadtime", 41);
} else if ((entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("ammo") == 0) { } else if (tag.getDouble("ammo") == 0) {
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("reloading", 1); tag.putDouble("reloading", 1);
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("emptyreload", 1); tag.putDouble("emptyreload", 1);
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("id", (Mth.nextDouble(RandomSource.create(), 1, 1919810))); tag.putDouble("id", (Mth.nextDouble(RandomSource.create(), 1, 1919810)));
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("reloadtime", 57); tag.putDouble("reloadtime", 57);
} }
} }
if ((entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getItem() == TargetModItems.M_60.get() if (player.getMainHandItem().getItem() == TargetModItems.M_60.get()
&& !(entity instanceof Player _plrCldCheck483 && _plrCldCheck483.getCooldowns().isOnCooldown((entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getItem())) && !(player.getCooldowns().isOnCooldown(player.getMainHandItem().getItem()))
&& (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("reloading") == 0 && tag.getDouble("reloading") == 0
&& (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).rifleammo > 0 && (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).rifleammo > 0
&& (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("ammo") < 100) { && tag.getDouble("ammo") < 100) {
if ((entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("ammo") > 0) { if (tag.getDouble("ammo") > 0) {
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("reloading", 1); tag.putDouble("reloading", 1);
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("emptyreload", 0); tag.putDouble("emptyreload", 0);
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("id", (Mth.nextDouble(RandomSource.create(), 1, 1919810))); tag.putDouble("id", (Mth.nextDouble(RandomSource.create(), 1, 1919810)));
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("reloadtime", 111); tag.putDouble("reloadtime", 111);
} else if ((entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("ammo") == 0) { } else if (tag.getDouble("ammo") == 0) {
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("reloading", 1); tag.putDouble("reloading", 1);
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("emptyreload", 1); tag.putDouble("emptyreload", 1);
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("id", (Mth.nextDouble(RandomSource.create(), 1, 1919810))); tag.putDouble("id", (Mth.nextDouble(RandomSource.create(), 1, 1919810)));
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("reloadtime", 129); tag.putDouble("reloadtime", 129);
} }
} }
if ((entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getItem() == TargetModItems.MARLIN.get() if (player.getMainHandItem().getItem() == TargetModItems.MARLIN.get()
&& !(entity instanceof Player _plrCldCheck513 && _plrCldCheck513.getCooldowns().isOnCooldown((entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getItem())) && !(player.getCooldowns().isOnCooldown(player.getMainHandItem().getItem()))
&& (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("reloading") == 0 && tag.getDouble("reloading") == 0
&& (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("ammo") < 8 && tag.getDouble("ammo") < 8
&& (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).rifleammo > 0) { && (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).rifleammo > 0) {
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("reloading", 1); tag.putDouble("reloading", 1);
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("id", (Mth.nextDouble(RandomSource.create(), 1, 1919810))); tag.putDouble("id", (Mth.nextDouble(RandomSource.create(), 1, 1919810)));
if (entity instanceof Player _player) player.getCooldowns().addCooldown(player.getMainHandItem().getItem(), 5);
_player.getCooldowns().addCooldown((entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getItem(), 5); tag.putDouble("prepare", 5);
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("prepare", 5); if (!entity.level().isClientSide() && entity.getServer() != null) {
{ entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), entity.level() instanceof ServerLevel ? (ServerLevel) entity.level() : null, 4,
Entity _ent = entity; entity.getName().getString(), entity.getDisplayName(), entity.level().getServer(), entity), "playsound target:marlin_start player @s ~ ~ ~ 100 1");
if (!_ent.level().isClientSide() && _ent.getServer() != null) {
_ent.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, _ent.position(), _ent.getRotationVector(), _ent.level() instanceof ServerLevel ? (ServerLevel) _ent.level() : null, 4,
_ent.getName().getString(), _ent.getDisplayName(), _ent.level().getServer(), _ent), "playsound target:marlin_start player @s ~ ~ ~ 100 1");
} }
} }
} if (player.getMainHandItem().getItem() == TargetModItems.M_870.get()
if ((entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getItem() == TargetModItems.M_870.get() && !(player.getCooldowns().isOnCooldown(player.getMainHandItem().getItem()))
&& !(entity instanceof Player _plrCldCheck531 && _plrCldCheck531.getCooldowns().isOnCooldown((entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getItem())) && tag.getDouble("reloading") == 0
&& (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("reloading") == 0 && tag.getDouble("ammo") < 8
&& (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("ammo") < 8
&& (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).shotgunammo > 0) { && (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).shotgunammo > 0) {
if ((entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("ammo") == 0) { if (tag.getDouble("ammo") == 0) {
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("emptyreload", 1); tag.putDouble("emptyreload", 1);
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("reloading", 1); tag.putDouble("reloading", 1);
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("id", (Mth.nextDouble(RandomSource.create(), 1, 1919810))); tag.putDouble("id", (Mth.nextDouble(RandomSource.create(), 1, 1919810)));
if (entity instanceof Player _player) player.getCooldowns().addCooldown(player.getMainHandItem().getItem(), 36);
_player.getCooldowns().addCooldown((entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getItem(), 36); tag.putDouble("prepare", 36);
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("prepare", 36);
{ if (!entity.level().isClientSide() && entity.getServer() != null) {
Entity _ent = entity; entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), entity.level() instanceof ServerLevel ? (ServerLevel) entity.level() : null, 4,
if (!_ent.level().isClientSide() && _ent.getServer() != null) { entity.getName().getString(), entity.getDisplayName(), entity.level().getServer(), entity), "playsound target:m870_preparealt player @s ~ ~ ~ 100 1");
_ent.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, _ent.position(), _ent.getRotationVector(), _ent.level() instanceof ServerLevel ? (ServerLevel) _ent.level() : null, 4,
_ent.getName().getString(), _ent.getDisplayName(), _ent.level().getServer(), _ent), "playsound target:m870_preparealt player @s ~ ~ ~ 100 1");
}
} }
} else { } else {
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("reloading", 1); tag.putDouble("reloading", 1);
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("id", (Mth.nextDouble(RandomSource.create(), 1, 1919810))); tag.putDouble("id", (Mth.nextDouble(RandomSource.create(), 1, 1919810)));
if (entity instanceof Player _player) if (entity instanceof Player _player)
_player.getCooldowns().addCooldown((entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getItem(), 7); _player.getCooldowns().addCooldown(player.getMainHandItem().getItem(), 7);
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("prepare", 7); tag.putDouble("prepare", 7);
} }
} }
} }

View file

@ -2,15 +2,12 @@ package net.mcreator.target.procedures;
import net.mcreator.target.init.TargetModItems; import net.mcreator.target.init.TargetModItems;
import net.mcreator.target.network.TargetModVariables; import net.mcreator.target.network.TargetModVariables;
import net.minecraft.client.Minecraft;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.tags.ItemTags; import net.minecraft.tags.ItemTags;
import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.GameType;
import net.minecraftforge.event.TickEvent; import net.minecraftforge.event.TickEvent;
import net.minecraftforge.eventbus.api.Event; import net.minecraftforge.eventbus.api.Event;
import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.eventbus.api.SubscribeEvent;
@ -35,26 +32,15 @@ public class PrepareToZoomProcedure {
if (entity == null) if (entity == null)
return; return;
if ((entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).is(ItemTags.create(new ResourceLocation("target:gun"))) if ((entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).is(ItemTags.create(new ResourceLocation("target:gun")))
&& !((entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("reloading") == 1) && !(new Object() { && !((entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("reloading") == 1) &&
public boolean checkGamemode(Entity _ent) { entity instanceof Player player && !player.isSpectator()) {
if (_ent instanceof ServerPlayer _serverPlayer) { if (!(player.getMainHandItem().getItem() == TargetModItems.MINIGUN.get())) {
return _serverPlayer.gameMode.getGameModeForPlayer() == GameType.SPECTATOR;
} else if (_ent.level().isClientSide() && _ent instanceof Player _player) {
return Minecraft.getInstance().getConnection().getPlayerInfo(_player.getGameProfile().getId()) != null
&& Minecraft.getInstance().getConnection().getPlayerInfo(_player.getGameProfile().getId()).getGameMode() == GameType.SPECTATOR;
}
return false;
}
}.checkGamemode(entity)) && !((entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getItem() == TargetModItems.MINIGUN.get())) {
if ((entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).zoom) { if ((entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).zoom) {
entity.setSprinting(false); entity.setSprinting(false);
{
boolean _setval = true;
entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> { entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
capability.zooming = _setval; capability.zooming = true;
capability.syncPlayerVariables(entity); capability.syncPlayerVariables(entity);
}); });
}
if (entity.getPersistentData().getDouble("miaozhunshijian") < 10) { if (entity.getPersistentData().getDouble("miaozhunshijian") < 10) {
entity.getPersistentData().putDouble("miaozhunshijian", (entity.getPersistentData().getDouble("miaozhunshijian") + 1)); entity.getPersistentData().putDouble("miaozhunshijian", (entity.getPersistentData().getDouble("miaozhunshijian") + 1));
} }
@ -63,4 +49,5 @@ public class PrepareToZoomProcedure {
} }
} }
} }
}
} }

View file

@ -1,17 +1,13 @@
package net.mcreator.target.procedures; package net.mcreator.target.procedures;
import net.mcreator.target.entity.ClaymoreEntity; import net.mcreator.target.entity.ClaymoreEntity;
import net.minecraft.client.Minecraft;
import net.minecraft.core.registries.Registries; import net.minecraft.core.registries.Registries;
import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.TamableAnimal;
import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.GameType;
import net.minecraftforge.event.entity.living.LivingAttackEvent; import net.minecraftforge.event.entity.living.LivingAttackEvent;
import net.minecraftforge.eventbus.api.Event; import net.minecraftforge.eventbus.api.Event;
import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.eventbus.api.SubscribeEvent;
@ -35,34 +31,22 @@ public class QuxiaoshanghaiProcedure {
private static void execute(@Nullable Event event, DamageSource damagesource, Entity entity, Entity sourceentity) { private static void execute(@Nullable Event event, DamageSource damagesource, Entity entity, Entity sourceentity) {
if (damagesource == null || entity == null || sourceentity == null) if (damagesource == null || entity == null || sourceentity == null)
return; return;
if (entity instanceof ClaymoreEntity && !(sourceentity == null) && (entity instanceof TamableAnimal _tamEnt ? (Entity) _tamEnt.getOwner() : null) == sourceentity && !(new Object() { if (entity instanceof ClaymoreEntity tamEnt && tamEnt.getOwner() == sourceentity) {
public boolean checkGamemode(Entity _ent) { if (tamEnt.getOwner() instanceof Player player && player.isCreative()) {
if (_ent instanceof ServerPlayer _serverPlayer) { if (entity instanceof ClaymoreEntity _entity && damagesource.is(ResourceKey.create(Registries.DAMAGE_TYPE, new ResourceLocation("target:deleted_mod_element")))) {
return _serverPlayer.gameMode.getGameModeForPlayer() == GameType.CREATIVE; entity.setYRot(sourceentity.getYRot());
} else if (_ent.level().isClientSide() && _ent instanceof Player _player) { entity.setXRot(entity.getXRot());
return Minecraft.getInstance().getConnection().getPlayerInfo(_player.getGameProfile().getId()) != null && Minecraft.getInstance().getConnection().getPlayerInfo(_player.getGameProfile().getId()).getGameMode() == GameType.CREATIVE; entity.setYBodyRot(entity.getYRot());
} entity.setYHeadRot(entity.getYRot());
return false; entity.yRotO = entity.getYRot();
} entity.xRotO = entity.getXRot();
}.checkGamemode((entity instanceof TamableAnimal _tamEnt ? (Entity) _tamEnt.getOwner() : null)))) {
if (entity instanceof ClaymoreEntity && damagesource.is(ResourceKey.create(Registries.DAMAGE_TYPE, new ResourceLocation("target:deleted_mod_element")))) {
{
Entity _ent = entity;
_ent.setYRot(sourceentity.getYRot());
_ent.setXRot(entity.getXRot());
_ent.setYBodyRot(_ent.getYRot());
_ent.setYHeadRot(_ent.getYRot());
_ent.yRotO = _ent.getYRot();
_ent.xRotO = _ent.getXRot();
if (_ent instanceof LivingEntity _entity) {
_entity.yBodyRotO = _entity.getYRot(); _entity.yBodyRotO = _entity.getYRot();
_entity.yHeadRotO = _entity.getYRot(); _entity.yHeadRotO = _entity.getYRot();
} }
}
}
if (event != null && event.isCancelable()) { if (event != null && event.isCancelable()) {
event.setCanceled(true); event.setCanceled(true);
} }
} }
} }
}
} }

View file

@ -33,17 +33,8 @@ public class QuxiaowafangkuaiProcedure {
private static void execute(@Nullable Event event, Entity entity) { private static void execute(@Nullable Event event, Entity entity) {
if (entity == null) if (entity == null)
return; return;
if (new Object() { if (entity instanceof Player player && !player.isCreative()) {
public boolean checkGamemode(Entity _ent) { if (player.getMainHandItem().getItem() == TargetModItems.LIGHT_SABER.get()) {
if (_ent instanceof ServerPlayer _serverPlayer) {
return _serverPlayer.gameMode.getGameModeForPlayer() == GameType.CREATIVE;
} else if (_ent.level().isClientSide() && _ent instanceof Player _player) {
return Minecraft.getInstance().getConnection().getPlayerInfo(_player.getGameProfile().getId()) != null && Minecraft.getInstance().getConnection().getPlayerInfo(_player.getGameProfile().getId()).getGameMode() == GameType.CREATIVE;
}
return false;
}
}.checkGamemode(entity)) {
if ((entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getItem() == TargetModItems.LIGHT_SABER.get()) {
if (event != null && event.isCancelable()) { if (event != null && event.isCancelable()) {
event.setCanceled(true); event.setCanceled(true);
} }

View file

@ -2,23 +2,18 @@ package net.mcreator.target.procedures;
import net.mcreator.target.init.TargetModEntities; import net.mcreator.target.init.TargetModEntities;
import net.mcreator.target.init.TargetModItems; import net.mcreator.target.init.TargetModItems;
import net.minecraft.client.Minecraft;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionHand;
import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.MobSpawnType; import net.minecraft.world.entity.MobSpawnType;
import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.GameType;
import net.minecraft.world.level.LevelAccessor; import net.minecraft.world.level.LevelAccessor;
public class RengchumortarProcedure { public class RengchumortarProcedure {
public static void execute(LevelAccessor world, double x, double y, double z, Entity entity) { public static void execute(LevelAccessor world, double x, double y, double z, Entity entity) {
if (entity == null) if (entity == null) return;
return;
if (world instanceof ServerLevel _level) { if (world instanceof ServerLevel _level) {
Entity entityToSpawn = TargetModEntities.MORTAR.get().spawn(_level, BlockPos.containing(x + 1.5 * entity.getLookAngle().x, y, z + 1.5 * entity.getLookAngle().z), MobSpawnType.MOB_SUMMONED); Entity entityToSpawn = TargetModEntities.MORTAR.get().spawn(_level, BlockPos.containing(x + 1.5 * entity.getLookAngle().x, y, z + 1.5 * entity.getLookAngle().z), MobSpawnType.MOB_SUMMONED);
if (entityToSpawn != null) { if (entityToSpawn != null) {
@ -29,22 +24,10 @@ public class RengchumortarProcedure {
entityToSpawn.setDeltaMovement(0, 0, 0); entityToSpawn.setDeltaMovement(0, 0, 0);
} }
} }
if (!(new Object() { if (entity instanceof Player player && !player.isCreative()) {
public boolean checkGamemode(Entity _ent) {
if (_ent instanceof ServerPlayer _serverPlayer) {
return _serverPlayer.gameMode.getGameModeForPlayer() == GameType.CREATIVE;
} else if (_ent.level().isClientSide() && _ent instanceof Player _player) {
return Minecraft.getInstance().getConnection().getPlayerInfo(_player.getGameProfile().getId()) != null && Minecraft.getInstance().getConnection().getPlayerInfo(_player.getGameProfile().getId()).getGameMode() == GameType.CREATIVE;
}
return false;
}
}.checkGamemode(entity))) {
if (entity instanceof Player _player) {
ItemStack _stktoremove = new ItemStack(TargetModItems.MORTAR_DEPOLYER.get()); ItemStack _stktoremove = new ItemStack(TargetModItems.MORTAR_DEPOLYER.get());
_player.getInventory().clearOrCountMatchingItems(p -> _stktoremove.getItem() == p.getItem(), 1, _player.inventoryMenu.getCraftSlots()); player.getInventory().clearOrCountMatchingItems(p -> _stktoremove.getItem() == p.getItem(), 1, player.inventoryMenu.getCraftSlots());
player.swing(InteractionHand.MAIN_HAND, true);
} }
} }
if (entity instanceof LivingEntity _entity)
_entity.swing(InteractionHand.MAIN_HAND, true);
}
} }

View file

@ -1,77 +1,36 @@
package net.mcreator.target.procedures; package net.mcreator.target.procedures;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.GameType;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.entity.projectile.Projectile;
import net.minecraft.world.entity.projectile.AbstractArrow;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.Entity;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.CommandSource;
import net.minecraft.client.Minecraft;
import net.mcreator.target.network.TargetModVariables;
import net.mcreator.target.init.TargetModItems;
import net.mcreator.target.init.TargetModEntities;
import net.mcreator.target.init.TargetModAttributes;
import net.mcreator.target.entity.RpgRocketEntity; import net.mcreator.target.entity.RpgRocketEntity;
import net.mcreator.target.init.TargetModAttributes;
import net.mcreator.target.init.TargetModEntities;
import net.mcreator.target.init.TargetModItems;
import net.mcreator.target.network.TargetModVariables;
import net.minecraft.commands.CommandSource;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.entity.projectile.AbstractArrow;
import net.minecraft.world.entity.projectile.Projectile;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
public class RpgfireProcedure { public class RpgfireProcedure {
public static void execute(Entity entity) { public static void execute(Entity entity) {
if (entity == null) if (entity == null) return;
return; if (entity instanceof Player player && !player.isSpectator()) {
ItemStack usehand = ItemStack.EMPTY; ItemStack usehand = player.getMainHandItem();
if (!(new Object() {
public boolean checkGamemode(Entity _ent) {
if (_ent instanceof ServerPlayer _serverPlayer) {
return _serverPlayer.gameMode.getGameModeForPlayer() == GameType.SPECTATOR;
} else if (_ent.level().isClientSide() && _ent instanceof Player _player) {
return Minecraft.getInstance().getConnection().getPlayerInfo(_player.getGameProfile().getId()) != null && Minecraft.getInstance().getConnection().getPlayerInfo(_player.getGameProfile().getId()).getGameMode() == GameType.SPECTATOR;
}
return false;
}
}.checkGamemode(entity))) {
usehand = (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY);
if (usehand.getItem() == TargetModItems.RPG.get() && usehand.getOrCreateTag().getDouble("reloading") == 0 && !(entity instanceof Player _plrCldCheck4 && _plrCldCheck4.getCooldowns().isOnCooldown(usehand.getItem())) if (usehand.getItem() == TargetModItems.RPG.get() && usehand.getOrCreateTag().getDouble("reloading") == 0 && !(entity instanceof Player _plrCldCheck4 && _plrCldCheck4.getCooldowns().isOnCooldown(usehand.getItem()))
&& usehand.getOrCreateTag().getDouble("ammo") > 0) { && usehand.getOrCreateTag().getDouble("ammo") > 0) {
if (Math.random() < 0.5) {
{
double _setval = -1;
entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> { entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
capability.recoilhorizon = _setval; capability.recoilhorizon = Math.random() < 0.5 ? -1 : 1;
capability.recoil = 0.1;
capability.firing = 1;
capability.syncPlayerVariables(entity); capability.syncPlayerVariables(entity);
}); });
}
} else { Level projectileLevel = entity.level();
{
double _setval = 1;
entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
capability.recoilhorizon = _setval;
capability.syncPlayerVariables(entity);
});
}
}
{
double _setval = 0.1;
entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
capability.recoil = _setval;
capability.syncPlayerVariables(entity);
});
}
{
double _setval = 1;
entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
capability.firing = _setval;
capability.syncPlayerVariables(entity);
});
}
{
Entity _shootFrom = entity;
Level projectileLevel = _shootFrom.level();
if (!projectileLevel.isClientSide()) { if (!projectileLevel.isClientSide()) {
Projectile _entityToSpawn = new Object() { Projectile _entityToSpawn = new Object() {
public Projectile getArrow(Level level, Entity shooter, float damage, int knockback) { public Projectile getArrow(Level level, Entity shooter, float damage, int knockback) {
@ -83,33 +42,26 @@ public class RpgfireProcedure {
return entityToSpawn; return entityToSpawn;
} }
}.getArrow(projectileLevel, entity, (float) ((usehand.getOrCreateTag().getDouble("damage") / usehand.getOrCreateTag().getDouble("velocity")) * (1 + 0.05 * usehand.getOrCreateTag().getDouble("level"))), 0); }.getArrow(projectileLevel, entity, (float) ((usehand.getOrCreateTag().getDouble("damage") / usehand.getOrCreateTag().getDouble("velocity")) * (1 + 0.05 * usehand.getOrCreateTag().getDouble("level"))), 0);
_entityToSpawn.setPos(_shootFrom.getX(), _shootFrom.getEyeY() - 0.1, _shootFrom.getZ()); _entityToSpawn.setPos(entity.getX(), entity.getEyeY() - 0.1, entity.getZ());
_entityToSpawn.shoot(_shootFrom.getLookAngle().x, _shootFrom.getLookAngle().y, _shootFrom.getLookAngle().z, (float) usehand.getOrCreateTag().getDouble("velocity"), _entityToSpawn.shoot(entity.getLookAngle().x, entity.getLookAngle().y, entity.getLookAngle().z, (float) usehand.getOrCreateTag().getDouble("velocity"),
(float) ((LivingEntity) entity).getAttribute(TargetModAttributes.SPREAD.get()).getBaseValue()); (float) ((LivingEntity) entity).getAttribute(TargetModAttributes.SPREAD.get()).getBaseValue());
projectileLevel.addFreshEntity(_entityToSpawn); projectileLevel.addFreshEntity(_entityToSpawn);
} }
}
{ if (!entity.level().isClientSide() && entity.getServer() != null) {
Entity _ent = entity; entity.getServer().getCommands().performPrefixedCommand(
if (!_ent.level().isClientSide() && _ent.getServer() != null) { new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), entity.level() instanceof ServerLevel ? (ServerLevel) entity.level() : null, 4, entity.getName().getString(), entity.getDisplayName(),
_ent.getServer().getCommands().performPrefixedCommand( entity.level().getServer(), entity),
new CommandSourceStack(CommandSource.NULL, _ent.position(), _ent.getRotationVector(), _ent.level() instanceof ServerLevel ? (ServerLevel) _ent.level() : null, 4, _ent.getName().getString(), _ent.getDisplayName(),
_ent.level().getServer(), _ent),
("particle minecraft:cloud" + (" " + (entity.getX() + 1.8 * entity.getLookAngle().x)) + (" " + (entity.getY() + entity.getBbHeight() - 0.1 + 1.8 * entity.getLookAngle().y)) ("particle minecraft:cloud" + (" " + (entity.getX() + 1.8 * entity.getLookAngle().x)) + (" " + (entity.getY() + entity.getBbHeight() - 0.1 + 1.8 * entity.getLookAngle().y))
+ (" " + (entity.getZ() + 1.8 * entity.getLookAngle().z)) + " 0.4 0.4 0.4 0.005 30 force @s")); + (" " + (entity.getZ() + 1.8 * entity.getLookAngle().z)) + " 0.4 0.4 0.4 0.005 30 force @s"));
} }
}
if (usehand.getOrCreateTag().getDouble("ammo") == 1) { if (usehand.getOrCreateTag().getDouble("ammo") == 1) {
usehand.getOrCreateTag().putDouble("empty", 1); usehand.getOrCreateTag().putDouble("empty", 1);
} }
if (entity instanceof Player _player) player.getCooldowns().addCooldown(usehand.getItem(), 10);
_player.getCooldowns().addCooldown(usehand.getItem(), 10); if (!entity.level().isClientSide() && entity.getServer() != null) {
{ entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), entity.level() instanceof ServerLevel ? (ServerLevel) entity.level() : null, 4,
Entity _ent = entity; entity.getName().getString(), entity.getDisplayName(), entity.level().getServer(), entity), "playsound target:rpg7_fire player @a ~ ~ ~ 3 1");
if (!_ent.level().isClientSide() && _ent.getServer() != null) {
_ent.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, _ent.position(), _ent.getRotationVector(), _ent.level() instanceof ServerLevel ? (ServerLevel) _ent.level() : null, 4,
_ent.getName().getString(), _ent.getDisplayName(), _ent.level().getServer(), _ent), "playsound target:rpg7_fire player @a ~ ~ ~ 3 1");
}
} }
usehand.getOrCreateTag().putDouble("fireanim", 2); usehand.getOrCreateTag().putDouble("fireanim", 2);
usehand.getOrCreateTag().putDouble("ammo", (usehand.getOrCreateTag().getDouble("ammo") - 1)); usehand.getOrCreateTag().putDouble("ammo", (usehand.getOrCreateTag().getDouble("ammo") - 1));

View file

@ -1,65 +1,40 @@
package net.mcreator.target.procedures; package net.mcreator.target.procedures;
import net.mcreator.target.init.TargetModItems; import net.mcreator.target.init.TargetModItems;
import net.minecraft.client.Minecraft;
import net.minecraft.commands.CommandSource; import net.minecraft.commands.CommandSource;
import net.minecraft.commands.CommandSourceStack; import net.minecraft.commands.CommandSourceStack;
import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.GameType;
public class RpkfireProcedure { public class RpkfireProcedure {
public static void execute(Entity entity) { public static void execute(Entity entity) {
if (entity == null) if (entity == null) return;
return; if (entity instanceof Player player && !player.isSpectator()) {
ItemStack usehand = ItemStack.EMPTY; ItemStack usehand = player.getMainHandItem();
if (!(new Object() { if (usehand.getItem() != TargetModItems.RPK.get()) return;
public boolean checkGamemode(Entity _ent) {
if (_ent instanceof ServerPlayer _serverPlayer) {
return _serverPlayer.gameMode.getGameModeForPlayer() == GameType.SPECTATOR;
} else if (_ent.level().isClientSide() && _ent instanceof Player _player) {
return Minecraft.getInstance().getConnection().getPlayerInfo(_player.getGameProfile().getId()) != null && Minecraft.getInstance().getConnection().getPlayerInfo(_player.getGameProfile().getId()).getGameMode() == GameType.SPECTATOR;
}
return false;
}
}.checkGamemode(entity))) {
usehand = (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY);
if (usehand.getItem() == TargetModItems.RPK.get()) {
if (usehand.getOrCreateTag().getDouble("firemode") == 0) { if (usehand.getOrCreateTag().getDouble("firemode") == 0) {
if (usehand.getOrCreateTag().getDouble("reloading") == 0 && usehand.getOrCreateTag().getDouble("ammo") > 0 && !(entity instanceof Player _plrCldCheck6 && _plrCldCheck6.getCooldowns().isOnCooldown(usehand.getItem()))) { if (usehand.getOrCreateTag().getDouble("reloading") == 0 && usehand.getOrCreateTag().getDouble("ammo") > 0 && !(entity instanceof Player _plrCldCheck6 && _plrCldCheck6.getCooldowns().isOnCooldown(usehand.getItem()))) {
if (entity instanceof Player _player) player.getCooldowns().addCooldown(usehand.getItem(), 2);
_player.getCooldowns().addCooldown(usehand.getItem(), 2);
BulletFireNormalProcedure.execute(entity); BulletFireNormalProcedure.execute(entity);
AkDsProcedure.execute(entity); AkDsProcedure.execute(entity);
{
if (!entity.level().isClientSide() && entity.getServer() != null) {
entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), entity.level() instanceof ServerLevel ? (ServerLevel) entity.level() : null, 4,
entity.getName().getString(), entity.getDisplayName(), entity.level().getServer(), entity), "playsound target:rpk_fire1p player @s ~ ~ ~ 2 1");
}
}
{
if (!entity.level().isClientSide() && entity.getServer() != null) {
entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), entity.level() instanceof ServerLevel ? (ServerLevel) entity.level() : null, 4,
entity.getName().getString(), entity.getDisplayName(), entity.level().getServer(), entity), "playsound target:rpkfire player @a ~ ~ ~ 4 1");
}
}
{
if (!entity.level().isClientSide() && entity.getServer() != null) {
entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), entity.level() instanceof ServerLevel ? (ServerLevel) entity.level() : null, 4,
entity.getName().getString(), entity.getDisplayName(), entity.level().getServer(), entity), "stopsound @s player target:rpkfire");
}
}
usehand.getOrCreateTag().putDouble("fireanim", 2); usehand.getOrCreateTag().putDouble("fireanim", 2);
usehand.getOrCreateTag().putDouble("ammo", (usehand.getOrCreateTag().getDouble("ammo") - 1)); usehand.getOrCreateTag().putDouble("ammo", (usehand.getOrCreateTag().getDouble("ammo") - 1));
if (!entity.level().isClientSide() && entity.getServer() == null) return;
entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), entity.level() instanceof ServerLevel ? (ServerLevel) entity.level() : null, 4,
entity.getName().getString(), entity.getDisplayName(), entity.level().getServer(), entity), "playsound target:rpk_fire1p player @s ~ ~ ~ 2 1");
entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), entity.level() instanceof ServerLevel ? (ServerLevel) entity.level() : null, 4,
entity.getName().getString(), entity.getDisplayName(), entity.level().getServer(), entity), "playsound target:rpkfire player @a ~ ~ ~ 4 1");
entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), entity.level() instanceof ServerLevel ? (ServerLevel) entity.level() : null, 4,
entity.getName().getString(), entity.getDisplayName(), entity.level().getServer(), entity), "stopsound @s player target:rpkfire");
} }
} else if (usehand.getOrCreateTag().getDouble("firemode") == 2) { } else if (usehand.getOrCreateTag().getDouble("firemode") == 2) {
entity.getPersistentData().putDouble("firing", 1); entity.getPersistentData().putDouble("firing", 1);
} }
} }
} }
}
} }

View file

@ -1,47 +1,29 @@
package net.mcreator.target.procedures; package net.mcreator.target.procedures;
import net.minecraft.client.Minecraft;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.Mob; import net.minecraft.world.entity.Mob;
import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.GameType;
import net.minecraft.world.level.LevelAccessor; import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.AABB;
import net.minecraft.world.phys.Vec3; import net.minecraft.world.phys.Vec3;
import java.util.Comparator; import java.util.Comparator;
import java.util.List;
public class SenpaiDangShiTiGengXinKeShiProcedure { public class SenpaiDangShiTiGengXinKeShiProcedure {
public static void execute(LevelAccessor world, double x, double y, double z, Entity entity) { public static void execute(LevelAccessor world, double x, double y, double z, Entity entity) {
if (entity == null) if (entity == null) return;
return; double target;
double target = 0;
entity.getPersistentData().putDouble("findtarget", (entity.getPersistentData().getDouble("findtarget") + 1)); entity.getPersistentData().putDouble("findtarget", (entity.getPersistentData().getDouble("findtarget") + 1));
target = entity.getPersistentData().getDouble("findtarget"); target = entity.getPersistentData().getDouble("findtarget");
if (target == 1) { if (target == 1 && entity instanceof Mob mob) {
{
final Vec3 _center = new Vec3(x, y, z); final Vec3 _center = new Vec3(x, y, z);
List<Entity> _entfound = world.getEntitiesOfClass(Entity.class, new AABB(_center, _center).inflate(1024 / 2d), e -> true).stream().sorted(Comparator.comparingDouble(_entcnd -> _entcnd.distanceToSqr(_center))).toList(); world.getEntitiesOfClass(Entity.class, new AABB(_center, _center).inflate(1024 / 2d), e -> true)
for (Entity entityiterator : _entfound) { .stream()
if (entityiterator instanceof Player && !(new Object() { .sorted(Comparator.comparingDouble(e -> e.distanceToSqr(_center)))
public boolean checkGamemode(Entity _ent) { .filter(e -> e instanceof Player player && !player.isCreative())
if (_ent instanceof ServerPlayer _serverPlayer) { .forEach(e -> mob.setTarget((LivingEntity) e));
return _serverPlayer.gameMode.getGameModeForPlayer() == GameType.CREATIVE;
} else if (_ent.level().isClientSide() && _ent instanceof Player _player) {
return Minecraft.getInstance().getConnection().getPlayerInfo(_player.getGameProfile().getId()) != null
&& Minecraft.getInstance().getConnection().getPlayerInfo(_player.getGameProfile().getId()).getGameMode() == GameType.CREATIVE;
}
return false;
}
}.checkGamemode(entityiterator))) {
if (entity instanceof Mob _entity && entityiterator instanceof LivingEntity _ent)
_entity.setTarget(_ent);
}
}
}
} }
if (target >= 100) { if (target >= 100) {
entity.getPersistentData().putDouble("findtarget", 0); entity.getPersistentData().putDouble("findtarget", 0);

View file

@ -2,33 +2,18 @@ package net.mcreator.target.procedures;
import net.mcreator.target.init.TargetModItems; import net.mcreator.target.init.TargetModItems;
import net.mcreator.target.network.TargetModVariables; import net.mcreator.target.network.TargetModVariables;
import net.minecraft.client.Minecraft;
import net.minecraft.commands.CommandSource; import net.minecraft.commands.CommandSource;
import net.minecraft.commands.CommandSourceStack; import net.minecraft.commands.CommandSourceStack;
import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.GameType;
public class SentinelFireProcedure { public class SentinelFireProcedure {
public static void execute(Entity entity) { public static void execute(Entity entity) {
if (entity == null) if (entity == null) return;
return; if (entity instanceof Player player && !player.isSpectator()) {
ItemStack usehand = ItemStack.EMPTY; ItemStack usehand = player.getMainHandItem();
if (!(new Object() {
public boolean checkGamemode(Entity _ent) {
if (_ent instanceof ServerPlayer _serverPlayer) {
return _serverPlayer.gameMode.getGameModeForPlayer() == GameType.SPECTATOR;
} else if (_ent.level().isClientSide() && _ent instanceof Player _player) {
return Minecraft.getInstance().getConnection().getPlayerInfo(_player.getGameProfile().getId()) != null && Minecraft.getInstance().getConnection().getPlayerInfo(_player.getGameProfile().getId()).getGameMode() == GameType.SPECTATOR;
}
return false;
}
}.checkGamemode(entity))) {
usehand = (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY);
if (usehand.getItem() == TargetModItems.SENTINEL.get() && usehand.getOrCreateTag().getDouble("reloading") == 0 && !(entity instanceof Player _plrCldCheck4 && _plrCldCheck4.getCooldowns().isOnCooldown(usehand.getItem())) if (usehand.getItem() == TargetModItems.SENTINEL.get() && usehand.getOrCreateTag().getDouble("reloading") == 0 && !(entity instanceof Player _plrCldCheck4 && _plrCldCheck4.getCooldowns().isOnCooldown(usehand.getItem()))
&& usehand.getOrCreateTag().getDouble("ammo") > 0) { && usehand.getOrCreateTag().getDouble("ammo") > 0) {
if (usehand.getOrCreateTag().getDouble("power") > 0) { if (usehand.getOrCreateTag().getDouble("power") > 0) {
@ -37,19 +22,11 @@ public class SentinelFireProcedure {
} else { } else {
usehand.getOrCreateTag().putDouble("firing", 24); usehand.getOrCreateTag().putDouble("firing", 24);
} }
{ if (!entity.level().isClientSide() && entity.getServer() != null) {
Entity _ent = entity; entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), entity.level() instanceof ServerLevel ? (ServerLevel) entity.level() : null, 4,
if (!_ent.level().isClientSide() && _ent.getServer() != null) { entity.getName().getString(), entity.getDisplayName(), entity.level().getServer(), entity), "playsound target:sentinelfirecharge1 player @s ~ ~ ~ 100 1");
_ent.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, _ent.position(), _ent.getRotationVector(), _ent.level() instanceof ServerLevel ? (ServerLevel) _ent.level() : null, 4, entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), entity.level() instanceof ServerLevel ? (ServerLevel) entity.level() : null, 4,
_ent.getName().getString(), _ent.getDisplayName(), _ent.level().getServer(), _ent), "playsound target:sentinelfirecharge1 player @s ~ ~ ~ 100 1"); entity.getName().getString(), entity.getDisplayName(), entity.level().getServer(), entity), "playsound target:sentinelfirecharge3 player @a ~ ~ ~ 4 1");
}
}
{
Entity _ent = entity;
if (!_ent.level().isClientSide() && _ent.getServer() != null) {
_ent.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, _ent.position(), _ent.getRotationVector(), _ent.level() instanceof ServerLevel ? (ServerLevel) _ent.level() : null, 4,
_ent.getName().getString(), _ent.getDisplayName(), _ent.level().getServer(), _ent), "playsound target:sentinelfirecharge3 player @a ~ ~ ~ 4 1");
}
} }
if (usehand.getOrCreateTag().getDouble("power") > 20) { if (usehand.getOrCreateTag().getDouble("power") > 20) {
usehand.getOrCreateTag().putDouble("power", (usehand.getOrCreateTag().getDouble("power") - 20)); usehand.getOrCreateTag().putDouble("power", (usehand.getOrCreateTag().getDouble("power") - 20));
@ -62,38 +39,22 @@ public class SentinelFireProcedure {
} else { } else {
usehand.getOrCreateTag().putDouble("firing", 24); usehand.getOrCreateTag().putDouble("firing", 24);
} }
{ if (!entity.level().isClientSide() && entity.getServer() != null) {
Entity _ent = entity; entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), entity.level() instanceof ServerLevel ? (ServerLevel) entity.level() : null, 4,
if (!_ent.level().isClientSide() && _ent.getServer() != null) { entity.getName().getString(), entity.getDisplayName(), entity.level().getServer(), entity), "playsound target:sentinelfire1 player @s ~ ~ ~ 100 1");
_ent.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, _ent.position(), _ent.getRotationVector(), _ent.level() instanceof ServerLevel ? (ServerLevel) _ent.level() : null, 4, entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), entity.level() instanceof ServerLevel ? (ServerLevel) entity.level() : null, 4,
_ent.getName().getString(), _ent.getDisplayName(), _ent.level().getServer(), _ent), "playsound target:sentinelfire1 player @s ~ ~ ~ 100 1"); entity.getName().getString(), entity.getDisplayName(), entity.level().getServer(), entity), "playsound target:sentinelfire3 player @a ~ ~ ~ 4 1");
}
}
{
Entity _ent = entity;
if (!_ent.level().isClientSide() && _ent.getServer() != null) {
_ent.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, _ent.position(), _ent.getRotationVector(), _ent.level() instanceof ServerLevel ? (ServerLevel) _ent.level() : null, 4,
_ent.getName().getString(), _ent.getDisplayName(), _ent.level().getServer(), _ent), "playsound target:sentinelfire3 player @a ~ ~ ~ 4 1");
}
} }
} }
BulletFireNormalProcedure.execute(entity); BulletFireNormalProcedure.execute(entity);
usehand.getOrCreateTag().putDouble("crot", 20); usehand.getOrCreateTag().putDouble("crot", 20);
if (entity instanceof Player _player) player.getCooldowns().addCooldown(usehand.getItem(), 23);
_player.getCooldowns().addCooldown(usehand.getItem(), 23);
{ if (!entity.level().isClientSide() && entity.getServer() != null) {
Entity _ent = entity; entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), entity.level() instanceof ServerLevel ? (ServerLevel) entity.level() : null, 4,
if (!_ent.level().isClientSide() && _ent.getServer() != null) { entity.getName().getString(), entity.getDisplayName(), entity.level().getServer(), entity), "stopsound @s player target:sentinelfire3");
_ent.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, _ent.position(), _ent.getRotationVector(), _ent.level() instanceof ServerLevel ? (ServerLevel) _ent.level() : null, 4, entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), entity.level() instanceof ServerLevel ? (ServerLevel) entity.level() : null, 4,
_ent.getName().getString(), _ent.getDisplayName(), _ent.level().getServer(), _ent), "stopsound @s player target:sentinelfire3"); entity.getName().getString(), entity.getDisplayName(), entity.level().getServer(), entity), "stopsound @s player target:sentinelfirecharge3");
}
}
{
Entity _ent = entity;
if (!_ent.level().isClientSide() && _ent.getServer() != null) {
_ent.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, _ent.position(), _ent.getRotationVector(), _ent.level() instanceof ServerLevel ? (ServerLevel) _ent.level() : null, 4,
_ent.getName().getString(), _ent.getDisplayName(), _ent.level().getServer(), _ent), "stopsound @s player target:sentinelfirecharge3");
}
} }
usehand.getOrCreateTag().putDouble("ammo", (usehand.getOrCreateTag().getDouble("ammo") - 1)); usehand.getOrCreateTag().putDouble("ammo", (usehand.getOrCreateTag().getDouble("ammo") - 1));
usehand.getOrCreateTag().putDouble("fireanim", 2); usehand.getOrCreateTag().putDouble("fireanim", 2);

View file

@ -1,65 +1,36 @@
package net.mcreator.target.procedures; package net.mcreator.target.procedures;
import net.mcreator.target.init.TargetModItems; import net.mcreator.target.init.TargetModItems;
import net.minecraft.client.Minecraft;
import net.minecraft.commands.CommandSource; import net.minecraft.commands.CommandSource;
import net.minecraft.commands.CommandSourceStack; import net.minecraft.commands.CommandSourceStack;
import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.GameType;
public class SksfireProcedure { public class SksfireProcedure {
public static void execute(Entity entity) { public static void execute(Entity entity) {
if (entity == null) if (entity == null) return;
return; if (entity instanceof Player player && !player.isSpectator()) {
ItemStack usehand = ItemStack.EMPTY; ItemStack usehand = player.getMainHandItem();
if (!(new Object() {
public boolean checkGamemode(Entity _ent) {
if (_ent instanceof ServerPlayer _serverPlayer) {
return _serverPlayer.gameMode.getGameModeForPlayer() == GameType.SPECTATOR;
} else if (_ent.level().isClientSide() && _ent instanceof Player _player) {
return Minecraft.getInstance().getConnection().getPlayerInfo(_player.getGameProfile().getId()) != null && Minecraft.getInstance().getConnection().getPlayerInfo(_player.getGameProfile().getId()).getGameMode() == GameType.SPECTATOR;
}
return false;
}
}.checkGamemode(entity))) {
usehand = (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY);
if (usehand.getItem() == TargetModItems.SKS.get() && usehand.getOrCreateTag().getDouble("reloading") == 0 && !(entity instanceof Player _plrCldCheck4 && _plrCldCheck4.getCooldowns().isOnCooldown(usehand.getItem())) if (usehand.getItem() == TargetModItems.SKS.get() && usehand.getOrCreateTag().getDouble("reloading") == 0 && !(entity instanceof Player _plrCldCheck4 && _plrCldCheck4.getCooldowns().isOnCooldown(usehand.getItem()))
&& usehand.getOrCreateTag().getDouble("ammo") > 0) { && usehand.getOrCreateTag().getDouble("ammo") > 0) {
BulletFireNormalProcedure.execute(entity); BulletFireNormalProcedure.execute(entity);
SksDsProcedure.execute(entity); SksDsProcedure.execute(entity);
{
Entity _ent = entity; if (!entity.level().isClientSide() && entity.getServer() != null) {
if (!_ent.level().isClientSide() && _ent.getServer() != null) { entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), entity.level() instanceof ServerLevel ? (ServerLevel) entity.level() : null, 4,
_ent.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, _ent.position(), _ent.getRotationVector(), _ent.level() instanceof ServerLevel ? (ServerLevel) _ent.level() : null, 4, entity.getName().getString(), entity.getDisplayName(), entity.level().getServer(), entity), "playsound target:ak_fire_1p player @s ~ ~ ~ 2 1");
_ent.getName().getString(), _ent.getDisplayName(), _ent.level().getServer(), _ent), "playsound target:ak_fire_1p player @s ~ ~ ~ 2 1"); entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), entity.level() instanceof ServerLevel ? (ServerLevel) entity.level() : null, 4,
} entity.getName().getString(), entity.getDisplayName(), entity.level().getServer(), entity), "playsound target:ak_fire_3p player @a ~ ~ ~ 5 1");
} entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), entity.level() instanceof ServerLevel ? (ServerLevel) entity.level() : null, 4,
{ entity.getName().getString(), entity.getDisplayName(), entity.level().getServer(), entity), "stopsound @s player target:ak_fire_3p");
Entity _ent = entity;
if (!_ent.level().isClientSide() && _ent.getServer() != null) {
_ent.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, _ent.position(), _ent.getRotationVector(), _ent.level() instanceof ServerLevel ? (ServerLevel) _ent.level() : null, 4,
_ent.getName().getString(), _ent.getDisplayName(), _ent.level().getServer(), _ent), "playsound target:ak_fire_3p player @a ~ ~ ~ 5 1");
}
}
{
Entity _ent = entity;
if (!_ent.level().isClientSide() && _ent.getServer() != null) {
_ent.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, _ent.position(), _ent.getRotationVector(), _ent.level() instanceof ServerLevel ? (ServerLevel) _ent.level() : null, 4,
_ent.getName().getString(), _ent.getDisplayName(), _ent.level().getServer(), _ent), "stopsound @s player target:ak_fire_3p");
}
} }
if (usehand.getOrCreateTag().getDouble("ammo") == 1) { if (usehand.getOrCreateTag().getDouble("ammo") == 1) {
if (entity instanceof Player _player) player.getCooldowns().addCooldown(usehand.getItem(), 10);
_player.getCooldowns().addCooldown(usehand.getItem(), 10);
usehand.getOrCreateTag().putDouble("gj", 1); usehand.getOrCreateTag().putDouble("gj", 1);
} else { } else {
if (entity instanceof Player _player) player.getCooldowns().addCooldown(usehand.getItem(), 3);
_player.getCooldowns().addCooldown(usehand.getItem(), 3);
} }
usehand.getOrCreateTag().putDouble("fireanim", 2); usehand.getOrCreateTag().putDouble("fireanim", 2);
usehand.getOrCreateTag().putDouble("ammo", (usehand.getOrCreateTag().getDouble("ammo") - 1)); usehand.getOrCreateTag().putDouble("ammo", (usehand.getOrCreateTag().getDouble("ammo") - 1));

View file

@ -1,65 +1,36 @@
package net.mcreator.target.procedures; package net.mcreator.target.procedures;
import net.mcreator.target.init.TargetModItems; import net.mcreator.target.init.TargetModItems;
import net.minecraft.client.Minecraft;
import net.minecraft.commands.CommandSource; import net.minecraft.commands.CommandSource;
import net.minecraft.commands.CommandSourceStack; import net.minecraft.commands.CommandSourceStack;
import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.GameType;
public class SvdfireProcedure { public class SvdfireProcedure {
public static void execute(Entity entity) { public static void execute(Entity entity) {
if (entity == null) if (entity == null) return;
return; if (entity instanceof Player player && !player.isSpectator()) {
ItemStack usehand = ItemStack.EMPTY; ItemStack usehand = player.getMainHandItem();
if (!(new Object() {
public boolean checkGamemode(Entity _ent) {
if (_ent instanceof ServerPlayer _serverPlayer) {
return _serverPlayer.gameMode.getGameModeForPlayer() == GameType.SPECTATOR;
} else if (_ent.level().isClientSide() && _ent instanceof Player _player) {
return Minecraft.getInstance().getConnection().getPlayerInfo(_player.getGameProfile().getId()) != null && Minecraft.getInstance().getConnection().getPlayerInfo(_player.getGameProfile().getId()).getGameMode() == GameType.SPECTATOR;
}
return false;
}
}.checkGamemode(entity))) {
usehand = (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY);
if (usehand.getItem() == TargetModItems.SVD.get() && usehand.getOrCreateTag().getDouble("reloading") == 0 && !(entity instanceof Player _plrCldCheck4 && _plrCldCheck4.getCooldowns().isOnCooldown(usehand.getItem())) if (usehand.getItem() == TargetModItems.SVD.get() && usehand.getOrCreateTag().getDouble("reloading") == 0 && !(entity instanceof Player _plrCldCheck4 && _plrCldCheck4.getCooldowns().isOnCooldown(usehand.getItem()))
&& usehand.getOrCreateTag().getDouble("ammo") > 0) { && usehand.getOrCreateTag().getDouble("ammo") > 0) {
BulletFireNormalProcedure.execute(entity); BulletFireNormalProcedure.execute(entity);
SvdDsProcedure.execute(entity); SvdDsProcedure.execute(entity);
{
Entity _ent = entity; if (!entity.level().isClientSide() && entity.getServer() != null) {
if (!_ent.level().isClientSide() && _ent.getServer() != null) { entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), entity.level() instanceof ServerLevel ? (ServerLevel) entity.level() : null, 4,
_ent.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, _ent.position(), _ent.getRotationVector(), _ent.level() instanceof ServerLevel ? (ServerLevel) _ent.level() : null, 4, entity.getName().getString(), entity.getDisplayName(), entity.level().getServer(), entity), "playsound target:svdfire1p player @s ~ ~ ~ 2 1");
_ent.getName().getString(), _ent.getDisplayName(), _ent.level().getServer(), _ent), "playsound target:svdfire1p player @s ~ ~ ~ 2 1"); entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), entity.level() instanceof ServerLevel ? (ServerLevel) entity.level() : null, 4,
} entity.getName().getString(), entity.getDisplayName(), entity.level().getServer(), entity), "playsound target:svdfire3p player @a ~ ~ ~ 6 1");
} entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), entity.level() instanceof ServerLevel ? (ServerLevel) entity.level() : null, 4,
{ entity.getName().getString(), entity.getDisplayName(), entity.level().getServer(), entity), "stopsound @s player target:svdfire3p");
Entity _ent = entity;
if (!_ent.level().isClientSide() && _ent.getServer() != null) {
_ent.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, _ent.position(), _ent.getRotationVector(), _ent.level() instanceof ServerLevel ? (ServerLevel) _ent.level() : null, 4,
_ent.getName().getString(), _ent.getDisplayName(), _ent.level().getServer(), _ent), "playsound target:svdfire3p player @a ~ ~ ~ 6 1");
}
}
{
Entity _ent = entity;
if (!_ent.level().isClientSide() && _ent.getServer() != null) {
_ent.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, _ent.position(), _ent.getRotationVector(), _ent.level() instanceof ServerLevel ? (ServerLevel) _ent.level() : null, 4,
_ent.getName().getString(), _ent.getDisplayName(), _ent.level().getServer(), _ent), "stopsound @s player target:svdfire3p");
}
} }
if (usehand.getOrCreateTag().getDouble("ammo") == 1) { if (usehand.getOrCreateTag().getDouble("ammo") == 1) {
if (entity instanceof Player _player) player.getCooldowns().addCooldown(usehand.getItem(), 10);
_player.getCooldowns().addCooldown(usehand.getItem(), 10);
usehand.getOrCreateTag().putDouble("gj", 1); usehand.getOrCreateTag().putDouble("gj", 1);
} else { } else {
if (entity instanceof Player _player) player.getCooldowns().addCooldown(usehand.getItem(), 5);
_player.getCooldowns().addCooldown(usehand.getItem(), 5);
} }
usehand.getOrCreateTag().putDouble("ammo", (usehand.getOrCreateTag().getDouble("ammo") - 1)); usehand.getOrCreateTag().putDouble("ammo", (usehand.getOrCreateTag().getDouble("ammo") - 1));
usehand.getOrCreateTag().putDouble("fireanim", 2); usehand.getOrCreateTag().putDouble("fireanim", 2);

View file

@ -1,15 +1,11 @@
package net.mcreator.target.procedures; package net.mcreator.target.procedures;
import net.mcreator.target.entity.Target1Entity;
import net.mcreator.target.init.TargetModMobEffects; import net.mcreator.target.init.TargetModMobEffects;
import net.minecraft.client.Minecraft;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.effect.MobEffectInstance; import net.minecraft.world.effect.MobEffectInstance;
import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.GameType;
public class TaserBulletDangTouZhiWuJiZhongShiTiShiProcedure { public class TaserBulletDangTouZhiWuJiZhongShiTiShiProcedure {
public static void execute(Entity entity, Entity immediatesourceentity, Entity sourceentity) { public static void execute(Entity entity, Entity immediatesourceentity, Entity sourceentity) {
@ -17,20 +13,9 @@ public class TaserBulletDangTouZhiWuJiZhongShiTiShiProcedure {
return; return;
(sourceentity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("hitcount", (sourceentity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("hitcount",
((sourceentity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("hitcount") + 1)); ((sourceentity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("hitcount") + 1));
if (!(new Object() { if (entity instanceof Player player && !player.isCreative()) {
public boolean checkGamemode(Entity _ent) { if (!player.level().isClientSide())
if (_ent instanceof ServerPlayer _serverPlayer) { player.addEffect(new MobEffectInstance(TargetModMobEffects.SHOCK.get(), 100, 0));
return _serverPlayer.gameMode.getGameModeForPlayer() == GameType.CREATIVE;
} else if (_ent.level().isClientSide() && _ent instanceof Player _player) {
return Minecraft.getInstance().getConnection().getPlayerInfo(_player.getGameProfile().getId()) != null && Minecraft.getInstance().getConnection().getPlayerInfo(_player.getGameProfile().getId()).getGameMode() == GameType.CREATIVE;
}
return false;
}
}.checkGamemode(entity))) {
if (!(entity instanceof Target1Entity)) {
if (entity instanceof LivingEntity _entity && !_entity.level().isClientSide())
_entity.addEffect(new MobEffectInstance(TargetModMobEffects.SHOCK.get(), 100, 0));
}
} }
if (!immediatesourceentity.level().isClientSide()) if (!immediatesourceentity.level().isClientSide())
immediatesourceentity.discard(); immediatesourceentity.discard();

View file

@ -5,81 +5,39 @@ import net.mcreator.target.init.TargetModAttributes;
import net.mcreator.target.init.TargetModEntities; import net.mcreator.target.init.TargetModEntities;
import net.mcreator.target.init.TargetModItems; import net.mcreator.target.init.TargetModItems;
import net.mcreator.target.network.TargetModVariables; import net.mcreator.target.network.TargetModVariables;
import net.minecraft.client.Minecraft;
import net.minecraft.commands.CommandSource; import net.minecraft.commands.CommandSource;
import net.minecraft.commands.CommandSourceStack; import net.minecraft.commands.CommandSourceStack;
import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.player.Player;
import net.minecraft.world.entity.projectile.AbstractArrow; import net.minecraft.world.entity.projectile.AbstractArrow;
import net.minecraft.world.entity.projectile.Projectile; import net.minecraft.world.entity.projectile.Projectile;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.GameType;
import net.minecraft.world.level.Level; import net.minecraft.world.level.Level;
public class TaserfireProcedure { public class TaserfireProcedure {
public static void execute(Entity entity) { public static void execute(Entity entity) {
if (entity == null) if (entity == null) return;
return; if (entity instanceof Player player && !player.isSpectator()) {
ItemStack usehand = ItemStack.EMPTY; ItemStack usehand = player.getMainHandItem();
if (!(new Object() {
public boolean checkGamemode(Entity _ent) {
if (_ent instanceof ServerPlayer _serverPlayer) {
return _serverPlayer.gameMode.getGameModeForPlayer() == GameType.SPECTATOR;
} else if (_ent.level().isClientSide() && _ent instanceof Player _player) {
return Minecraft.getInstance().getConnection().getPlayerInfo(_player.getGameProfile().getId()) != null && Minecraft.getInstance().getConnection().getPlayerInfo(_player.getGameProfile().getId()).getGameMode() == GameType.SPECTATOR;
}
return false;
}
}.checkGamemode(entity))) {
usehand = (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY);
if (usehand.getItem() == TargetModItems.TASER.get() && usehand.getOrCreateTag().getDouble("reloading") == 0 && !(entity instanceof Player _plrCldCheck4 && _plrCldCheck4.getCooldowns().isOnCooldown(usehand.getItem())) if (usehand.getItem() == TargetModItems.TASER.get() && usehand.getOrCreateTag().getDouble("reloading") == 0 && !(entity instanceof Player _plrCldCheck4 && _plrCldCheck4.getCooldowns().isOnCooldown(usehand.getItem()))
&& usehand.getOrCreateTag().getDouble("ammo") > 0) { && usehand.getOrCreateTag().getDouble("ammo") > 0) {
if (Math.random() < 0.5) {
{
double _setval = -1;
entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> { entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
capability.recoilhorizon = _setval; capability.recoilhorizon = Math.random() < 0.5 ? -1 : 1;
capability.recoil = 0.1;
capability.firing = 1;
capability.syncPlayerVariables(entity); capability.syncPlayerVariables(entity);
}); });
player.getCooldowns().addCooldown(usehand.getItem(), 5);
if (!entity.level().isClientSide() && entity.getServer() != null) {
entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), entity.level() instanceof ServerLevel ? (ServerLevel) entity.level() : null, 4,
entity.getName().getString(), entity.getDisplayName(), entity.level().getServer(), entity), "playsound target:taserfire player @a ~ ~ ~ 1 1");
} }
} else {
{ Level projectileLevel = entity.level();
double _setval = 1;
entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
capability.recoilhorizon = _setval;
capability.syncPlayerVariables(entity);
});
}
}
{
double _setval = 0.1;
entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
capability.recoil = _setval;
capability.syncPlayerVariables(entity);
});
}
{
double _setval = 1;
entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
capability.firing = _setval;
capability.syncPlayerVariables(entity);
});
}
if (entity instanceof Player _player)
_player.getCooldowns().addCooldown(usehand.getItem(), 5);
{
Entity _ent = entity;
if (!_ent.level().isClientSide() && _ent.getServer() != null) {
_ent.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, _ent.position(), _ent.getRotationVector(), _ent.level() instanceof ServerLevel ? (ServerLevel) _ent.level() : null, 4,
_ent.getName().getString(), _ent.getDisplayName(), _ent.level().getServer(), _ent), "playsound target:taserfire player @a ~ ~ ~ 1 1");
}
}
{
Entity _shootFrom = entity;
Level projectileLevel = _shootFrom.level();
if (!projectileLevel.isClientSide()) { if (!projectileLevel.isClientSide()) {
Projectile _entityToSpawn = new Object() { Projectile _entityToSpawn = new Object() {
public Projectile getArrow(Level level, Entity shooter, float damage, int knockback) { public Projectile getArrow(Level level, Entity shooter, float damage, int knockback) {
@ -91,12 +49,11 @@ public class TaserfireProcedure {
return entityToSpawn; return entityToSpawn;
} }
}.getArrow(projectileLevel, entity, (float) (usehand.getOrCreateTag().getDouble("damage") / usehand.getOrCreateTag().getDouble("velocity")), 0); }.getArrow(projectileLevel, entity, (float) (usehand.getOrCreateTag().getDouble("damage") / usehand.getOrCreateTag().getDouble("velocity")), 0);
_entityToSpawn.setPos(_shootFrom.getX(), _shootFrom.getEyeY() - 0.1, _shootFrom.getZ()); _entityToSpawn.setPos(entity.getX(), entity.getEyeY() - 0.1, entity.getZ());
_entityToSpawn.shoot(_shootFrom.getLookAngle().x, _shootFrom.getLookAngle().y, _shootFrom.getLookAngle().z, (float) usehand.getOrCreateTag().getDouble("velocity"), _entityToSpawn.shoot(entity.getLookAngle().x, entity.getLookAngle().y, entity.getLookAngle().z, (float) usehand.getOrCreateTag().getDouble("velocity"),
(float) ((LivingEntity) entity).getAttribute(TargetModAttributes.SPREAD.get()).getBaseValue()); (float) ((LivingEntity) entity).getAttribute(TargetModAttributes.SPREAD.get()).getBaseValue());
projectileLevel.addFreshEntity(_entityToSpawn); projectileLevel.addFreshEntity(_entityToSpawn);
} }
}
usehand.getOrCreateTag().putDouble("fireanim", 4); usehand.getOrCreateTag().putDouble("fireanim", 4);
usehand.getOrCreateTag().putDouble("ammo", (usehand.getOrCreateTag().getDouble("ammo") - 1)); usehand.getOrCreateTag().putDouble("ammo", (usehand.getOrCreateTag().getDouble("ammo") - 1));
} }

View file

@ -1,44 +1,26 @@
package net.mcreator.target.procedures; package net.mcreator.target.procedures;
import net.mcreator.target.init.TargetModItems; import net.mcreator.target.init.TargetModItems;
import net.minecraft.client.Minecraft;
import net.minecraft.commands.CommandSource; import net.minecraft.commands.CommandSource;
import net.minecraft.commands.CommandSourceStack; import net.minecraft.commands.CommandSourceStack;
import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.GameType;
public class TracheliumfireProcedure { public class TracheliumfireProcedure {
public static void execute(Entity entity) { public static void execute(Entity entity) {
if (entity == null) if (entity == null) return;
return; if (entity instanceof Player player && !player.isSpectator()) {
ItemStack usehand = ItemStack.EMPTY; ItemStack usehand = player.getMainHandItem();
if (!(new Object() {
public boolean checkGamemode(Entity _ent) {
if (_ent instanceof ServerPlayer _serverPlayer) {
return _serverPlayer.gameMode.getGameModeForPlayer() == GameType.SPECTATOR;
} else if (_ent.level().isClientSide() && _ent instanceof Player _player) {
return Minecraft.getInstance().getConnection().getPlayerInfo(_player.getGameProfile().getId()) != null && Minecraft.getInstance().getConnection().getPlayerInfo(_player.getGameProfile().getId()).getGameMode() == GameType.SPECTATOR;
}
return false;
}
}.checkGamemode(entity))) {
usehand = (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY);
if (usehand.getItem() == TargetModItems.TRACHELIUM.get() && usehand.getOrCreateTag().getDouble("reloading") == 0 && !(entity instanceof Player _plrCldCheck4 && _plrCldCheck4.getCooldowns().isOnCooldown(usehand.getItem())) if (usehand.getItem() == TargetModItems.TRACHELIUM.get() && usehand.getOrCreateTag().getDouble("reloading") == 0 && !(entity instanceof Player _plrCldCheck4 && _plrCldCheck4.getCooldowns().isOnCooldown(usehand.getItem()))
&& usehand.getOrCreateTag().getDouble("ammo") > 0) { && usehand.getOrCreateTag().getDouble("ammo") > 0) {
BulletFireNormalProcedure.execute(entity); BulletFireNormalProcedure.execute(entity);
if (entity instanceof Player _player) player.getCooldowns().addCooldown(usehand.getItem(), 4);
_player.getCooldowns().addCooldown(usehand.getItem(), 4);
{ if (!entity.level().isClientSide() && entity.getServer() != null) {
Entity _ent = entity; entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), entity.level() instanceof ServerLevel ? (ServerLevel) entity.level() : null, 4,
if (!_ent.level().isClientSide() && _ent.getServer() != null) { entity.getName().getString(), entity.getDisplayName(), entity.level().getServer(), entity), "playsound target:trachelium3p player @a ~ ~ ~ 4 1");
_ent.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, _ent.position(), _ent.getRotationVector(), _ent.level() instanceof ServerLevel ? (ServerLevel) _ent.level() : null, 4,
_ent.getName().getString(), _ent.getDisplayName(), _ent.level().getServer(), _ent), "playsound target:trachelium3p player @a ~ ~ ~ 4 1");
}
} }
usehand.getOrCreateTag().putDouble("fireanim", 2); usehand.getOrCreateTag().putDouble("fireanim", 2);
usehand.getOrCreateTag().putDouble("ammo", (usehand.getOrCreateTag().getDouble("ammo") - 1)); usehand.getOrCreateTag().putDouble("ammo", (usehand.getOrCreateTag().getDouble("ammo") - 1));

View file

@ -1,45 +1,27 @@
package net.mcreator.target.procedures; package net.mcreator.target.procedures;
import net.mcreator.target.init.TargetModItems; import net.mcreator.target.init.TargetModItems;
import net.minecraft.client.Minecraft;
import net.minecraft.commands.CommandSource; import net.minecraft.commands.CommandSource;
import net.minecraft.commands.CommandSourceStack; import net.minecraft.commands.CommandSourceStack;
import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.GameType;
public class VecfireProcedure { public class VecfireProcedure {
public static void execute(Entity entity) { public static void execute(Entity entity) {
if (entity == null) if (entity == null) return;
return; if (entity instanceof Player player && !player.isSpectator()) {
ItemStack usehand = ItemStack.EMPTY; ItemStack usehand = player.getMainHandItem();
if (!(new Object() {
public boolean checkGamemode(Entity _ent) {
if (_ent instanceof ServerPlayer _serverPlayer) {
return _serverPlayer.gameMode.getGameModeForPlayer() == GameType.SPECTATOR;
} else if (_ent.level().isClientSide() && _ent instanceof Player _player) {
return Minecraft.getInstance().getConnection().getPlayerInfo(_player.getGameProfile().getId()) != null && Minecraft.getInstance().getConnection().getPlayerInfo(_player.getGameProfile().getId()).getGameMode() == GameType.SPECTATOR;
}
return false;
}
}.checkGamemode(entity))) {
usehand = (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY);
if (usehand.getItem() == TargetModItems.VECTOR.get()) { if (usehand.getItem() == TargetModItems.VECTOR.get()) {
if (usehand.getOrCreateTag().getDouble("firemode") == 0) { if (usehand.getOrCreateTag().getDouble("firemode") == 0) {
if (usehand.getOrCreateTag().getDouble("reloading") == 0 && usehand.getOrCreateTag().getDouble("ammo") > 0 && !(entity instanceof Player _plrCldCheck6 && _plrCldCheck6.getCooldowns().isOnCooldown(usehand.getItem()))) { if (usehand.getOrCreateTag().getDouble("reloading") == 0 && usehand.getOrCreateTag().getDouble("ammo") > 0 && !(entity instanceof Player _plrCldCheck6 && _plrCldCheck6.getCooldowns().isOnCooldown(usehand.getItem()))) {
if (entity instanceof Player _player) player.getCooldowns().addCooldown(usehand.getItem(), 1);
_player.getCooldowns().addCooldown(usehand.getItem(), 1);
BulletFireNormalProcedure.execute(entity); BulletFireNormalProcedure.execute(entity);
{
Entity _ent = entity; if (!entity.level().isClientSide() && entity.getServer() != null) {
if (!_ent.level().isClientSide() && _ent.getServer() != null) { entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), entity.level() instanceof ServerLevel ? (ServerLevel) entity.level() : null, 4,
_ent.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, _ent.position(), _ent.getRotationVector(), _ent.level() instanceof ServerLevel ? (ServerLevel) _ent.level() : null, 4, entity.getName().getString(), entity.getDisplayName(), entity.level().getServer(), entity), "playsound target:vec3 player @a ~ ~ ~ 2 1");
_ent.getName().getString(), _ent.getDisplayName(), _ent.level().getServer(), _ent), "playsound target:vec3 player @a ~ ~ ~ 2 1");
}
} }
usehand.getOrCreateTag().putDouble("ammo", (usehand.getOrCreateTag().getDouble("ammo") - 1)); usehand.getOrCreateTag().putDouble("ammo", (usehand.getOrCreateTag().getDouble("ammo") - 1));
usehand.getOrCreateTag().putDouble("fireanim", 2); usehand.getOrCreateTag().putDouble("fireanim", 2);