Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package fr.silvergames.common.init;
- import net.minecraft.init.SoundEvents;
- import net.minecraft.inventory.EntityEquipmentSlot;
- import net.minecraft.item.IArmorMaterial;
- import net.minecraft.item.crafting.Ingredient;
- import net.minecraft.util.LazyLoadBase;
- import net.minecraft.util.SoundEvent;
- import net.minecraftforge.api.distmarker.Dist;
- import net.minecraftforge.api.distmarker.OnlyIn;
- import java.util.function.Supplier;
- public enum SGArmorMaterial implements IArmorMaterial {
- SILVER("silver", 15, new int[] {2, 6, 5, 2}, 12, SoundEvents.ITEM_ARMOR_EQUIP_IRON, 0, () -> Ingredient.fromItems(SGItem.SILVER_INGOT));
- /**
- * Holds the 'base' maxDamage that each armorType have.
- */
- private static final int[] MAX_DAMAGE_ARRAY = new int[] {13, 15, 16, 11};
- private final String name;
- /**
- * Holds the maximum damage factor (each piece multiply this by it's own value) of the material, this is the item
- * damage (how much can absorb before breaks)
- */
- private final int maxDamageFactor;
- /**
- * Holds the damage reduction (each 1 points is half a shield on gui) of each piece of armor (helmet, plate, legs and
- * boots)
- */
- private final int[] damageReductionAmountArray;
- /**
- * Return the enchantability factor of the material
- */
- private final int enchantability;
- private final SoundEvent soundEvent;
- private final float toughness;
- private final LazyLoadBase<Ingredient> repairMaterial;
- SGArmorMaterial(String nameIn, int maxDamage, int[] damageReductionAmountArray, int enchantability, SoundEvent soundEvent, float toughness, Supplier<Ingredient> repairMaterial) {
- this.name = nameIn;
- this.maxDamageFactor = maxDamage;
- this.damageReductionAmountArray = damageReductionAmountArray;
- this.enchantability = enchantability;
- this.soundEvent = soundEvent;
- this.toughness = toughness;
- this.repairMaterial = new LazyLoadBase<>(repairMaterial);
- }
- @Override
- public int getDurability(EntityEquipmentSlot slotIn) {
- return MAX_DAMAGE_ARRAY[slotIn.getIndex()] * this.maxDamageFactor;
- }
- @Override
- public int getDamageReductionAmount(EntityEquipmentSlot 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;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement