Hi, I'm trying to add this as a constant render layer on the player. This works perfectly, unless the player crouches:
Interestingly enough, if I add the model as a model for armor, it works just fine:
I almost feel like I'm missing something obvious, like getting the rotation angles from somewhere, but am oblivious to where it could get them from.
In my RenderSetup I add the render layer:
@Mod.EventBusSubscriber(modid = Main.MODID, value = Dist.CLIENT, bus = Mod.EventBusSubscriber.Bus.MOD)
public class RenderSetup
{
public static final ResourceLocation KNIGHT_LAYER_TEXTURE = new ResourceLocation(Main.MODID, "textures/models/armor/knight_layer_1.png");
public static final ModelLayerLocation KNIGHT_LAYER_LOCATION = new ModelLayerLocation(KNIGHT_LAYER_TEXTURE, "knight");
@SubscribeEvent
public static void onRegisterLayerDefinition(final EntityRenderersEvent.RegisterLayerDefinitions evt)
{
evt.registerLayerDefinition(KNIGHT_LAYER_LOCATION, ModelKnight::createLayer);
}
@SubscribeEvent
public static void onEntityAddLayers(final EntityRenderersEvent.AddLayers evt)
{
for (String skin : evt.getSkins())
{
final LivingEntityRenderer<Player, EntityModel<Player>> renderer = evt.getSkin(skin);
renderer.addLayer(new LayerTT<>(renderer));
}
}
}
And my LayerTT looks like this:
public class LayerTT<T extends LivingEntity, M extends EntityModel<T>> extends RenderLayer<T, M>
{
private final ModelKnight<T> MODEL_KNIGHT_HEAD;
private final ModelKnight<T> MODEL_KNIGHT_CHEST;
private final ModelKnight<T> MODEL_KNIGHT_LEGS;
private final ModelKnight<T> MODEL_KNIGHT_FEET;
public LayerTT(RenderLayerParent<T, M> entityRendererOwner)
{
super(entityRendererOwner);
final ModelPart bakedKnight = Minecraft.getInstance().getEntityModels().bakeLayer(RenderSetup.KNIGHT_LAYER_LOCATION);
this.MODEL_KNIGHT_HEAD = new ModelKnight<>(EquipmentSlot.HEAD, bakedKnight);
this.MODEL_KNIGHT_CHEST = new ModelKnight<>(EquipmentSlot.CHEST, bakedKnight);
this.MODEL_KNIGHT_LEGS = new ModelKnight<>(EquipmentSlot.LEGS, bakedKnight);
this.MODEL_KNIGHT_FEET = new ModelKnight<>(EquipmentSlot.FEET, bakedKnight);
}
@Override
public void render(PoseStack pMatrixStack, MultiBufferSource pBuffer, int pPackedLight, T pLivingEntity, float pLimbSwing, float pLimbSwingAmount, float pPartialTicks, float pAgeInTicks, float pNetHeadYaw, float pHeadPitch)
{
pMatrixStack.pushPose();
M parentModel = this.getParentModel();
coloredCutoutModelCopyLayerRender(parentModel, MODEL_KNIGHT_HEAD, RenderSetup.KNIGHT_LAYER_TEXTURE, pMatrixStack, pBuffer, pPackedLight, pLivingEntity, pLimbSwing, pLimbSwingAmount, pAgeInTicks, pNetHeadYaw, pHeadPitch, pPartialTicks, 1, 1, 1);
coloredCutoutModelCopyLayerRender(parentModel, MODEL_KNIGHT_CHEST, RenderSetup.KNIGHT_LAYER_TEXTURE, pMatrixStack, pBuffer, pPackedLight, pLivingEntity, pLimbSwing, pLimbSwingAmount, pAgeInTicks, pNetHeadYaw, pHeadPitch, pPartialTicks, 1, 1, 1);
coloredCutoutModelCopyLayerRender(parentModel, MODEL_KNIGHT_LEGS, RenderSetup.KNIGHT_LAYER_TEXTURE, pMatrixStack, pBuffer, pPackedLight, pLivingEntity, pLimbSwing, pLimbSwingAmount, pAgeInTicks, pNetHeadYaw, pHeadPitch, pPartialTicks, 1, 1, 1);
coloredCutoutModelCopyLayerRender(parentModel, MODEL_KNIGHT_FEET, RenderSetup.KNIGHT_LAYER_TEXTURE, pMatrixStack, pBuffer, pPackedLight, pLivingEntity, pLimbSwing, pLimbSwingAmount, pAgeInTicks, pNetHeadYaw, pHeadPitch, pPartialTicks, 1, 1, 1);
pMatrixStack.popPose();
}
}
I'd be happy if anyone could give me a direction of where to look. Thanks