jayhillx

onUse

Sep 6th, 2021 (edited)
414
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.78 KB | None | 0 0
  1.     @SubscribeEvent
  2.     public void onUse(PlayerInteractEvent.RightClickItem event) {
  3.         PlayerEntity player = event.getPlayer();
  4.         Item item = event.getItemStack().getItem();
  5.         CompoundNBT nbt = item.getDefaultInstance().getOrCreateTag();
  6.  
  7.         if (item == Items.WRITTEN_BOOK) {
  8.  
  9.             IHealthCapability health = player.getCapability(HealthCapability.HEALTH_CAPABILITY).orElse(null);
  10.             ListNBT pages = new ListNBT();
  11.  
  12.             if (health.getMaxHealth() >= 2.0F && health.getMaxHealth() <= 6.0F) {
  13.                 pages.add(HealthBookUtils.setPageOne(player));
  14.             } else if (health.getMaxHealth() >= 8.0F && health.getMaxHealth() <= 12.0F) {
  15.                 pages.add(2, HealthBookUtils.setPageTwo(player));
  16.             }
  17.         }
  18.     }
Add Comment
Please, Sign In to add comment