Totems work in inventory

This commit is contained in:
William Blake Galbreath
2020-07-15 14:55:24 -05:00
parent 91976a87e7
commit 60e6fa55f2

View File

@@ -0,0 +1,45 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: draycia <lonelyyordle@gmail.com>
Date: Wed, 29 Apr 2020 00:45:58 -0700
Subject: [PATCH] Totems work in inventory
diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java
index 3a2a45a65..3bd38d99f 100644
--- a/src/main/java/net/minecraft/server/EntityLiving.java
+++ b/src/main/java/net/minecraft/server/EntityLiving.java
@@ -1318,6 +1318,18 @@ public abstract class EntityLiving extends Entity {
}
}
+ // Purpur start
+ if (world.purpurConfig.totemOfUndyingWorksInInventory && itemstack == ItemStack.NULL_ITEM && this instanceof EntityPlayer) {
+ EntityPlayer player = (EntityPlayer) this;
+ for (ItemStack item : player.inventory.items) {
+ if (item.getItem() == Items.TOTEM_OF_UNDYING) {
+ itemstack = item.cloneItemStack();
+ break;
+ }
+ }
+ }
+ // Purpur end
+
EntityResurrectEvent event = new EntityResurrectEvent((LivingEntity) this.getBukkitEntity());
event.setCancelled(itemstack == null);
this.world.getServer().getPluginManager().callEvent(event);
diff --git a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
index 26964f062..cb7812741 100644
--- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
+++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
@@ -185,6 +185,11 @@ public class PurpurWorldConfig {
teleportIfOutsideBorder = getBoolean("gameplay-mechanics.player.teleport-if-outside-border", teleportIfOutsideBorder);
}
+ public boolean totemOfUndyingWorksInInventory = false;
+ private void totemOfUndyingWorksInInventory() {
+ totemOfUndyingWorksInInventory = getBoolean("gameplay-mechanics.player.totem-of-undying-works-in-inventory", totemOfUndyingWorksInInventory);
+ }
+
public boolean silkTouchEnabled = false;
public List<Item> silkTouchTools = new ArrayList<>();
private void silkTouchSettings() {