2012-11-28 16:33:34 +01:00
|
|
|
package mekanism.client;
|
|
|
|
|
2012-12-23 20:46:11 +01:00
|
|
|
import mekanism.common.BlockMachine.MachineType;
|
2012-11-28 16:33:34 +01:00
|
|
|
import mekanism.common.Mekanism;
|
2012-12-20 22:53:39 +01:00
|
|
|
import net.minecraft.block.Block;
|
|
|
|
import net.minecraft.client.renderer.RenderBlocks;
|
|
|
|
import net.minecraft.client.renderer.Tessellator;
|
2012-12-23 20:46:11 +01:00
|
|
|
import net.minecraft.world.IBlockAccess;
|
2012-11-28 16:33:34 +01:00
|
|
|
import net.minecraftforge.client.ForgeHooksClient;
|
|
|
|
|
2012-12-20 22:53:39 +01:00
|
|
|
import org.lwjgl.opengl.GL11;
|
|
|
|
|
2012-12-23 20:46:11 +01:00
|
|
|
import cpw.mods.fml.client.FMLClientHandler;
|
|
|
|
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
|
|
|
|
|
|
|
|
public class BlockRenderingHandler implements ISimpleBlockRenderingHandler
|
2012-11-28 16:33:34 +01:00
|
|
|
{
|
2012-12-23 20:46:11 +01:00
|
|
|
public ModelTheoreticalElementizer theoreticalElementizer = new ModelTheoreticalElementizer();
|
|
|
|
|
2012-11-28 16:33:34 +01:00
|
|
|
@Override
|
2012-12-23 20:46:11 +01:00
|
|
|
public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer)
|
2012-11-28 16:33:34 +01:00
|
|
|
{
|
2012-12-23 20:46:11 +01:00
|
|
|
GL11.glPushMatrix();
|
|
|
|
GL11.glRotatef(90F, 0.0F, 1.0F, 0.0F);
|
|
|
|
|
|
|
|
if(block.blockID == Mekanism.machineBlockID)
|
|
|
|
{
|
|
|
|
if(metadata == MachineType.THEORETICAL_ELEMENTIZER.meta)
|
|
|
|
{
|
|
|
|
GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F);
|
|
|
|
GL11.glRotatef(90F, 0.0F, -1.0F, 0.0F);
|
|
|
|
GL11.glTranslated(0.0F, -1.0F, 0.0F);
|
|
|
|
GL11.glBindTexture(3553, FMLClientHandler.instance().getClient().renderEngine.getTexture("/resources/mekanism/render/TheoreticalElementizer.png"));
|
|
|
|
theoreticalElementizer.render(0.0625F);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
ForgeHooksClient.bindTexture(block.getTextureFile(), 0);
|
|
|
|
renderItem(renderer, metadata, block);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
GL11.glPopMatrix();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer)
|
|
|
|
{
|
|
|
|
if(block.blockID == Mekanism.machineBlockID)
|
|
|
|
{
|
|
|
|
int metadata = world.getBlockMetadata(x, y, z);
|
|
|
|
|
|
|
|
if(!MachineType.getFromMetadata(metadata).hasModel)
|
|
|
|
{
|
|
|
|
renderer.renderStandardBlock(block, x, y, z);
|
|
|
|
renderer.updateCustomBlockBounds(block);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
2012-11-28 16:33:34 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2012-12-23 20:46:11 +01:00
|
|
|
public boolean shouldRender3DInInventory()
|
2012-11-28 16:33:34 +01:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2012-12-23 20:46:11 +01:00
|
|
|
public int getRenderId()
|
2012-11-28 16:33:34 +01:00
|
|
|
{
|
2012-12-23 20:46:11 +01:00
|
|
|
return ClientProxy.RENDER_ID;
|
2012-11-28 16:33:34 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Cleaned-up snip of RenderBlocks.renderBlockAsItem() -- used for rendering an item as an entity,
|
|
|
|
* in a player's inventory, and in a player's hand.
|
|
|
|
* @param renderer - RenderBlocks renderer to render the item with
|
|
|
|
* @param metadata - block/item metadata
|
|
|
|
* @param block - block to render
|
|
|
|
*/
|
2012-12-23 20:46:11 +01:00
|
|
|
public void renderItem(RenderBlocks renderer, int metadata, Block block)
|
2012-11-28 16:33:34 +01:00
|
|
|
{
|
|
|
|
block.setBlockBoundsForItemRender();
|
2012-12-23 20:46:11 +01:00
|
|
|
|
|
|
|
renderer.updateCustomBlockBounds(block);
|
2012-11-28 16:33:34 +01:00
|
|
|
|
|
|
|
if (renderer.useInventoryTint)
|
|
|
|
{
|
|
|
|
int renderColor = block.getRenderColor(metadata);
|
|
|
|
float red = (float)(renderColor >> 16 & 255) / 255.0F;
|
|
|
|
float green = (float)(renderColor >> 8 & 255) / 255.0F;
|
|
|
|
float blue = (float)(renderColor & 255) / 255.0F;
|
|
|
|
GL11.glColor4f(red, green, blue, 1.0F);
|
|
|
|
}
|
|
|
|
|
|
|
|
GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
|
|
|
|
Tessellator tessellator = Tessellator.instance;
|
|
|
|
tessellator.startDrawingQuads();
|
|
|
|
tessellator.setNormal(0.0F, -1.0F, 0.0F);
|
|
|
|
renderer.renderBottomFace(block, 0.0D, 0.0D, 0.0D, block.getBlockTextureFromSideAndMetadata(0, metadata));
|
|
|
|
tessellator.draw();
|
|
|
|
tessellator.startDrawingQuads();
|
|
|
|
tessellator.setNormal(0.0F, 1.0F, 0.0F);
|
|
|
|
renderer.renderTopFace(block, 0.0D, 0.0D, 0.0D, block.getBlockTextureFromSideAndMetadata(1, metadata));
|
|
|
|
tessellator.draw();
|
|
|
|
tessellator.startDrawingQuads();
|
|
|
|
tessellator.setNormal(0.0F, 0.0F, -1.0F);
|
|
|
|
renderer.renderEastFace(block, 0.0D, 0.0D, 0.0D, block.getBlockTextureFromSideAndMetadata(2, metadata));
|
|
|
|
tessellator.draw();
|
|
|
|
tessellator.startDrawingQuads();
|
|
|
|
tessellator.setNormal(0.0F, 0.0F, 1.0F);
|
|
|
|
renderer.renderWestFace(block, 0.0D, 0.0D, 0.0D, block.getBlockTextureFromSideAndMetadata(3, metadata));
|
|
|
|
tessellator.draw();
|
|
|
|
tessellator.startDrawingQuads();
|
|
|
|
tessellator.setNormal(-1.0F, 0.0F, 0.0F);
|
|
|
|
renderer.renderNorthFace(block, 0.0D, 0.0D, 0.0D, block.getBlockTextureFromSideAndMetadata(4, metadata));
|
|
|
|
tessellator.draw();
|
|
|
|
tessellator.startDrawingQuads();
|
|
|
|
tessellator.setNormal(1.0F, 0.0F, 0.0F);
|
|
|
|
renderer.renderSouthFace(block, 0.0D, 0.0D, 0.0D, block.getBlockTextureFromSideAndMetadata(5, metadata));
|
|
|
|
tessellator.draw();
|
|
|
|
GL11.glTranslatef(0.5F, 0.5F, 0.5F);
|
|
|
|
}
|
|
|
|
}
|