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

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 getArmorModel(EquipmentSlot slot, HumanoidModel _default)
	{
		return slot == this.f_40377_ && this.model.isPresent() ? this.model.get() : _default;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy