Skip to content

Commit 96cd596

Browse files
committed
fixed armor not having durability
1 parent 95838ff commit 96cd596

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

src/main/java/de/ellpeck/naturesaura/items/tools/ItemArmor.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public class ItemArmor extends ArmorItem implements IModItem {
3535
private final String baseName;
3636

3737
public ItemArmor(String baseName, ModArmorMaterial materialIn, ArmorItem.Type equipmentSlotIn) {
38-
super(materialIn.material, equipmentSlotIn, new Properties());
38+
super(materialIn.material, equipmentSlotIn, new Properties().durability(materialIn.getDurability(equipmentSlotIn)));
3939
this.baseName = baseName;
4040
ModRegistry.ALL_ITEMS.add(this);
4141
}

src/main/java/de/ellpeck/naturesaura/reg/ModArmorMaterial.java

+9-4
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,15 @@
1818

1919
public enum ModArmorMaterial {
2020

21-
INFUSED(NaturesAura.MOD_ID + ":infused_iron", new int[]{2, 5, 6, 2}, 16, SoundEvents.ARMOR_EQUIP_IRON, 0, 0, () -> Ingredient.of(ModItems.INFUSED_IRON)),
22-
SKY(NaturesAura.MOD_ID + ":sky", new int[]{3, 6, 8, 3}, 12, SoundEvents.ARMOR_EQUIP_DIAMOND, 2, 0, () -> Ingredient.of(ModItems.SKY_INGOT)),
23-
DEPTH(NaturesAura.MOD_ID + ":depth", new int[]{3, 6, 8, 3}, 18, SoundEvents.ARMOR_EQUIP_NETHERITE, 3, 1, () -> Ingredient.of(ModItems.DEPTH_INGOT));
21+
INFUSED(NaturesAura.MOD_ID + ":infused_iron", 19, new int[]{2, 5, 6, 2}, 16, SoundEvents.ARMOR_EQUIP_IRON, 0, 0, () -> Ingredient.of(ModItems.INFUSED_IRON)),
22+
SKY(NaturesAura.MOD_ID + ":sky", 33, new int[]{3, 6, 8, 3}, 12, SoundEvents.ARMOR_EQUIP_DIAMOND, 2, 0, () -> Ingredient.of(ModItems.SKY_INGOT)),
23+
DEPTH(NaturesAura.MOD_ID + ":depth", 37, new int[]{3, 6, 8, 3}, 18, SoundEvents.ARMOR_EQUIP_NETHERITE, 3, 1, () -> Ingredient.of(ModItems.DEPTH_INGOT));
2424

2525
public final Holder<ArmorMaterial> material;
26+
private final int maxDamageFactor;
2627

27-
ModArmorMaterial(String nameIn, int[] damageReductionAmountsIn, int enchantabilityIn, Holder<SoundEvent> equipSoundIn, float toughness, float knockbackResistance, Supplier<Ingredient> repairMaterialSupplier) {
28+
ModArmorMaterial(String nameIn, int maxDamageFactor, int[] damageReductionAmountsIn, int enchantabilityIn, Holder<SoundEvent> equipSoundIn, float toughness, float knockbackResistance, Supplier<Ingredient> repairMaterialSupplier) {
29+
this.maxDamageFactor = maxDamageFactor;
2830
var res = ResourceLocation.parse(nameIn);
2931
var defense = new EnumMap<ArmorItem.Type, Integer>(ArmorItem.Type.class);
3032
defense.put(ArmorItem.Type.BOOTS, damageReductionAmountsIn[0]);
@@ -35,4 +37,7 @@ public enum ModArmorMaterial {
3537
this.material = Registry.registerForHolder(BuiltInRegistries.ARMOR_MATERIAL, res, new ArmorMaterial(defense, enchantabilityIn, equipSoundIn, repairMaterialSupplier, layers, toughness, knockbackResistance));
3638
}
3739

40+
public int getDurability(ArmorItem.Type type) {
41+
return type.getDurability(this.maxDamageFactor);
42+
}
3843
}

0 commit comments

Comments
 (0)