package com.atsuishio.superbwarfare.tiers; import com.atsuishio.superbwarfare.init.ModItems; import net.minecraft.Util; import net.minecraft.sounds.SoundEvent; import net.minecraft.sounds.SoundEvents; import net.minecraft.util.LazyLoadedValue; import net.minecraft.world.item.ArmorItem; import net.minecraft.world.item.ArmorMaterial; import net.minecraft.world.item.crafting.Ingredient; import java.util.EnumMap; import java.util.function.Supplier; public enum ModArmorMaterial implements ArmorMaterial { CEMENTED_CARBIDE("cemented_carbide", 50, Util.make(new EnumMap<>(ArmorItem.Type.class), p -> { p.put(ArmorItem.Type.BOOTS, 3); p.put(ArmorItem.Type.LEGGINGS, 6); p.put(ArmorItem.Type.CHESTPLATE, 8); p.put(ArmorItem.Type.HELMET, 3); }), 10, SoundEvents.ARMOR_EQUIP_IRON, 4.0F, 0.05F, () -> Ingredient.of(ModItems.CEMENTED_CARBIDE_INGOT.get())), STEEL("steel", 35, Util.make(new EnumMap<>(ArmorItem.Type.class), p -> { p.put(ArmorItem.Type.BOOTS, 2); p.put(ArmorItem.Type.LEGGINGS, 5); p.put(ArmorItem.Type.CHESTPLATE, 7); p.put(ArmorItem.Type.HELMET, 2); }), 9, SoundEvents.ARMOR_EQUIP_IRON, 1.0F, 0.0F, () -> Ingredient.of(ModItems.STEEL_INGOT.get())); private static final EnumMap HEALTH_FUNCTION_FOR_TYPE = Util.make(new EnumMap<>(ArmorItem.Type.class), (p_266653_) -> { p_266653_.put(ArmorItem.Type.BOOTS, 13); p_266653_.put(ArmorItem.Type.LEGGINGS, 15); p_266653_.put(ArmorItem.Type.CHESTPLATE, 16); p_266653_.put(ArmorItem.Type.HELMET, 11); }); private final String name; private final int durabilityMultiplier; private final EnumMap protectionFunctionForType; private final int enchantmentValue; private final SoundEvent sound; private final float toughness; private final float knockbackResistance; private final LazyLoadedValue repairIngredient; ModArmorMaterial(String pName, int pDurabilityMultiplier, EnumMap pProtectionFunctionForType, int pEnchantmentValue, SoundEvent pSound, float pToughness, float pKnockbackResistance, Supplier pRepairIngredient) { this.name = pName; this.durabilityMultiplier = pDurabilityMultiplier; this.protectionFunctionForType = pProtectionFunctionForType; this.enchantmentValue = pEnchantmentValue; this.sound = pSound; this.toughness = pToughness; this.knockbackResistance = pKnockbackResistance; this.repairIngredient = new LazyLoadedValue<>(pRepairIngredient); } public int getDurabilityForType(ArmorItem.Type pType) { return HEALTH_FUNCTION_FOR_TYPE.get(pType) * this.durabilityMultiplier; } public int getDefenseForType(ArmorItem.Type pType) { return this.protectionFunctionForType.get(pType); } public int getEnchantmentValue() { return this.enchantmentValue; } public SoundEvent getEquipSound() { return this.sound; } public Ingredient getRepairIngredient() { return this.repairIngredient.get(); } public String getName() { return this.name; } public float getToughness() { return this.toughness; } public float getKnockbackResistance() { return this.knockbackResistance; } public String getSerializedName() { return this.name; } }