equivalent-exchange-3/ee3_common/com/pahimar/ee3/client/renderer/tileentity/TileEntityAlchemicalChestRenderer.java

82 lines
2.8 KiB
Java
Raw Normal View History

2013-02-19 02:13:24 +01:00
package com.pahimar.ee3.client.renderer.tileentity;
import net.minecraft.client.model.ModelChest;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.ForgeDirection;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;
import com.pahimar.ee3.lib.Textures;
import com.pahimar.ee3.tileentity.TileAlchemicalChest;
import cpw.mods.fml.client.FMLClientHandler;
2013-02-19 02:13:24 +01:00
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
/**
* Equivalent-Exchange-3
*
* TileEntityAlchemicalChestRenderer
*
* @author pahimar
* @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html)
*
*/
2013-02-19 02:13:24 +01:00
@SideOnly(Side.CLIENT)
public class TileEntityAlchemicalChestRenderer extends TileEntitySpecialRenderer {
2013-02-19 02:13:24 +01:00
private ModelChest modelChest = new ModelChest();
public void renderAlchemicalChest(TileAlchemicalChest tileAlchemicalChest, double x, double y, double z, float tick) {
ForgeDirection direction = null;
if (tileAlchemicalChest.getWorldObj() != null) {
direction = ForgeDirection.getOrientation(tileAlchemicalChest.getBlockMetadata());
}
FMLClientHandler.instance().getClient().renderEngine.func_98187_b(Textures.MODEL_ALCHEMICAL_CHEST);
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);
float adjustedLidAngle = tileAlchemicalChest.prevLidAngle + (tileAlchemicalChest.lidAngle - tileAlchemicalChest.prevLidAngle) * tick;
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);
}
2013-02-19 02:13:24 +01:00
@Override
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float tick) {
renderAlchemicalChest((TileAlchemicalChest) tileEntity, x, y, z, tick);
2013-02-19 02:13:24 +01:00
}
}