From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: draycia Date: Wed, 29 Apr 2020 00:45:58 -0700 Subject: [PATCH] Totems work in inventory diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java index 642ffbd2632c9cb0438447ca83f598b1df37bd9b..5e701bd6ce6db9ef3cebbc24ce80e00aa1e558d7 100644 --- a/src/main/java/net/minecraft/world/entity/LivingEntity.java +++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java @@ -1631,6 +1631,18 @@ public abstract class LivingEntity extends Entity implements Attackable { } } + // Purpur start + if (level().purpurConfig.totemOfUndyingWorksInInventory && this instanceof ServerPlayer player && (itemstack == null || itemstack.getItem() != Items.TOTEM_OF_UNDYING) && player.getBukkitEntity().hasPermission("purpur.inventory_totem")) { + for (ItemStack item : player.getInventory().items) { + if (item.getItem() == Items.TOTEM_OF_UNDYING) { + itemstack1 = item; + itemstack = item.copy(); + break; + } + } + } + // Purpur end + org.bukkit.inventory.EquipmentSlot handSlot = (hand != null) ? org.bukkit.craftbukkit.CraftEquipmentSlot.getHand(hand) : null; EntityResurrectEvent event = new EntityResurrectEvent((org.bukkit.entity.LivingEntity) this.getBukkitEntity(), handSlot); event.setCancelled(itemstack == null); diff --git a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java index 8f085e8ba40d3bd9fca27b18b9ee156bbffe6bc3..538c6f1cec00ef0ce8e793a5d205875d2d9aac92 100644 --- a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java +++ b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java @@ -243,6 +243,7 @@ public class PurpurWorldConfig { public String playerDeathExpDropEquation = "expLevel * 7"; public int playerDeathExpDropMax = 100; public boolean teleportIfOutsideBorder = false; + public boolean totemOfUndyingWorksInInventory = false; private void playerSettings() { if (PurpurConfig.version < 19) { boolean oldVal = getBoolean("gameplay-mechanics.player.idle-timeout.mods-target", idleTimeoutTargetPlayer); @@ -257,6 +258,7 @@ public class PurpurWorldConfig { playerDeathExpDropEquation = getString("gameplay-mechanics.player.exp-dropped-on-death.equation", playerDeathExpDropEquation); playerDeathExpDropMax = getInt("gameplay-mechanics.player.exp-dropped-on-death.maximum", playerDeathExpDropMax); teleportIfOutsideBorder = getBoolean("gameplay-mechanics.player.teleport-if-outside-border", teleportIfOutsideBorder); + totemOfUndyingWorksInInventory = getBoolean("gameplay-mechanics.player.totem-of-undying-works-in-inventory", totemOfUndyingWorksInInventory); } public boolean silkTouchEnabled = false;