Immersive Railroading

Immersive Railroading

3M Downloads

Implement dynamic cargo visualization for freight and tenders

cam72cam opened this issue ยท 2 comments

commented

The ability to render inventory items/blocks in the car/tender

commented

What still remains is a rendering system for the actual items in the car, streched by the inventory area of the car.

Example code for @FriedrichLP (from another one of my mods):

public class ShelvingTileRender extends TileEntitySpecialRenderer<ShelvingTile> {
	public void render(ShelvingTile te, double x, double y, double z, float partialTicks, int destroyStage, float alpha) {
		if (te.isOrigin()) {
			ItemStackHandler container = te.getContainer();
            RenderHelper.enableStandardItemLighting();
            GL11.glPushMatrix();
            {
            	GL11.glTranslated(x+0.5, y+0.5, z+0.5);
            	GL11.glRotated(te.getFacing().getHorizontalAngle(), 0, 1, 0);
            	
				double scale = 0.4;
				GL11.glScaled(scale, scale, scale);
				GL11.glTranslated(0.5, 0.5, 0.5);
				
				double width = te.getSize() * ShelvingTile.INV_WIDTH_MULT;
				double depth = ShelvingTile.INV_ROWS;
				GL11.glTranslated(-width/2, 0, -depth/2);
	            for (int i = 0; i < container.getSlots(); i++) {
	            	GL11.glPushMatrix();
	            	{
		            	GL11.glTranslated(i % (width), 0, Math.floor(i / width));
		            	Minecraft.getMinecraft().getRenderItem().renderItem(container.getStackInSlot(i), ItemCameraTransforms.TransformType.NONE);
		            }
	            	GL11.glPopMatrix();
	            }
            }
            GL11.glPopMatrix();
		}
	}
}

The critical bit is Minecraft.getMinecraft().getRenderItem().renderItem(container.getStackInSlot(i), ItemCameraTransforms.TransformType.NONE);

commented

Didn't fredrick just close this with :
// Cargo
CARGO_FILL_X("CARGO_FILL_#ID#"),