All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.magistuarmory.item.armor.ArmorType Maven / Gradle / Ivy

package com.magistuarmory.item.armor;

import java.util.function.Supplier;

import com.magistuarmory.EpicKnights;
import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.tags.TagKey;
import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.item.ArmorMaterial;
import net.minecraft.world.item.crafting.Ingredient;

public final class ArmorType implements ArmorMaterial
{
	private final String name;
	private final float toughness;
	private final float knockbackResistance;
	private final int[] durability;
	private final int[] defenseForSlot;
	private final int enchantmentValue;
	private final SoundEvent equipSound;
	private final boolean enabled;

	private Supplier repairIngredient = () -> Ingredient.f_43901_;;

	ArmorType(String name, float toughness, float knockbackResistance, int[] durability, int[] defenseForSlot, int enchantmentValue, SoundEvent equipSound, boolean enabled)
	{
		this.name = EpicKnights.ID + ":" + name;
		this.toughness = toughness;
		this.knockbackResistance = knockbackResistance;
		this.durability = durability;
		this.defenseForSlot = defenseForSlot;
		this.enchantmentValue = enchantmentValue;
		this.equipSound = equipSound;
		this.enabled = enabled;
	}

	ArmorType(String name, float toughness, float knockbackResistance, int[] durability, int[] defenseForSlot, int enchantmentValue, SoundEvent equipSound, boolean enabled, Supplier repairIngredient)
	{
		this(name, toughness, knockbackResistance, durability, defenseForSlot, enchantmentValue, equipSound, enabled);
		this.repairIngredient = repairIngredient;
	}

	ArmorType(String name, float toughness, float knockbackResistance, int[] durability, int[] defenseForSlot, int enchantmentValue, SoundEvent equipSound, boolean enabled, String repairitemtag)
	{
		this(name, toughness, knockbackResistance, durability, defenseForSlot, enchantmentValue, equipSound, enabled);
		this.repairIngredient = () -> Ingredient.m_204132_(TagKey.m_203882_(Registry.f_122904_, new ResourceLocation(repairitemtag)));
	}

	@Override
	public String m_6082_() {
		return this.name;
	}

	@Override
	public float m_6651_() {
		return this.toughness;
	}

	@Override
	public float m_6649_() {
		return this.knockbackResistance;
	}

	@Override
	public int m_7366_(EquipmentSlot slot) {
		return this.durability[slot.m_20749_()];
	}

	@Override
	public int m_7365_(EquipmentSlot slot) {
		return this.defenseForSlot[slot.m_20749_()];
	}

	@Override
	public int m_6646_() {
		return this.enchantmentValue;
	}

	@Override
	public SoundEvent m_7344_() {
		return this.equipSound;
	}

	@Override
	public Ingredient m_6230_() {
		return this.repairIngredient.get();
	}

	public boolean isDisabled()
	{
		return !this.enabled;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy