Skip to content

Commit

Permalink
Totems work in inventory
Browse files Browse the repository at this point in the history
  • Loading branch information
BillyGalbreath committed Jul 15, 2020
1 parent 91976a8 commit 60e6fa5
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions patches/server/0116-Totems-work-in-inventory.patch
Original file line number Diff line number Diff line change
@@ -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() {

0 comments on commit 60e6fa5

Please sign in to comment.