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

84 lines
3 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;
2023-07-08 12:32:27 +02:00
import net.minecraft.world.item.ArmorItem;
2021-12-05 23:32:31 +01:00
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
2023-03-02 14:40:57 +01:00
INFUSED(NaturesAura.MOD_ID + ":infused_iron", 19, new int[]{2, 5, 6, 2}, 16, SoundEvents.ARMOR_EQUIP_IRON, 0, 0, () -> Ingredient.of(ModItems.INFUSED_IRON)),
SKY(NaturesAura.MOD_ID + ":sky", 33, new int[]{3, 6, 8, 3}, 12, SoundEvents.ARMOR_EQUIP_DIAMOND, 2, 0, () -> Ingredient.of(ModItems.SKY_INGOT)),
DEPTH(NaturesAura.MOD_ID + ":depth", 37, new int[]{3, 6, 8, 3}, 18, SoundEvents.ARMOR_EQUIP_NETHERITE, 3, 1, () -> Ingredient.of(ModItems.DEPTH_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;
2023-03-02 14:40:57 +01:00
private final float knockbackResistance;
2021-12-05 23:32:31 +01:00
private final Lazy<Ingredient> repairMaterial;
2019-11-04 19:08:49 +01:00
2023-03-02 14:40:57 +01:00
ModArmorMaterial(String nameIn, int maxDamageFactorIn, int[] damageReductionAmountsIn, int enchantabilityIn, SoundEvent equipSoundIn, float toughness, float knockbackResistance, 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;
2023-03-02 14:40:57 +01:00
this.knockbackResistance = knockbackResistance;
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
2023-07-08 12:32:27 +02:00
public int getDurabilityForType(ArmorItem.Type p_266807_) {
return ModArmorMaterial.MAX_DAMAGE_ARRAY[p_266807_.getSlot().getIndex()] * this.maxDamageFactor;
2019-11-04 19:08:49 +01:00
}
2020-01-21 21:04:44 +01:00
@Override
2023-07-08 12:32:27 +02:00
public int getDefenseForType(ArmorItem.Type p_266807_) {
return this.damageReductionAmountArray[p_266807_.getSlot().getIndex()];
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 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() {
2023-03-02 14:40:57 +01:00
return this.knockbackResistance;
2020-09-22 03:17:02 +02:00
}
2019-11-04 19:08:49 +01:00
}