Advertisement
Superloup10

Untitled

Mar 17th, 2019
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.82 KB | None | 0 0
  1. package fr.silvergames.common.init;
  2.  
  3. import net.minecraft.init.SoundEvents;
  4. import net.minecraft.inventory.EntityEquipmentSlot;
  5. import net.minecraft.item.IArmorMaterial;
  6. import net.minecraft.item.crafting.Ingredient;
  7. import net.minecraft.util.LazyLoadBase;
  8. import net.minecraft.util.SoundEvent;
  9. import net.minecraftforge.api.distmarker.Dist;
  10. import net.minecraftforge.api.distmarker.OnlyIn;
  11.  
  12. import java.util.function.Supplier;
  13.  
  14. public enum SGArmorMaterial implements IArmorMaterial {
  15.     SILVER("silver", 15, new int[] {2, 6, 5, 2}, 12, SoundEvents.ITEM_ARMOR_EQUIP_IRON, 0, () -> Ingredient.fromItems(SGItem.SILVER_INGOT));
  16.  
  17.     /**
  18.      * Holds the 'base' maxDamage that each armorType have.
  19.      */
  20.     private static final int[] MAX_DAMAGE_ARRAY = new int[] {13, 15, 16, 11};
  21.     private final String name;
  22.     /**
  23.      * Holds the maximum damage factor (each piece multiply this by it's own value) of the material, this is the item
  24.      * damage (how much can absorb before breaks)
  25.      */
  26.     private final int maxDamageFactor;
  27.     /**
  28.      * Holds the damage reduction (each 1 points is half a shield on gui) of each piece of armor (helmet, plate, legs and
  29.      * boots)
  30.      */
  31.     private final int[] damageReductionAmountArray;
  32.     /**
  33.      * Return the enchantability factor of the material
  34.      */
  35.     private final int enchantability;
  36.     private final SoundEvent soundEvent;
  37.     private final float toughness;
  38.     private final LazyLoadBase<Ingredient> repairMaterial;
  39.  
  40.     SGArmorMaterial(String nameIn, int maxDamage, int[] damageReductionAmountArray, int enchantability, SoundEvent soundEvent, float toughness, Supplier<Ingredient> repairMaterial) {
  41.         this.name = nameIn;
  42.         this.maxDamageFactor = maxDamage;
  43.         this.damageReductionAmountArray = damageReductionAmountArray;
  44.         this.enchantability = enchantability;
  45.         this.soundEvent = soundEvent;
  46.         this.toughness = toughness;
  47.         this.repairMaterial = new LazyLoadBase<>(repairMaterial);
  48.     }
  49.  
  50.     @Override
  51.     public int getDurability(EntityEquipmentSlot slotIn) {
  52.         return MAX_DAMAGE_ARRAY[slotIn.getIndex()] * this.maxDamageFactor;
  53.     }
  54.  
  55.     @Override
  56.     public int getDamageReductionAmount(EntityEquipmentSlot slotIn) {
  57.         return this.damageReductionAmountArray[slotIn.getIndex()];
  58.     }
  59.  
  60.     @Override
  61.     public int getEnchantability() {
  62.         return this.enchantability;
  63.     }
  64.  
  65.     @Override
  66.     public SoundEvent getSoundEvent() {
  67.         return this.soundEvent;
  68.     }
  69.  
  70.     @Override
  71.     public Ingredient getRepairMaterial() {
  72.         return this.repairMaterial.getValue();
  73.     }
  74.  
  75.     @Override
  76.     @OnlyIn(Dist.CLIENT)
  77.     public String getName() {
  78.         return this.name;
  79.     }
  80.  
  81.     @Override
  82.     public float getToughness() {
  83.         return this.toughness;
  84.     }
  85. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement