Jump to content

[1.15/1.14] Render armor visually as an elytra


Recommended Posts

Alright, so I've searched for quite a while now, but I haven't found anything that significantly helped me, so I thought I'd just ask here instead.

I have an ArmorItem that works as intended, I can equip it onto the chest slot and it renders the checkerboard error texture (as intended).
Now, I'm developing for 1.15, but I'd take any help, as 1.15 doesn't have a lot of mappings so far, so if you know how to do it in 1.14, go ahead and explain how to do what I'd like to do in 1.14, that might also help me, working without mappings is hard.


I would like to render my armor with the elytra model + texture instead of the "default" armor model, and I've gathered to do what I want I'll have to swap render layers/add my own render layer. So far I have copied the ElytraLayer class 1:1 into my own class to later modify to my liking, however I don't quite get how I get it to "show up" so to speak.

This is the code I have for that so far:


	public void renderPlayerEvent(RenderPlayerEvent event) {
		PlayerEntity p = event.getPlayer();
		ItemStack stack = p.getItemStackFromSlot(EquipmentSlotType.CHEST);
		if(stack.getItem() instanceof ItemCustomChestplate) {
			event.getRenderer().addLayer(new LayerCustomChestplate<AbstractClientPlayerEntity, PlayerModel<AbstractClientPlayerEntity>>(event.getRenderer()));

From what I've gathered so far, the addLayer call might not actually belong there, as it would keep adding the layer, instead something else has to go there.
So what I need to know (I think anyways) is:
Where do I add my renderlayer, how do I deactivate the default armor render layer (if necessary) and how do I then activate my custom renderlayer for my item?

I believe the code checking for my custom item in the chestplate slot should be fine as is, and I already tested whether the EventHandler gets called, that does happen, but I believe the addLayer Part is wrong. Any help?

Link to comment
Share on other sites

Alright, I figured it out on my own, but I'll leave this explanation here for anyone else that might encounter a problem with renderlayers, as there is no good guide on how they work out there I feel like!

Firstly, you have to add your layer only once, not multiple times! The layer "stays" in the renderer, add it again in the next tick and it will be there twice, and then thrice and so on. This will seriously impact performance, so don't do that! I'm not sure whether this layer has to be added per player or just once and then all playerentities have access to it? Some clarification on that by someone else would be nice! Either way, if you try to do what I did, you'll probably also just copy the ElytraLayer class. Now that's where my problem was, the class checks whether the player is wearing an elytra, removing that fixed my issue. Also, for anyone else asking themselves how to tell the game what to render or what not to render, that's how you do it! There is no function you need to call, you just surround your model with an if statement containing it's render condition. That way you control when it should be rendered and when it shouldn't! That's it! I would like some clarification on the question I asked earlier in this paragraph though, if at all possible, that would be neat!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...

Important Information

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