Advertisement
Guest User

Untitled

a guest
Apr 27th, 2021
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  1. public class CoolDownHandler
  2. {
  3. public static void onAttachCapabilities(AttachCapabilitiesEvent<Item> event) {
  4. if (event.getObject() instanceof BoltcasterItem) {
  5. CoolDownProvider provider = new CoolDownProvider();
  6. event.addCapability(new ResourceLocation(ProjectDawn.MOD_ID, "ticksIn"), provider);
  7. event.addListener(provider::invalidate);
  8. }
  9.  
  10. }
  11. public static void doCoolDown(PlayerInteractEvent.RightClickItem event)
  12. {
  13. CooldownTracker cooldownTracker = new CooldownTracker();
  14.  
  15. PlayerEntity player = event.getPlayer();
  16. ItemStack stack = player.getHeldItemMainhand();
  17. ItemStack stack1 = player.getHeldItemOffhand();
  18.  
  19. if(stack.getItem() instanceof BoltcasterItem)
  20. {
  21. stack.getCapability(CoolDownCapability.COOLDOWN_CAPABILITY).ifPresent(h -> {
  22. int ticksIn = h.getCoolDown();
  23.  
  24. cooldownTracker.setCooldown(stack.getItem(), ticksIn);
  25. });
  26. }
  27. if(stack1.getItem() instanceof BoltcasterItem)
  28. {
  29. stack1.getCapability(CoolDownCapability.COOLDOWN_CAPABILITY).ifPresent(h -> {
  30. int ticksIn = h.getCoolDown();
  31. cooldownTracker.setCooldown(stack.getItem(), ticksIn);
  32. });
  33. }
  34.  
  35. }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement