Jump to content

[1.15.2][SOLVED] Render Item with TileEntityRenderer


Boy132

Recommended Posts

Hello,

I updated my mod files from 1.14.4 to 1.15.2 but now me block doesn't render the item

public class TERChoppingBlock extends TileEntityRenderer<TileEntityChoppingBlock>
{
	public TERChoppingBlock(TileEntityRendererDispatcher rendererDispatcher)
	{
		super(rendererDispatcher);
	}

	@Override
	public void render(TileEntityChoppingBlock tileEntityChoppingBlock, float partialTicks, MatrixStack matrixStack, IRenderTypeBuffer buffer, int combinedLight, int combinedOverlay)
	{
//		GlStateManager.pushLightingAttributes();
//		GlStateManager.pushMatrix();
		matrixStack.push();

		BlockPos blockPos = tileEntityChoppingBlock.getPos();
//		GlStateManager.translated(blockPos.getX(), blockPos.getY(), blockPos.getZ());
//		GlStateManager.disableRescaleNormal();
		matrixStack.translate(blockPos.getX(), blockPos.getY(), blockPos.getZ());
		renderItem(tileEntityChoppingBlock, matrixStack, buffer, combinedLight, combinedOverlay);

		matrixStack.pop();
//		GlStateManager.popMatrix();
//		GlStateManager.popAttributes();
	}

	private void renderItem(TileEntityChoppingBlock tileEntityChoppingBlock, MatrixStack matrixStack, IRenderTypeBuffer buffer, int combinedLight, int combinedOverlay)
	{
		IItemHandler itemHandler = tileEntityChoppingBlock.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null).orElse(null);
		
		if(itemHandler != null)
		{
			ItemStack stack = itemHandler.getStackInSlot(0);
			
			if(!stack.isEmpty())
			{
				RenderHelper.enableStandardItemLighting();
//				GlStateManager.enableLighting();
//				GlStateManager.pushMatrix();
				matrixStack.push();

//				GlStateManager.scaled(0.5f, 0.5f, 0.5f);
//				GlStateManager.translated(1, 1.5, 1);
//				GlStateManager.rotatef(-90, 0f, 1f, 0f);
				matrixStack.scale(0.5f, 0.5f, 0.5f);
				matrixStack.translate(1, 1.5, 1);
				matrixStack.rotate(new Quaternion(0f, 1f, 0f, -90));

				Minecraft.getInstance().getItemRenderer().renderItem(stack, TransformType.NONE, combinedLight, combinedOverlay, matrixStack, buffer);
//				Minecraft.getInstance().getItemRenderer().renderItem(stack, TransformType.NONE);

				matrixStack.pop();
//				GlStateManager.popMatrix();
			}
		}
	}
}

In the comments is my older 1.14 code.

 

Wanted behavior from 1.14: (now in 1.15 the log block doesn't render)

Screen.png.31546a9ca470b82c9c4bc4855fd09962.png

 

 

 

EDIT:

I removed this line "matrixStack.translate(blockPos.getX(), blockPos.getY(), blockPos.getZ());" and now this is the result: (o.O)

Spoiler

2020-04-24_18_48_21.png.2b56738846d07cf10609f616270d63a0.png

 

Edited by Boy132
Link to comment
Share on other sites

Works now: (it was didn't work because of the "matrixStack.rotate")

RenderHelper.enableStandardItemLighting();
				
matrixStack.push();

matrixStack.scale(0.5f, 0.5f, 0.5f);
matrixStack.translate(1, 1.5, 1);

Minecraft.getInstance().getItemRenderer().renderItem(stack, TransformType.NONE, combinedLight, combinedOverlay, matrixStack, buffer);

matrixStack.pop();

 

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.