Jump to content

trienow

Members
  • Posts

    3
  • Joined

  • Last visited

Everything posted by trienow

  1. I got it to work. Just for future reference, I decided to take your advice and use instanceof and cast by dropping the generics (which do add up). It isn't pretty as Java gives me warnings, but at least no errors. public static void onEntityAddLayers(final EntityRenderersEvent.AddLayers evt) { for (String skin : evt.getSkins()) { final LivingEntityRenderer livingEntityRenderer = evt.getSkin(skin); if (livingEntityRenderer instanceof LivingEntityRenderer) { livingEntityRenderer.addLayer(new LayerTT<>(livingEntityRenderer)); } } } I then was able to make my layer class reference HumanoidModel<T> and also call copyPropertiesTo before calling the coloredCutoutModelCopyLayerRender. Take care!
  2. Hi diesieben! Thanks for your swift reply. I thought I called it through coloredCutoutModelCopyLayerRender, but I was wrong! As I made LayerTT's parent Model to an EntityModel and not a HumanoidModel, copyPropertiesTo was not copying all the expected model parts. Unfortunatly the EntityRenderersEvent.AddLayers Event only gives me a renderer for EntityModel<Player> and not HumanoidModel<Player>, so I'll have to figure something out there. Hopefully, without having to make my own Version of the PlayerRenderer. Thanks for giving me a direction
  3. 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
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.