Skip to content

Commit

Permalink
Fix: EndArmorItems attributes now properly stack
Browse files Browse the repository at this point in the history
  • Loading branch information
OpenBagTwo committed Oct 14, 2024
1 parent 5d78655 commit 9a2b329
Showing 1 changed file with 29 additions and 6 deletions.
35 changes: 29 additions & 6 deletions src/main/java/org/betterx/betterend/item/EndArmorItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,24 @@

public class EndArmorItem extends ArmorItem implements ItemModelProvider {
public static final ResourceLocation BASE_BLINDNESS_RESISTANCE = BetterEnd.C.mk("base_blindness_resistance");
public static final ResourceLocation BASE_KNOCKBACK_RESISTANCE = BetterEnd.C.mk("base_knockback_resistance");
public static final ResourceLocation[] KNOCKBACK_RESISTANCES = {
BetterEnd.C.mk("base_knockback_resistance_helmet"),
BetterEnd.C.mk("base_knockback_resistance_chestplate"),
BetterEnd.C.mk("base_knockback_resistance_leggings"),
BetterEnd.C.mk("base_knockback_resistance_boots")};
public static final ResourceLocation MAX_HEALTH_BOOST = BetterEnd.C.mk("max_health_boost");
public static final ResourceLocation TOUGHNESS_BOOST = BetterEnd.C.mk("toughness_boost");
public static final ResourceLocation ARMOR_BOOST = BetterEnd.C.mk("armor_boost");
public static final ResourceLocation[] TOUGHNESS_BOOSTS = {
BetterEnd.C.mk("toughness_boost_helmet"),
BetterEnd.C.mk("toughness_boost_chestplate"),
BetterEnd.C.mk("toughness_boost_leggings"),
BetterEnd.C.mk("toughness_boost_boots")
};
public static final ResourceLocation[] ARMOR_BOOSTS = {
BetterEnd.C.mk("armor_boost_helmet"),
BetterEnd.C.mk("armor_boost_chestplate"),
BetterEnd.C.mk("armor_boost_leggings"),
BetterEnd.C.mk("armor_boost_boots")
};

public static Properties createDefaultEndArmorSettings(ArmorSlot slot, ArmorTier tier) {
var values = tier.getValues(slot);
Expand Down Expand Up @@ -56,12 +70,21 @@ public static ItemAttributeModifiers.Builder startAttributeBuilder(
) {
EquipmentSlotGroup slotGroup = EquipmentSlotGroup.bySlot(slot.armorType.getSlot());

int boosterIdx = 0;
if (slot == ArmorSlot.CHESTPLATE_SLOT){
boosterIdx = 1;
} else if (slot == ArmorSlot.LEGGINGS_SLOT) {
boosterIdx = 2;
} else if (slot == ArmorSlot.BOOTS_SLOT) {
boosterIdx = 3;
}

final ItemAttributeModifiers.Builder builder = ItemAttributeModifiers
.builder()
.add(
Attributes.ARMOR,
new AttributeModifier(
ARMOR_BOOST,
ARMOR_BOOSTS[boosterIdx],
defense,
AttributeModifier.Operation.ADD_VALUE
),
Expand All @@ -70,7 +93,7 @@ public static ItemAttributeModifiers.Builder startAttributeBuilder(
.add(
Attributes.ARMOR_TOUGHNESS,
new AttributeModifier(
TOUGHNESS_BOOST,
TOUGHNESS_BOOSTS[boosterIdx],
toughness,
AttributeModifier.Operation.ADD_VALUE
),
Expand All @@ -81,7 +104,7 @@ public static ItemAttributeModifiers.Builder startAttributeBuilder(
builder.add(
Attributes.KNOCKBACK_RESISTANCE,
new AttributeModifier(
BASE_KNOCKBACK_RESISTANCE,
KNOCKBACK_RESISTANCES[boosterIdx],
knockbackResistance,
AttributeModifier.Operation.ADD_VALUE
),
Expand Down

0 comments on commit 9a2b329

Please sign in to comment.