73 lines
4.4 KiB
Java
73 lines
4.4 KiB
Java
package net.mcreator.target.procedures;
|
|
|
|
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.item.ItemStack;
|
|
import net.minecraftforge.event.TickEvent;
|
|
import net.minecraftforge.eventbus.api.Event;
|
|
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
|
import net.minecraftforge.fml.common.Mod;
|
|
|
|
import javax.annotation.Nullable;
|
|
|
|
@Mod.EventBusSubscriber
|
|
public class PullXiaoGuoChiXuShiMeiKeFaShengProcedure {
|
|
@SubscribeEvent
|
|
public static void onPlayerTick(TickEvent.PlayerTickEvent event) {
|
|
if (event.phase == TickEvent.Phase.END) {
|
|
execute(event, event.player);
|
|
}
|
|
}
|
|
|
|
public static void execute(Entity entity) {
|
|
execute(null, entity);
|
|
}
|
|
|
|
private static void execute(@Nullable Event event, Entity entity) {
|
|
if (entity == null)
|
|
return;
|
|
if ((entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).bowpullhold) {
|
|
if ((entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getItem() == TargetModItems.BOCEK.get()
|
|
&& (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("maxammo") > 0
|
|
&& !(entity instanceof Player _plrCldCheck5 && _plrCldCheck5.getCooldowns().isOnCooldown((entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getItem()))
|
|
&& (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("power") < 12) {
|
|
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("power",
|
|
((entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("power") + 1));
|
|
{
|
|
boolean _setval = true;
|
|
entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
|
|
capability.bowpull = _setval;
|
|
capability.syncPlayerVariables(entity);
|
|
});
|
|
}
|
|
}
|
|
if ((entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("power") == 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:bocek_pull_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:bocek_pull_3p player @a ~ ~ ~ 0.5 1");
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
if ((entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getItem() == TargetModItems.BOCEK.get()) {
|
|
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("power", 0);
|
|
}
|
|
{
|
|
boolean _setval = false;
|
|
entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
|
|
capability.bowpull = _setval;
|
|
capability.syncPlayerVariables(entity);
|
|
});
|
|
}
|
|
}
|
|
}
|
|
}
|