Guest User

i need help

a guest
Oct 29th, 2022
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. package net.mcreator.amulets.procedures;
  2.  
  3. /* imports omitted */
  4.  
  5. public class RegenerationProcedure {
  6. public static void execute(LevelAccessor world, Entity entity, ItemStack itemstack) {
  7. if (entity == null)
  8. return;
  9. double ifItemOnCooldown = 0;
  10. if (ifItemOnCooldown == 0) {
  11. ifItemOnCooldown = 1;
  12. if (entity instanceof Player _player)
  13. _player.getCooldowns().addCooldown(itemstack.getItem(), 400);
  14. if (entity instanceof LivingEntity _entity)
  15. _entity.addEffect(new MobEffectInstance(MobEffects.HEAL, 1, 1, (false), (false)));
  16. new Object() {
  17. private int ticks = 0;
  18. private float waitTicks;
  19. private LevelAccessor world;
  20.  
  21. public void start(LevelAccessor world, int waitTicks) {
  22. this.waitTicks = waitTicks;
  23. MinecraftForge.EVENT_BUS.register(this);
  24. this.world = world;
  25. }
  26.  
  27. @SubscribeEvent
  28. public void tick(TickEvent.ServerTickEvent event) {
  29. if (event.phase == TickEvent.Phase.END) {
  30. this.ticks += 1;
  31. if (this.ticks >= this.waitTicks)
  32. run();
  33. }
  34. }
  35.  
  36. private void run() {
  37. MinecraftForge.EVENT_BUS.unregister(this);
  38. }
  39. }.start(world, 400);
  40. }
  41. }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment