Jump to content

[1.16.5] Model not binding texture correctly


That_Martin_Guy

Recommended Posts

I have a tile entity renderer that renders a model. Code looks like this

 

    private static final ResourceLocation TEXTURE = ResourceHelper.createNew("block/test.png");

    private final ClockworksDoorModel model;
    private final RenderMaterial doorMaterial;

    public ClockworksDoorTileEntityRenderer(TileEntityRendererDispatcher dispatcher)
    {
        super(dispatcher);

        model = new ClockworksDoorModel();

        doorMaterial = new RenderMaterial(PlayerContainer.BLOCK_ATLAS, TEXTURE);
    }

    @Override
    public void render(ClockworksDoorTileEntity tileEntity, float partialTicks, MatrixStack matrixStack, IRenderTypeBuffer buffer, int combinedLight, int combinedOverlay)
    {
        IVertexBuilder builder = doorMaterial.buffer(buffer, RenderType::entityCutoutNoCull);

        model.renderToBuffer(matrixStack, builder, combinedLight, combinedOverlay, 1, 1, 1, 1);
    }

In game, however, it has the black and purple missing texture. When examining the log it does not report anything about missing textures if I put the path correctly, so I can only assume it's correctly finding my texture.

Link to comment
Share on other sites

Please show the entire class and the ClockworksDoorModel. I'm imagining you are incorrectly binding information here. The block atlas will not hold your texture unless some block is also using it. Also, RenderMaterials do not contain the full path, just a relative ResourceLocation. I would instead follow the BoatRenderer model here since it will be much easier to use with the current data you are trying to draw.

Link to comment
Share on other sites

The code I posted was in fact the entire tile entity renderer, minus the class declaration. I have added some small stuff since for testing, but overall its the same and should be very similar to the enchanting table renderer.

public class ClockworksDoorTileEntityRenderer extends TileEntityRenderer<ClockworksDoorTileEntity>
{
    private static final ResourceLocation TEXTURE = ResourceHelper.createNew("block/test.png");

    private final ClockworksDoorModel model;
    private final RenderMaterial doorMaterial;

    public ClockworksDoorTileEntityRenderer(TileEntityRendererDispatcher dispatcher)
    {
        super(dispatcher);

        model = new ClockworksDoorModel();

        doorMaterial = new RenderMaterial(PlayerContainer.BLOCK_ATLAS, TEXTURE);
    }

    @Override
    public void render(ClockworksDoorTileEntity tileEntity, float partialTicks, MatrixStack matrixStack, IRenderTypeBuffer buffer, int combinedLight, int combinedOverlay)
    {
        matrixStack.pushPose();
        IVertexBuilder builder = doorMaterial.buffer(buffer, RenderType::entitySolid);

        model.renderToBuffer(matrixStack, builder, combinedLight, combinedOverlay, 1, 1, 1, 1);
        matrixStack.popPose();
    }
}

The model itself is just a basic model. Not much to showcase, but since I was asked I'll do it anyway.

public class ClockworksDoorModel extends Model
{
	private final ModelRenderer model;

	public ClockworksDoorModel()
	{
		super(RenderType::entitySolid);
		texWidth = 64;
		texHeight = 64;

		model = new ModelRenderer(this);
		model.setPos(8, 32, 8);
		model.texOffs(0, 0).addBox(-8.0F, -32.0F, -8.0F, 16.0F, 32.0F, 3.0F, 0.0F, false);
	}

	@Override
	public void renderToBuffer(MatrixStack matrixStack, IVertexBuilder builder, int partialLight, int partialOverlay, float red, float green, float blue, float alpha)
	{
		model.render(matrixStack, builder, partialLight, partialOverlay);
	}
}

 

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.

Guest
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.

Announcements



×
×
  • Create New...

Important Information

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