Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @SubscribeEvent
- public static void necklaceSummerAcornDeathPrevention(LivingDeathEvent event){
- if(!(event.getEntity() instanceof Player)){
- return;
- }
- Player player = (Player) event.getEntity();
- if(player.getInventory().contains(DRItems.NECKLACEOFOAKS.get().getDefaultInstance())){
- int oakNecklaceSlotId = Math.abs(player.getInventory().findSlotMatchingItem(DRItems.NECKLACEOFOAKS.get().getDefaultInstance()));
- ItemStack oakNecklace = player.getInventory().getItem(oakNecklaceSlotId).copy();
- if(oakNecklace.getTag().getBoolean("has_summer_acorn"))
- {
- player.setHealth(4F);
- player.removeAllEffects();
- player.level.broadcastEntityEvent(player, (byte)35);
- oakNecklace.getTag().putBoolean("has_summer_acorn", false);
- oakNecklace.hurtAndBreak(1, player, null);
- event.setCanceled(true);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement