Add the ability to add render layers to the player

Published by Inf3rnado on
Status
Won't fix
Issue description

So, the title basically covers a cool feature that should be used in MCreator. Incase you don't know, here's what is actually possible with render layers:https://gyazo.com/db047fd30f7d3bc1243cc1dce75005d5

As you can see, with this, players will also be able to make their own models (of course, animating them is difficult), but they could easily make non moving equipment on the player. This is the code for my render layer (note that I am using Baubles as a dependency).

package com.flashfyre.fyrecraft.entity.render.layer;

import com.flashfyre.fyrecraft.entity.model.armour.ModelBlazeArms;
import com.flashfyre.fyrecraft.init.FyItems;

import baubles.api.BaubleType;
import baubles.api.BaublesApi;
import baubles.api.cap.IBaublesItemHandler;
import net.minecraft.client.entity.AbstractClientPlayer;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.entity.RenderPlayer;
import net.minecraft.client.renderer.entity.layers.LayerRenderer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;

public class LayerBlazeArms implements LayerRenderer<AbstractClientPlayer> {
	
	private final RenderPlayer playerRenderer;
	private static final ResourceLocation TEXTURE_BLAZE = new ResourceLocation("textures/entity/blaze.png");
	public static final ModelBlazeArms model = new ModelBlazeArms();
	
	public LayerBlazeArms(RenderPlayer playerRendererIn)
	{
		this.playerRenderer = playerRendererIn;
	}

	@Override
	public boolean shouldCombineTextures() {
		return false;
	}

	@Override
	public void doRenderLayer(AbstractClientPlayer player, float limbSwing, float limbSwingAmount,
			float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale) {
		IBaublesItemHandler baubles = BaublesApi.getBaublesHandler(player);
		ItemStack stack = baubles.getStackInSlot(BaubleType.AMULET.ordinal());
		if(stack.getItem() == FyItems.BLAZE_AMULET) {
			GlStateManager.pushMatrix();
			GlStateManager.color(1, 1, 1);
			playerRenderer.bindTexture(TEXTURE_BLAZE);		
			model.render(player, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale);
			model.setRotationAngles(limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale, player);
			GlStateManager.popMatrix();
		}
	}
}

Now, the doRenderLayer method is called every tick, so you can see mine only renders with an item. Using the procedure editor in MCreator you would be able to do this using all sorts of conditions! I'm sure you are aware of the possibilities. The other thing you would need, is the model and texture, as you can see with the two static final variables. The model used is a variation of the Blaze without the head, and the texture (ResourceLocation) points to the Blaze texture within Minecraft. Of course, for a custom texture you just add the mod ID with a colon before "textures".

And that, is about it. Hopefully you implement this soon, as it really isn't that hard!

Issue comments

Thank you for these code examples. There is no simple way to attach such layers to the player using our current procedure system implementation. We might implement this sometimes, but not soon as there are many much more needed features at the moment.

Just saying, there is absolutely no reason why you couldn't just add this.

1) Create new mod element
2) Be able to import the model to use
3) Make conditions like isDay/night, does player have x in slot, etc etc

 

Plus, if you are saying there are many more needed features... why don't you actually implement those?

it would be cool if you made a forum post describing what you did as im having some trouble doing this like are you using a procedure or a custom code element