package de.ellpeck.naturesaura.reg; import de.ellpeck.naturesaura.NaturesAura; import de.ellpeck.naturesaura.items.ModItems; import net.minecraft.inventory.EquipmentSlotType; import net.minecraft.item.IArmorMaterial; import net.minecraft.item.crafting.Ingredient; import net.minecraft.util.LazyValue; import net.minecraft.util.SoundEvent; import net.minecraft.util.SoundEvents; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import java.util.function.Supplier; public enum ModArmorMaterial implements IArmorMaterial { INFUSED(NaturesAura.MOD_ID + ":infused_iron", 19, new int[]{2, 5, 6, 2}, 16, SoundEvents.ITEM_ARMOR_EQUIP_GENERIC, 0, () -> Ingredient.fromItems(ModItems.INFUSED_IRON)), SKY(NaturesAura.MOD_ID + ":sky", 33, new int[]{3, 6, 8, 3}, 12, SoundEvents.ITEM_ARMOR_EQUIP_GENERIC, 2, () -> Ingredient.fromItems(ModItems.SKY_INGOT)); private static final int[] MAX_DAMAGE_ARRAY = new int[]{13, 15, 16, 11}; private final String name; private final int maxDamageFactor; private final int[] damageReductionAmountArray; private final int enchantability; private final SoundEvent soundEvent; private final float toughness; private final LazyValue repairMaterial; ModArmorMaterial(String nameIn, int maxDamageFactorIn, int[] damageReductionAmountsIn, int enchantabilityIn, SoundEvent equipSoundIn, float toughness, Supplier repairMaterialSupplier) { this.name = nameIn; this.maxDamageFactor = maxDamageFactorIn; this.damageReductionAmountArray = damageReductionAmountsIn; this.enchantability = enchantabilityIn; this.soundEvent = equipSoundIn; this.toughness = toughness; this.repairMaterial = new LazyValue<>(repairMaterialSupplier); } @Override public int getDurability(EquipmentSlotType slotIn) { return MAX_DAMAGE_ARRAY[slotIn.getIndex()] * this.maxDamageFactor; } @Override public int getDamageReductionAmount(EquipmentSlotType slotIn) { return this.damageReductionAmountArray[slotIn.getIndex()]; } @Override public int getEnchantability() { return this.enchantability; } @Override public SoundEvent getSoundEvent() { return this.soundEvent; } @Override public Ingredient getRepairMaterial() { return this.repairMaterial.getValue(); } @Override @OnlyIn(Dist.CLIENT) public String getName() { return this.name; } @Override public float getToughness() { return this.toughness; } }