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 17828733fff18cb3159dd75280aa1f1b32ac088f..4904abec73580eee50c12a8edcb6e743805b018e 100644 --- a/src/main/java/net/minecraft/world/entity/LivingEntity.java +++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java @@ -1512,6 +1512,19 @@ public abstract class LivingEntity extends Entity { } } + // Purpur start + if (level.purpurConfig.totemOfUndyingWorksInInventory && this instanceof ServerPlayer && (itemstack == null || itemstack.getItem() != Items.TOTEM_OF_UNDYING)) { + ServerPlayer player = (ServerPlayer) this; + for (ItemStack item : player.getInventory().items) { + if (item.getItem() == Items.TOTEM_OF_UNDYING) { + itemstack1 = item; + itemstack = item.cloneItemStack(false); + break; + } + } + } + // Purpur end + EntityResurrectEvent event = new EntityResurrectEvent((org.bukkit.entity.LivingEntity) this.getBukkitEntity()); event.setCancelled(itemstack == null); this.level.getCraftServer().getPluginManager().callEvent(event); diff --git a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java index 7d41d9c5e35bb451f214b67b20c05e30f63ab9d4..d10be85bd30dcf5eba755152954be35a43e8b8b4 100644 --- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java +++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java @@ -232,6 +232,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); @@ -248,6 +249,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;