mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-17 16:37:43 +01:00
73 lines
3.7 KiB
Diff
73 lines
3.7 KiB
Diff
From 5f11f209c5b6ad99a7f699e542b31d7e21b7339a Mon Sep 17 00:00:00 2001
|
|
From: William Blake Galbreath <blake.galbreath@gmail.com>
|
|
Date: Sun, 25 Aug 2019 00:09:52 -0500
|
|
Subject: [PATCH] Dispenser curse of binding protection
|
|
|
|
---
|
|
src/main/java/net/minecraft/server/EntityInsentient.java | 8 +++++++-
|
|
src/main/java/net/minecraft/server/ItemArmor.java | 3 ++-
|
|
src/main/java/net/pl3x/purpur/PurpurWorldConfig.java | 5 +++++
|
|
3 files changed, 14 insertions(+), 2 deletions(-)
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/EntityInsentient.java b/src/main/java/net/minecraft/server/EntityInsentient.java
|
|
index 53fffb3dc3..53b45215bc 100644
|
|
--- a/src/main/java/net/minecraft/server/EntityInsentient.java
|
|
+++ b/src/main/java/net/minecraft/server/EntityInsentient.java
|
|
@@ -902,9 +902,15 @@ public abstract class EntityInsentient extends EntityLiving {
|
|
|
|
}
|
|
|
|
+ // Purpur start
|
|
+ public static EnumItemSlot getSlotForDispenser(ItemStack itemstack) {
|
|
+ return EnchantmentManager.getEnchantmentLevel(Enchantments.BINDING_CURSE, itemstack) > 0 ? EnumItemSlot.MAINHAND : getSlotForItemStack(itemstack);
|
|
+ }
|
|
+ // Purpur end
|
|
+
|
|
+ public static EnumItemSlot getSlotForItemStack(ItemStack itemstack) { return h(itemstack); } // Purpur - OBFHELPER
|
|
public static EnumItemSlot h(ItemStack itemstack) {
|
|
Item item = itemstack.getItem();
|
|
-
|
|
return item != Blocks.CARVED_PUMPKIN.getItem() && (!(item instanceof ItemBlock) || !(((ItemBlock) item).getBlock() instanceof BlockSkullAbstract)) ? (item instanceof ItemArmor ? ((ItemArmor) item).b() : (item == Items.ELYTRA ? EnumItemSlot.CHEST : (item == Items.SHIELD ? EnumItemSlot.OFFHAND : EnumItemSlot.MAINHAND))) : EnumItemSlot.HEAD;
|
|
}
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/ItemArmor.java b/src/main/java/net/minecraft/server/ItemArmor.java
|
|
index cef073c81e..4014c7d116 100644
|
|
--- a/src/main/java/net/minecraft/server/ItemArmor.java
|
|
+++ b/src/main/java/net/minecraft/server/ItemArmor.java
|
|
@@ -31,7 +31,7 @@ public class ItemArmor extends Item {
|
|
return false;
|
|
} else {
|
|
EntityLiving entityliving = (EntityLiving) list.get(0);
|
|
- EnumItemSlot enumitemslot = EntityInsentient.h(itemstack);
|
|
+ EnumItemSlot enumitemslot = isourceblock.getWorld().purpurConfig.dispenserApplyCursedArmor ? EntityInsentient.getSlotForItemStack(itemstack) : EntityInsentient.getSlotForDispenser(itemstack); // Purpur
|
|
ItemStack itemstack1 = itemstack.cloneAndSubtract(1);
|
|
// CraftBukkit start
|
|
World world = isourceblock.getWorld();
|
|
@@ -79,6 +79,7 @@ public class ItemArmor extends Item {
|
|
BlockDispenser.a((IMaterial) this, ItemArmor.a);
|
|
}
|
|
|
|
+ public EnumItemSlot getEquipmentSlot() { return b(); } // Purpur - OBFHELPER
|
|
public EnumItemSlot b() {
|
|
return this.b;
|
|
}
|
|
diff --git a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
|
index 8915bc9ea8..3ff5dc4a3b 100644
|
|
--- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
|
+++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
|
@@ -107,6 +107,11 @@ public class PurpurWorldConfig {
|
|
campfiresGoOutInRain = getBoolean("campfires-go-out-in-rain", campfiresGoOutInRain);
|
|
}
|
|
|
|
+ public boolean dispenserApplyCursedArmor = true;
|
|
+ private void dispenserApplyCursedArmor() {
|
|
+ dispenserApplyCursedArmor = getBoolean("dispenser-apply-cursed-armor-slots", dispenserApplyCursedArmor);
|
|
+ }
|
|
+
|
|
public boolean allowMoistSoilFromWaterBelow = true;
|
|
private void allowMoistSoilFromWaterBelow() {
|
|
allowMoistSoilFromWaterBelow = getBoolean("allow-moist-soil-from-water-below", allowMoistSoilFromWaterBelow);
|
|
--
|
|
2.24.0.rc1
|
|
|