39 lines
2.4 KiB
Java
39 lines
2.4 KiB
Java
package net.mcreator.target.procedures;
|
|
|
|
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.item.ItemStack;
|
|
|
|
public class Hk416autofireProcedure {
|
|
public static void execute(Entity entity) {
|
|
if (entity == null)
|
|
return;
|
|
ItemStack usehand = ItemStack.EMPTY;
|
|
usehand = (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY);
|
|
BulletFireNormalProcedure.execute(entity);
|
|
HkDsProcedure.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: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.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.getName().getString(), entity.getDisplayName(), entity.level().getServer(), entity), "stopsound @s player target:hk416fire");
|
|
}
|
|
}
|
|
usehand.getOrCreateTag().putDouble("fireanim", 2);
|
|
usehand.getOrCreateTag().putDouble("ammo", (usehand.getOrCreateTag().getDouble("ammo") - 1));
|
|
}
|
|
}
|