Implement entity aware armor model and texture hooks. Closes #9960

This commit is contained in:
LexManos committed 2024-05-12 17:07:45 -07:00
1 parent 59a7bbdb57
commit 640c206117
4 files changed
+107 -5

No files matched your search

@@ -98,6 +98,7 @@ import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.ai.attributes.AttributeInstance;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.inventory.tooltip.TooltipComponent;
import net.minecraft.world.item.ArmorMaterial;
import net.minecraft.world.item.ItemDisplayContext;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.crafting.RecipeManager;
@@ -260,9 +261,9 @@ public class ForgeHooksClient {
MinecraftForge.EVENT_BUS.post(new ClientPauseChangeEvent.Post(pause));
}
public static String getArmorTexture(Entity entity, ItemStack armor, String _default, EquipmentSlot slot, String type) {
String result = armor.getItem().getArmorTexture(armor, entity, slot, type);
return result != null ? result : _default;
public static ResourceLocation getArmorTexture(Entity entity, ItemStack armor, EquipmentSlot slot, ArmorMaterial.Layer layer, boolean inner) {
var result = armor.getItem().getArmorTexture(armor, entity, slot, layer, inner);
return result != null ? result : layer.texture(inner);
}
public static boolean onDrawHighlight(LevelRenderer context, Camera camera, HitResult target, float partialTick, Matrix4f ctxPos, MultiBufferSource bufferSource) {
@@ -28,6 +28,7 @@ import net.minecraft.world.item.crafting.RecipeType;
import net.minecraft.world.InteractionResult;
import net.minecraft.core.BlockPos;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.Level;
import net.minecraftforge.common.ForgeHooks;
import net.minecraftforge.common.ToolAction;
@@ -326,11 +327,12 @@ public interface IForgeItem {
* @param stack ItemStack for the equipped armor
* @param entity The entity wearing the armor
* @param slot The slot the armor is in
* @param type The subtype, can be null or "overlay"
* @param layer The layer of the armor being rendered. Typically want to use {@alin ArmorMaterial.Layer#getSuffix()}.
* @param inner Weither or not to use the inner texture layer.
* @return Path of texture to bind, or null to use default
*/
@Nullable
default String getArmorTexture(ItemStack stack, Entity entity, EquipmentSlot slot, String type) {
default ResourceLocation getArmorTexture(ItemStack stack, Entity entity, EquipmentSlot slot, ArmorMaterial.Layer layer, boolean inner) {
return null;
}