com.magistuarmory.item.armor.MedievalArmorItem Maven / Gradle / Ivy
package com.magistuarmory.item.armor;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.model.HumanoidModel;
import net.minecraft.client.model.geom.EntityModelSet;
import net.minecraft.client.model.geom.ModelLayerLocation;
import net.minecraft.client.renderer.entity.EntityRendererProvider;
import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.item.ArmorItem;
import net.minecraft.world.item.ArmorMaterial;
import java.util.Optional;
public class MedievalArmorItem extends ArmorItem implements ISurcoat
{
protected Optional> model = Optional.empty();
public MedievalArmorItem(ArmorMaterial material, EquipmentSlot type, Properties properties)
{
super(material, type, properties);
}
@Environment(EnvType.CLIENT)
public void loadModel(EntityModelSet context)
{
if (this.f_40379_ instanceof ArmorType armortype)
{
Optional location = armortype.getModelLocation();
location.ifPresent(loc -> this.model = Optional.of(new HumanoidModel<>(context.m_171103_(loc))));
}
}
@Environment(EnvType.CLIENT)
public HumanoidModel extends LivingEntity> getArmorModel(EquipmentSlot slot, HumanoidModel extends LivingEntity> _default)
{
return slot == this.f_40377_ && this.model.isPresent() ? this.model.get() : _default;
}
}