You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

75 lines
2.5 KiB
Java

package net.fabricmc.example;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.entity.EquipmentSlot;
import net.minecraft.item.ArmorMaterial;
import net.minecraft.item.Items;
import net.minecraft.recipe.Ingredient;
import net.minecraft.sound.SoundEvent;
import net.minecraft.sound.SoundEvents;
import net.minecraft.util.Lazy;
import java.util.function.Supplier;
public enum GoldNetherite implements ArmorMaterial {
GOLD_NETHERITE("gold_netherite", 37, new int[]{3, 8, 6, 3}, 25, SoundEvents.ITEM_ARMOR_EQUIP_NETHERITE, 3.0F, 1.0F, () -> {
return Ingredient.ofItems(Items.NETHERITE_INGOT);
});
private static final int[] BASE_DURABILITY = {13, 15, 16, 11};
private final String name;
private final int durabilityMultiplier;
private final int[] armorValues;
private final int enchantability;
private final SoundEvent equipSound;
private final float toughness;
private final float knockbackResistance;
private final Lazy<Ingredient> repairIngredient;
GoldNetherite(String name, int durabilityMultiplier, int[] armorValueArr, int enchantability, SoundEvent soundEvent, float toughness, float knockbackResistance, Supplier<Ingredient> repairIngredient) {
this.name = name;
this.durabilityMultiplier = durabilityMultiplier;
this.armorValues = armorValueArr;
this.enchantability = enchantability;
this.equipSound = soundEvent;
this.toughness = toughness;
this.knockbackResistance = knockbackResistance;
this.repairIngredient = new Lazy(repairIngredient);
}
public int getDurability(EquipmentSlot equipmentSlot_1) {
return BASE_DURABILITY[equipmentSlot_1.getEntitySlotId()] * this.durabilityMultiplier;
}
public int getProtectionAmount(EquipmentSlot equipmentSlot_1) {
return this.armorValues[equipmentSlot_1.getEntitySlotId()];
}
public int getEnchantability() {
return this.enchantability;
}
public SoundEvent getEquipSound() {
return this.equipSound;
}
public Ingredient getRepairIngredient() {
// We needed to make it a Lazy type so we can actually get the Ingredient from the Supplier.
return this.repairIngredient.get();
}
@Environment(EnvType.CLIENT)
public String getName() {
return this.name;
}
public float getToughness() {
return this.toughness;
}
public float getKnockbackResistance() {
return this.knockbackResistance;
}
}