Files
Purpur/patches/server/0091-Totems-work-in-inventory.patch
BillyGalbreath 9a48162500 more progress
2021-06-18 19:09:50 -05:00

47 lines
2.5 KiB
Diff

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/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
index 8ace00a8dbba62c3c889b57a47d3ad4e2c014431..4a8ef02c1a2fa08c113441261c56d28da18e1526 100644
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
@@ -1516,6 +1516,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 c619ea7c5cdf5331e4a16fa3d899b888fa436295..386bd354d0c5ff9c2570634c9d34a121f9bf8641 100644
--- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
+++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
@@ -247,6 +247,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 String silkTouchSpawnerName = "Spawner";
public List<String> silkTouchSpawnerLore = new ArrayList<>();