Skip to content

Commit

Permalink
fixed armor not having durability
Browse files Browse the repository at this point in the history
  • Loading branch information
Ellpeck committed Dec 5, 2024
1 parent 95838ff commit 96cd596
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class ItemArmor extends ArmorItem implements IModItem {
private final String baseName;

public ItemArmor(String baseName, ModArmorMaterial materialIn, ArmorItem.Type equipmentSlotIn) {
super(materialIn.material, equipmentSlotIn, new Properties());
super(materialIn.material, equipmentSlotIn, new Properties().durability(materialIn.getDurability(equipmentSlotIn)));
this.baseName = baseName;
ModRegistry.ALL_ITEMS.add(this);
}
Expand Down
13 changes: 9 additions & 4 deletions src/main/java/de/ellpeck/naturesaura/reg/ModArmorMaterial.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,15 @@

public enum ModArmorMaterial {

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

public final Holder<ArmorMaterial> material;
private final int maxDamageFactor;

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

public int getDurability(ArmorItem.Type type) {
return type.getDurability(this.maxDamageFactor);
}
}

0 comments on commit 96cd596

Please sign in to comment.