NaturesAura/src/main/java/de/ellpeck/naturesaura/reg/ModArmorMaterial.java

81 lines
2.6 KiB
Java
Raw Normal View History

2019-11-04 19:08:49 +01:00
package de.ellpeck.naturesaura.reg;
import de.ellpeck.naturesaura.NaturesAura;
import de.ellpeck.naturesaura.items.ModItems;
2021-12-05 23:32:31 +01:00
import net.minecraft.sounds.SoundEvent;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.item.ArmorMaterial;
import net.minecraft.world.item.crafting.Ingredient;
2019-11-04 19:08:49 +01:00
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
2021-12-05 23:32:31 +01:00
import net.minecraftforge.common.util.Lazy;
2019-11-04 19:08:49 +01:00
import java.util.function.Supplier;
2021-12-05 23:32:31 +01:00
public enum ModArmorMaterial implements ArmorMaterial {
2019-11-04 19:08:49 +01:00
2021-12-05 23:32:31 +01:00
INFUSED(NaturesAura.MOD_ID + ":infused_iron", 19, new int[]{2, 5, 6, 2}, 16, SoundEvents.ARMOR_EQUIP_GENERIC, 0, () -> Ingredient.of(ModItems.INFUSED_IRON)),
SKY(NaturesAura.MOD_ID + ":sky", 33, new int[]{3, 6, 8, 3}, 12, SoundEvents.ARMOR_EQUIP_GENERIC, 2, () -> Ingredient.of(ModItems.SKY_INGOT));
2019-11-04 19:08:49 +01:00
2023-02-15 23:45:50 +01:00
private static final int[] MAX_DAMAGE_ARRAY = {13, 15, 16, 11};
2019-11-04 19:08:49 +01:00
private final String name;
private final int maxDamageFactor;
private final int[] damageReductionAmountArray;
private final int enchantability;
private final SoundEvent soundEvent;
private final float toughness;
2021-12-05 23:32:31 +01:00
private final Lazy<Ingredient> repairMaterial;
2019-11-04 19:08:49 +01:00
2020-01-26 01:41:49 +01:00
ModArmorMaterial(String nameIn, int maxDamageFactorIn, int[] damageReductionAmountsIn, int enchantabilityIn, SoundEvent equipSoundIn, float toughness, Supplier<Ingredient> repairMaterialSupplier) {
2019-11-04 19:08:49 +01:00
this.name = nameIn;
this.maxDamageFactor = maxDamageFactorIn;
this.damageReductionAmountArray = damageReductionAmountsIn;
this.enchantability = enchantabilityIn;
this.soundEvent = equipSoundIn;
2020-01-21 21:04:44 +01:00
this.toughness = toughness;
2021-12-05 23:32:31 +01:00
this.repairMaterial = Lazy.of(repairMaterialSupplier);
2019-11-04 19:08:49 +01:00
}
2020-01-21 21:04:44 +01:00
@Override
2021-12-05 23:32:31 +01:00
public int getDurabilityForSlot(EquipmentSlot slotIn) {
2022-06-27 15:24:04 +02:00
return ModArmorMaterial.MAX_DAMAGE_ARRAY[slotIn.getIndex()] * this.maxDamageFactor;
2019-11-04 19:08:49 +01:00
}
2020-01-21 21:04:44 +01:00
@Override
2021-12-05 23:32:31 +01:00
public int getDefenseForSlot(EquipmentSlot slotIn) {
2019-11-04 19:08:49 +01:00
return this.damageReductionAmountArray[slotIn.getIndex()];
}
2020-01-21 21:04:44 +01:00
@Override
2021-12-05 23:32:31 +01:00
public int getEnchantmentValue() {
2019-11-04 19:08:49 +01:00
return this.enchantability;
}
2020-01-21 21:04:44 +01:00
@Override
2021-12-05 23:32:31 +01:00
public SoundEvent getEquipSound() {
2019-11-04 19:08:49 +01:00
return this.soundEvent;
}
2020-01-21 21:04:44 +01:00
@Override
2021-12-05 23:32:31 +01:00
public Ingredient getRepairIngredient() {
return this.repairMaterial.get();
2019-11-04 19:08:49 +01:00
}
2020-01-21 21:04:44 +01:00
@Override
2019-11-04 19:08:49 +01:00
@OnlyIn(Dist.CLIENT)
public String getName() {
return this.name;
}
2020-01-21 21:04:44 +01:00
@Override
2019-11-04 19:08:49 +01:00
public float getToughness() {
return this.toughness;
}
2020-09-22 03:17:02 +02:00
@Override
public float getKnockbackResistance() {
return 0;
}
2019-11-04 19:08:49 +01:00
}