superb-warfare/src/main/java/net/mcreator/target/procedures/HrfireProcedure.java
2024-05-06 14:25:44 +08:00

30 lines
1.7 KiB
Java

package net.mcreator.target.procedures;
import net.mcreator.target.init.TargetModItems;
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.player.Player;
import net.minecraft.world.item.ItemStack;
public class HrfireProcedure {
public static void execute(Entity entity) {
if (entity == null) return;
if (entity instanceof Player player && !player.isSpectator()) {
ItemStack usehand = player.getMainHandItem();
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) {
BulletFireNormalProcedure.execute(entity);
player.getCooldowns().addCooldown(usehand.getItem(), 13);
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:hr_fire_1p player @a ~ ~ ~ 4 1");
}
usehand.getOrCreateTag().putDouble("fireanim", 2);
usehand.getOrCreateTag().putDouble("ammo", (usehand.getOrCreateTag().getDouble("ammo") - 1));
}
}
}
}