Mekanism-tilera-Edition/src/minecraft/mekanism/client/BasicRenderingHandler.java
Aidan Brady 05a8ea03e9 v5.5.5 Beta #2
*Added Dynamic Tanks.
*Added Dynamic Valves.
*Added Dynamic Glass.
*Added Wind Turbines.
*Factories can change recipe type.
*Events for liquid and energy transfer.
*Fixed console spam.
*Fixed major lag with Universal Cable and lava-carrying Mechanical
Pipes.
*Liquid now renders with correct transparency.
*Fixed bad packets with Mechanical Pipe.
*Fixed NPE with null array in liquid transfer.
*Sounds now load if the sound system changes state in-game.
*Sounds now pause when the game pauses.
*Other enhancements and fixes.
2013-04-28 15:23:08 -04:00

111 lines
3.6 KiB
Java

package mekanism.client;
import mekanism.common.Mekanism;
import mekanism.common.TileEntityDynamicTank;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.world.IBlockAccess;
import org.lwjgl.opengl.GL11;
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class BasicRenderingHandler implements ISimpleBlockRenderingHandler
{
@Override
public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer)
{
GL11.glPushMatrix();
GL11.glRotatef(90F, 0.0F, 1.0F, 0.0F);
if(block.blockID == Mekanism.basicBlockID)
{
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.basicBlockID)
{
int metadata = world.getBlockMetadata(x, y, z);
renderer.renderStandardBlock(block, x, y, z);
renderer.setRenderBoundsFromBlock(block);
return true;
}
return false;
}
@Override
public boolean shouldRender3DInInventory()
{
return true;
}
@Override
public int getRenderId()
{
return ClientProxy.BASIC_RENDER_ID;
}
/**
* 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
*/
public void renderItem(RenderBlocks renderer, int metadata, Block block)
{
block.setBlockBoundsForItemRender();
renderer.setRenderBoundsFromBlock(block);
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.getIcon(0, metadata));
tessellator.draw();
tessellator.startDrawingQuads();
tessellator.setNormal(0.0F, 1.0F, 0.0F);
renderer.renderTopFace(block, 0.0D, 0.0D, 0.0D, block.getIcon(1, metadata));
tessellator.draw();
tessellator.startDrawingQuads();
tessellator.setNormal(0.0F, 0.0F, -1.0F);
renderer.renderEastFace(block, 0.0D, 0.0D, 0.0D, block.getIcon(2, metadata));
tessellator.draw();
tessellator.startDrawingQuads();
tessellator.setNormal(0.0F, 0.0F, 1.0F);
renderer.renderWestFace(block, 0.0D, 0.0D, 0.0D, block.getIcon(3, metadata));
tessellator.draw();
tessellator.startDrawingQuads();
tessellator.setNormal(-1.0F, 0.0F, 0.0F);
renderer.renderNorthFace(block, 0.0D, 0.0D, 0.0D, block.getIcon(4, metadata));
tessellator.draw();
tessellator.startDrawingQuads();
tessellator.setNormal(1.0F, 0.0F, 0.0F);
renderer.renderSouthFace(block, 0.0D, 0.0D, 0.0D, block.getIcon(5, metadata));
tessellator.draw();
GL11.glTranslatef(0.5F, 0.5F, 0.5F);
}
}