Skip to content

Commit 0adbbcf

Browse files
committed
fix #348
1 parent 638d0a8 commit 0adbbcf

2 files changed

Lines changed: 11 additions & 5 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
- add Turkish translation (#335)
22
- add Hungarian translation (#345, #347)
3+
- disallow removing armor with curse of binding (fix #348)

src/main/java/de/mari_023/ae2wtlib/wct/ArmorSlot.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
import net.minecraft.world.entity.EquipmentSlot;
44
import net.minecraft.world.entity.player.Inventory;
55
import net.minecraft.world.entity.player.Player;
6-
import net.minecraft.world.item.ArmorItem;
76
import net.minecraft.world.item.ItemStack;
7+
import net.minecraft.world.item.enchantment.EnchantmentEffectComponents;
8+
import net.minecraft.world.item.enchantment.EnchantmentHelper;
89

910
import appeng.menu.slot.AppEngSlot;
1011

@@ -22,9 +23,13 @@ public ArmorSlot(Inventory playerInventory, Armor armor) {
2223

2324
public boolean mayPlace(ItemStack stack) {
2425
return armor == Armor.OFFHAND
25-
|| (playerInventory.canPlaceItem(armor.armor.invSlot, stack)
26-
&& stack.getItem() instanceof ArmorItem aItem
27-
&& aItem.getEquipmentSlot().equals(armor.armor.equipmentSlot));
26+
|| stack.canEquip(armor.armor.equipmentSlot(), playerInventory.player);
27+
}
28+
29+
@Override
30+
public boolean mayPickup(Player player) {
31+
return super.mayPickup(player) && (player.isCreative()
32+
|| !EnchantmentHelper.has(getItem(), EnchantmentEffectComponents.PREVENT_ARMOR_CHANGE));
2833
}
2934

3035
public Icon icon() {
@@ -36,7 +41,7 @@ public enum Armor {
3641
LEGS(new ArmorValue(EquipmentSlot.LEGS, 37, Icon.EMPTY_ARMOR_SLOT_LEGGINGS)),
3742
CHEST(new ArmorValue(EquipmentSlot.CHEST, 38, Icon.EMPTY_ARMOR_SLOT_CHESTPLATE)),
3843
HEAD(new ArmorValue(EquipmentSlot.HEAD, 39, Icon.EMPTY_ARMOR_SLOT_HELMET)),
39-
OFFHAND(new ArmorValue(EquipmentSlot.HEAD, Inventory.SLOT_OFFHAND, Icon.EMPTY_ARMOR_SLOT_SHIELD));
44+
OFFHAND(new ArmorValue(EquipmentSlot.OFFHAND, Inventory.SLOT_OFFHAND, Icon.EMPTY_ARMOR_SLOT_SHIELD));
4045

4146
public final ArmorValue armor;
4247

0 commit comments

Comments
 (0)