2014-04-11 01:59:04 +02:00
|
|
|
package com.pahimar.ee3.client.renderer.tileentity;
|
|
|
|
|
|
|
|
import com.pahimar.ee3.reference.Textures;
|
2014-04-30 03:46:59 +02:00
|
|
|
import com.pahimar.ee3.tileentity.TileEntityAlchemicalChest;
|
2014-04-11 01:59:04 +02:00
|
|
|
import cpw.mods.fml.relauncher.Side;
|
|
|
|
import cpw.mods.fml.relauncher.SideOnly;
|
|
|
|
import net.minecraft.client.model.ModelChest;
|
|
|
|
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
|
|
|
import net.minecraft.tileentity.TileEntity;
|
|
|
|
import net.minecraftforge.common.util.ForgeDirection;
|
|
|
|
import org.lwjgl.opengl.GL11;
|
|
|
|
import org.lwjgl.opengl.GL12;
|
|
|
|
|
|
|
|
@SideOnly(Side.CLIENT)
|
2014-07-17 21:20:53 +02:00
|
|
|
public class TileEntityRendererAlchemicalChest extends TileEntitySpecialRenderer
|
2014-04-11 01:59:04 +02:00
|
|
|
{
|
|
|
|
private final ModelChest modelChest = new ModelChest();
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float tick)
|
|
|
|
{
|
2014-04-30 03:46:59 +02:00
|
|
|
if (tileEntity instanceof TileEntityAlchemicalChest)
|
2014-04-11 01:59:04 +02:00
|
|
|
{
|
2014-04-30 03:46:59 +02:00
|
|
|
TileEntityAlchemicalChest tileEntityAlchemicalChest = (TileEntityAlchemicalChest) tileEntity;
|
2014-04-11 01:59:04 +02:00
|
|
|
ForgeDirection direction = null;
|
|
|
|
|
2014-04-30 03:46:59 +02:00
|
|
|
if (tileEntityAlchemicalChest.getWorldObj() != null)
|
2014-04-11 01:59:04 +02:00
|
|
|
{
|
2014-04-30 03:46:59 +02:00
|
|
|
direction = tileEntityAlchemicalChest.getOrientation();
|
2014-04-11 01:59:04 +02:00
|
|
|
}
|
|
|
|
|
2014-04-30 03:46:59 +02:00
|
|
|
if (tileEntityAlchemicalChest.getState() == 0)
|
2014-04-11 01:59:04 +02:00
|
|
|
{
|
2014-07-17 21:20:53 +02:00
|
|
|
this.bindTexture(Textures.Model.ALCHEMICAL_CHEST_SMALL);
|
2014-04-11 01:59:04 +02:00
|
|
|
}
|
2014-04-30 03:46:59 +02:00
|
|
|
else if (tileEntityAlchemicalChest.getState() == 1)
|
2014-04-11 01:59:04 +02:00
|
|
|
{
|
2014-07-17 21:20:53 +02:00
|
|
|
this.bindTexture(Textures.Model.ALCHEMICAL_CHEST_MEDIUM);
|
2014-04-11 01:59:04 +02:00
|
|
|
}
|
2014-04-30 03:46:59 +02:00
|
|
|
else if (tileEntityAlchemicalChest.getState() == 2)
|
2014-04-11 01:59:04 +02:00
|
|
|
{
|
2014-07-17 21:20:53 +02:00
|
|
|
this.bindTexture(Textures.Model.ALCHEMICAL_CHEST_LARGE);
|
2014-04-11 01:59:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
GL11.glPushMatrix();
|
|
|
|
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
|
|
|
|
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
|
|
|
GL11.glTranslatef((float) x, (float) y + 1.0F, (float) z + 1.0F);
|
|
|
|
GL11.glScalef(1.0F, -1.0F, -1.0F);
|
|
|
|
GL11.glTranslatef(0.5F, 0.5F, 0.5F);
|
|
|
|
short angle = 0;
|
|
|
|
|
|
|
|
if (direction != null)
|
|
|
|
{
|
|
|
|
if (direction == ForgeDirection.NORTH)
|
|
|
|
{
|
|
|
|
angle = 180;
|
|
|
|
}
|
|
|
|
else if (direction == ForgeDirection.SOUTH)
|
|
|
|
{
|
|
|
|
angle = 0;
|
|
|
|
}
|
|
|
|
else if (direction == ForgeDirection.WEST)
|
|
|
|
{
|
|
|
|
angle = 90;
|
|
|
|
}
|
|
|
|
else if (direction == ForgeDirection.EAST)
|
|
|
|
{
|
|
|
|
angle = -90;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
GL11.glRotatef(angle, 0.0F, 1.0F, 0.0F);
|
|
|
|
GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
|
2014-04-30 03:46:59 +02:00
|
|
|
float adjustedLidAngle = tileEntityAlchemicalChest.prevLidAngle + (tileEntityAlchemicalChest.lidAngle - tileEntityAlchemicalChest.prevLidAngle) * tick;
|
2014-04-11 01:59:04 +02:00
|
|
|
adjustedLidAngle = 1.0F - adjustedLidAngle;
|
|
|
|
adjustedLidAngle = 1.0F - adjustedLidAngle * adjustedLidAngle * adjustedLidAngle;
|
|
|
|
modelChest.chestLid.rotateAngleX = -(adjustedLidAngle * (float) Math.PI / 2.0F);
|
|
|
|
modelChest.renderAll();
|
|
|
|
GL11.glDisable(GL12.GL_RESCALE_NORMAL);
|
|
|
|
GL11.glPopMatrix();
|
|
|
|
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|