Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package net.mcreator.amulets.procedures;
- /* imports omitted */
- public class RegenerationProcedure {
- public static void execute(LevelAccessor world, Entity entity, ItemStack itemstack) {
- if (entity == null)
- return;
- double ifItemOnCooldown = 0;
- if (ifItemOnCooldown == 0) {
- ifItemOnCooldown = 1;
- if (entity instanceof Player _player)
- _player.getCooldowns().addCooldown(itemstack.getItem(), 400);
- if (entity instanceof LivingEntity _entity)
- _entity.addEffect(new MobEffectInstance(MobEffects.HEAL, 1, 1, (false), (false)));
- new Object() {
- private int ticks = 0;
- private float waitTicks;
- private LevelAccessor world;
- public void start(LevelAccessor world, int waitTicks) {
- this.waitTicks = waitTicks;
- MinecraftForge.EVENT_BUS.register(this);
- this.world = world;
- }
- @SubscribeEvent
- public void tick(TickEvent.ServerTickEvent event) {
- if (event.phase == TickEvent.Phase.END) {
- this.ticks += 1;
- if (this.ticks >= this.waitTicks)
- run();
- }
- }
- private void run() {
- MinecraftForge.EVENT_BUS.unregister(this);
- }
- }.start(world, 400);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment