fixed armor not having durability

This commit is contained in:
Ell 2024-12-05 22:21:33 +01:00
parent 95838ff567
commit 96cd5963f5
2 changed files with 10 additions and 5 deletions

View file

@ -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);
}

View file

@ -18,13 +18,15 @@ import java.util.function.Supplier;
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]);
@ -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);
}
}