package net.blay09.mods.cookingforblockheads.client.render;

import com.mojang.blaze3d.matrix.MatrixStack;
import net.blay09.mods.cookingforblockheads.block.BlockKitchen;
import net.blay09.mods.cookingforblockheads.tile.SpiceRackTileEntity;
import net.minecraft.block.BlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.IRenderTypeBuffer;
import net.minecraft.client.renderer.ItemRenderer;
import net.minecraft.client.renderer.Quaternion;
import net.minecraft.client.renderer.tileentity.TileEntityRenderer;
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
import net.minecraft.item.ItemStack;

public class SpiceRackRenderer extends TileEntityRenderer<SpiceRackTileEntity> {

    public SpiceRackRenderer(TileEntityRendererDispatcher dispatcher) {
        super(dispatcher);
    }

    @Override
    public void render(SpiceRackTileEntity tileEntity, float partialTicks, MatrixStack matrixStack, IRenderTypeBuffer buffer, int combinedLight, int combinedOverlay) {
        if (!tileEntity.hasWorld()) {
            return;
        }

        BlockState state = tileEntity.getBlockState();
        float angle = state.get(BlockKitchen.FACING).getHorizontalAngle();

        ItemRenderer itemRenderer = Minecraft.getInstance().getItemRenderer();
        matrixStack.push();
        matrixStack.translate(0.5, 0.6, 0.5);
        matrixStack.rotate(new Quaternion(0f, angle, 0f, true));
        matrixStack.translate(0, 0, 0.4);
        matrixStack.rotate(new Quaternion(0f, 90f, 0f, true));
        matrixStack.scale(0.5f, 0.5f, 0.5f);
        for (int i = 0; i < tileEntity.getItemHandler().getSlots(); i++) {
            ItemStack itemStack = tileEntity.getItemHandler().getStackInSlot(i);
            if (!itemStack.isEmpty()) {
                // TODO RenderUtils.renderItem(itemRenderer, itemStack, 0.15f, 0.35f, 0.8f - i * 0.2f, -30f, 0f, 1f, 0f);
            }
        }

        matrixStack.pop();
    }

}

@@ -148,174 +148,32 @@
 ads.
-block.BlockKitchen;%0Aimport net.blay09.mods.cookingforblockheads.tile.SpiceRackTileEntity;%0Aimport net.minecraft.block.BlockState;%0Aimport net.minecraft.client.Minecraft
+tile.SpiceRackTileEntity
 ;%0Aim
@@ -230,59 +230,8 @@
 er;%0A
-import net.minecraft.client.renderer.ItemRenderer;%0A
 impo
@@ -910,139 +910,36 @@
     
-BlockState state = tileEntity.getBlockState();%0A        float angle = state.get(BlockKitchen.FACING).getHorizontalAngle
+matrixStack.push
 ();%0A
-%0A
         
 Item
@@ -938,214 +938,74 @@
     
-Item
 Render
-er itemRenderer = Minecraft.getInstance().getItemRenderer();%0A        matrixStack.push();%0A        matrixStack.translate(0.5, 0.6, 0.5);%0A        matrixStack.rotate(new Quaternion(0f, angle, 0f, true
+Utils.applyBlockAngle(matrixStack, tileEntity.getBlockState(
 ));%0A
@@ -1038,17 +1038,24 @@
 ate(
-0, 0
+-0.4, 0.75
 , 
+-
 0.
-4
+3
 );%0A 
@@ -1377,111 +1377,276 @@
     
-// TODO RenderUtils.renderItem(itemRenderer, itemStack, 0.15f, 0.35f, 0.8f - i * 0.2f, -30f, 0f, 1f, 0f
+matrixStack.push();%0A                matrixStack.translate(0f, 0f, 0.2f * i);%0A                matrixStack.rotate(new Quaternion(0f, -20f, 0f, true));%0A                RenderUtils.renderItem(itemStack, combinedLight, matrixStack, buffer);%0A                matrixStack.pop(
 );%0A 

Fix spice rack rendering