package com.leomelonseeds.moarstuff.client.render.blocks;
import com.leomelonseeds.moarstuff.blocks.BlockGrill;
import com.leomelonseeds.moarstuff.blocks.Modblocks;
import com.leomelonseeds.moarstuff.client.model.ModelGrill;
import com.leomelonseeds.moarstuff.tileentity.Grill;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.model.ModelChest;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.client.ForgeHooksClient;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class TileGrillRenderer extends TileEntitySpecialRenderer<Grill>
{
private static final ResourceLocation TEXTURE_BURNING = new ResourceLocation("moarstuff:textures/entity/grill/grill_on.png");
private static final ResourceLocation TEXTURE_NORMAL = new ResourceLocation("moarstuff:textures/entity/grill/grill_off.png");
private final ModelGrill simpleChest = new ModelGrill();
public TileGrillRenderer(){
}
@Override
public void renderTileEntityAt(Grill te, double x, double y, double z, float partialTicks, int destroyStage)
{
Grill grill = new Grill();
if(te != null){
GlStateManager.enableDepth();
GlStateManager.depthFunc(515);
GlStateManager.depthMask(true);
int i;
if (te.hasWorldObj())
{
Block block = te.getBlockType();
i = te.getBlockMetadata();
}
else
{
i = 0;
}
ModelGrill modelgrill = this.simpleChest;
if (destroyStage >= 0)
{
this.bindTexture(DESTROY_STAGES[destroyStage]);
GlStateManager.matrixMode(5890);
GlStateManager.pushMatrix();
GlStateManager.scale(4.0F, 4.0F, 1.0F);
GlStateManager.translate(0.0625F, 0.0625F, 0.0625F);
GlStateManager.matrixMode(5888);
}
else if(te.isBurning == true){
this.bindTexture(TEXTURE_BURNING);
}
else
{
this.bindTexture(TEXTURE_NORMAL);
}
GlStateManager.pushMatrix();
GlStateManager.enableRescaleNormal();
if (destroyStage < 0)
{
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
}
GlStateManager.translate((float)x, (float)y + 1.0F, (float)z + 1.0F);
GlStateManager.scale(1.0F, -1.0F, -1.0F);
GlStateManager.translate(0.5F, 0.5F, 0.5F);
int j = 0;
if (i == 2)
{
j = 180;
}
if (i == 3)
{
j = 0;
}
if (i == 4)
{
j = 90;
}
if (i == 5)
{
j = -90;
}
GlStateManager.rotate((float)j, 0.0F, 1.0F, 0.0F);
GlStateManager.translate(-0.5F, -0.5F, -0.5F);
float f = te.prevLidAngle + (te.lidAngle - te.prevLidAngle) * partialTicks;
f = 1.0F - f;
f = 1.0F - f * f * f;
modelgrill.chestLid.rotateAngleX = -(f * ((float)Math.PI / 2F));
modelgrill.renderAll();
GlStateManager.disableRescaleNormal();
GlStateManager.popMatrix();
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
if (destroyStage >= 0)
{
GlStateManager.matrixMode(5890);
GlStateManager.popMatrix();
GlStateManager.matrixMode(5888);
}
}else{
GlStateManager.enableDepth();
GlStateManager.depthFunc(515);
GlStateManager.depthMask(true);
ModelGrill mg = this.simpleChest;
if (destroyStage >= 0)
{
this.bindTexture(DESTROY_STAGES[destroyStage]);
GlStateManager.matrixMode(5890);
GlStateManager.pushMatrix();
GlStateManager.scale(4.0F, 4.0F, 1.0F);
GlStateManager.translate(0.0625F, 0.0625F, 0.0625F);
GlStateManager.matrixMode(5888);
}
else
{
this.bindTexture(TEXTURE_NORMAL);
}
GlStateManager.pushMatrix();
GlStateManager.enableRescaleNormal();
if (destroyStage < 0)
{
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
}
GlStateManager.translate((float)x, (float)y + 1.0F, (float)z + 1.0F);
GlStateManager.scale(1.0F, -1.0F, -1.0F);
GlStateManager.translate(0.5F, 0.5F, 0.5F);
GlStateManager.translate(-0.5F, -0.5F, -0.5F);
mg.renderAll();
GlStateManager.disableRescaleNormal();
GlStateManager.popMatrix();
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
if (destroyStage >= 0)
{
GlStateManager.matrixMode(5890);
GlStateManager.popMatrix();
GlStateManager.matrixMode(5888);
}
}
}
}
Also, read the above posts.