mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-17 08:27:43 +01:00
71 lines
3.5 KiB
Diff
71 lines
3.5 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] |FEAT| |FIX| Dispenser curse of binding protection
|
|
|
|
{EXPLANATION}
|
|
|
|
$-----------------------------$
|
|
blocks:
|
|
dispenser:
|
|
apply-cursed-to-armor-slots:
|
|
default: true
|
|
description: |-
|
|
apply armor enchanted with curse of binding to armor slots
|
|
$-----------------------------$
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java
|
|
index 20862d2c4a10f24f76b627f66af292813b1d0264..e985f795747e25c5456658df3e1d65a520d8a2cc 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/Mob.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/Mob.java
|
|
@@ -62,6 +62,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.BlockGetter;
|
|
import net.minecraft.world.level.GameRules;
|
|
import net.minecraft.world.level.ItemLike;
|
|
@@ -1077,6 +1078,12 @@ public abstract class Mob extends LivingEntity {
|
|
|
|
}
|
|
|
|
+ // 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 aab4a63e61aced51b1b6c885fd8b8426a4f14408..dba3b8e0671ee63ff077155a8964f3e245740e7e 100644
|
|
--- a/src/main/java/net/minecraft/world/item/ArmorItem.java
|
|
+++ b/src/main/java/net/minecraft/world/item/ArmorItem.java
|
|
@@ -56,7 +56,7 @@ public class ArmorItem extends Item implements Wearable {
|
|
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.split(1);
|
|
// CraftBukkit start
|
|
Level world = pointer.getLevel();
|
|
diff --git a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
|
index b1722d945ce43e296e603b8c4eec43df39cc3bed..c5ced15da2a371dde1dbcc18266119bef2ceb035 100644
|
|
--- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
|
+++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
|
@@ -232,6 +232,11 @@ public class PurpurWorldConfig {
|
|
voidDamageDealt = getDouble("gameplay-mechanics.void-damage-dealt", voidDamageDealt);
|
|
}
|
|
|
|
+ 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);
|