Minecraft Fabric Tutorial 9 adding armor

Posted by Sianide on Sat, 22 Feb 2020 18:28:42 +0100

First appeared in Enaium's personal blog

Create a armor class

public class EndArmorMaterials implements ArmorMaterial {

Copy it

    private static final int[] BASE_DURABILITY = {13, 15, 16, 11};
    private final String name;
    private final int durabilityMultiplier;
    private final int[] protectionAmounts;
    private final int enchantability;
    private final SoundEvent equipSound;
    private final float toughness;
    private final Lazy<Ingredient> repairIngredientSupplier;

    public EndArmorMaterials(String name, int durabilityMultiplier, int[] armorValueArr, int enchantability, SoundEvent soundEvent, float toughness, Supplier<Ingredient> repairIngredient) {
        this.name = name;
        this.durabilityMultiplier = durabilityMultiplier;
        this.protectionAmounts = armorValueArr;
        this.enchantability = enchantability;
        this.equipSound = soundEvent;
        this.toughness = toughness;
        this.repairIngredientSupplier = new Lazy(repairIngredient);

    public int getDurability(EquipmentSlot equipmentSlot_1) {
        return BASE_DURABILITY[equipmentSlot_1.getEntitySlotId()] * this.durabilityMultiplier;

    public int getProtectionAmount(EquipmentSlot equipmentSlot_1) {
        return this.protectionAmounts[equipmentSlot_1.getEntitySlotId()];

    public int getEnchantability() {
        return this.enchantability;

    public SoundEvent getEquipSound() {
        return this.equipSound;

    public Ingredient getRepairIngredient() {
        return this.repairIngredientSupplier.get();

    public String getName() {
        return this.name;

    public float getToughness() {
        return this.toughness;

Then change class to enum

Making armor materials

public enum EndArmorMaterials implements ArmorMaterial {

    END("end_heart" , 15 , new int[]{1,3,2,1}, 15, SoundEvents.BLOCK_WOOL_PLACE,0.0F, () -> {
        return Ingredient.ofItems(Items.WHITE_WOOL);


Parameter 1: material name parameter 2: durability multiple parameter 3: Armor number, i.e. armor value added by armor parameter 4: sound parameter 5: durability when used

Create armor items

	public static final Item END_HELMET = new ArmorItem(EndArmorMaterials.END, EquipmentSlot.HEAD, (new Item.Settings().group(ItemGroup.COMBAT)));
	public static final Item END_CHESTPLATE = new ArmorItem(EndArmorMaterials.END, EquipmentSlot.CHEST, (new Item.Settings().group(ItemGroup.COMBAT)));
	public static final Item END_LEGGINGS = new ArmorItem(EndArmorMaterials.END, EquipmentSlot.LEGS, (new Item.Settings().group(ItemGroup.COMBAT)));
	public static final Item END_BOOTS = new ArmorItem(EndArmorMaterials.END, EquipmentSlot.FEET, (new Item.Settings().group(ItemGroup.COMBAT)));

Registered armor items

	Registry.register(Registry.ITEM,new Identifier("endarmor","end_helmet"), END_HELMET);
	Registry.register(Registry.ITEM,new Identifier("endarmor","end_chestplate"), END_CHESTPLATE);
	Registry.register(Registry.ITEM,new Identifier("endarmor","end_leggings"), END_LEGGINGS);
	Registry.register(Registry.ITEM,new Identifier("endarmor","end_boots"), END_BOOTS);

Adding texture

Add item texture first

It is found that only the item texture has no model texture after it is put on, and then the model is added

Location src\main\resources\assets\minecraft\textures\models\armor

There are two layers, end ﹣ heart ﹣ layer ﹣ 1.png and end ﹣ heart ﹣ layer ﹣ 2.png

Final effect

Topics: Programming