Files
Purpur/patches/server/0054-Dispenser-curse-of-binding-protection.patch
Ben Kerllenevich 3f2e212cda 100/310
2023-06-08 17:58:43 -04:00

61 lines
3.3 KiB
Diff

From 0000000000000000000000000000000000000000 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
diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java
index e62de6ba4836da2c2a389c753ac0865f9b0184a6..fdd0acaaf69f9325feaf8167e8122191a0c7e9d7 100644
--- a/src/main/java/net/minecraft/world/entity/Mob.java
+++ b/src/main/java/net/minecraft/world/entity/Mob.java
@@ -65,6 +65,7 @@ import net.minecraft.world.item.ProjectileWeaponItem;
import net.minecraft.world.item.SpawnEggItem;
import net.minecraft.world.item.SwordItem;
import net.minecraft.world.item.enchantment.EnchantmentHelper;
+import net.minecraft.world.item.enchantment.Enchantments;
import net.minecraft.world.level.GameRules;
import net.minecraft.world.level.ItemLike;
import net.minecraft.world.level.Level;
@@ -1160,6 +1161,12 @@ public abstract class Mob extends LivingEntity implements Targeting {
}
+ // Purpur start
+ public static @Nullable EquipmentSlot getSlotForDispenser(ItemStack itemstack) {
+ return EnchantmentHelper.getItemEnchantmentLevel(Enchantments.BINDING_CURSE, itemstack) > 0 ? null : getEquipmentSlotForItem(itemstack);
+ }
+ // Purpur end
+
@Nullable
public static Item getEquipmentForSlot(EquipmentSlot equipmentSlot, int equipmentLevel) {
switch (equipmentSlot) {
diff --git a/src/main/java/net/minecraft/world/item/ArmorItem.java b/src/main/java/net/minecraft/world/item/ArmorItem.java
index d7a0cbde8f8c99276307502674c71463fbe7e89c..3500c56cb85d8c76b2acd77976d374eaf487b3b3 100644
--- a/src/main/java/net/minecraft/world/item/ArmorItem.java
+++ b/src/main/java/net/minecraft/world/item/ArmorItem.java
@@ -60,7 +60,7 @@ public class ArmorItem extends Item implements Equipable {
return false;
} else {
LivingEntity entityliving = (LivingEntity) list.get(0);
- EquipmentSlot enumitemslot = Mob.getEquipmentSlotForItem(armor);
+ EquipmentSlot enumitemslot = pointer.getLevel().purpurConfig.dispenserApplyCursedArmor ? Mob.getEquipmentSlotForItem(armor) : Mob.getSlotForDispenser(armor); if (enumitemslot == null) return false; // Purpur
ItemStack itemstack1 = armor.copyWithCount(1); // Paper - shrink below and single item in event
// CraftBukkit start
Level world = pointer.getLevel();
diff --git a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
index 81c25f1498868d75107ec050fa95d02f2c0afea1..c6856ca91aed12bab95c115e5f3bc6d01ef75594 100644
--- a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
+++ b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
@@ -230,6 +230,11 @@ public class PurpurWorldConfig {
});
}
+ public boolean dispenserApplyCursedArmor = true;
+ private void dispenserSettings() {
+ dispenserApplyCursedArmor = getBoolean("blocks.dispenser.apply-cursed-to-armor-slots", dispenserApplyCursedArmor);
+ }
+
public boolean farmlandGetsMoistFromBelow = false;
private void farmlandSettings() {
farmlandGetsMoistFromBelow = getBoolean("blocks.farmland.gets-moist-from-below", farmlandGetsMoistFromBelow);