2012-11-28 16:33:34 +01:00
|
|
|
package mekanism.client;
|
|
|
|
|
2013-08-27 00:49:32 +02:00
|
|
|
import mekanism.client.model.ModelRobit;
|
2013-04-13 02:25:21 +02:00
|
|
|
import mekanism.common.IElectricChest;
|
2013-05-20 00:43:01 +02:00
|
|
|
import mekanism.common.IEnergyCube;
|
2012-11-28 16:33:34 +01:00
|
|
|
import mekanism.common.Mekanism;
|
2013-07-20 18:10:14 +02:00
|
|
|
import mekanism.common.MekanismUtils;
|
|
|
|
import mekanism.common.MekanismUtils.ResourceType;
|
2013-04-01 01:12:10 +02:00
|
|
|
import mekanism.common.Tier.EnergyCubeTier;
|
2013-08-27 00:49:32 +02:00
|
|
|
import mekanism.common.block.BlockMachine.MachineType;
|
|
|
|
import mekanism.common.item.ItemBlockMachine;
|
|
|
|
import mekanism.common.item.ItemRobit;
|
2012-12-20 22:53:39 +01:00
|
|
|
import net.minecraft.block.Block;
|
2013-05-07 01:42:03 +02:00
|
|
|
import net.minecraft.client.Minecraft;
|
2013-04-20 00:03:59 +02:00
|
|
|
import net.minecraft.client.model.ModelChest;
|
2012-12-20 22:53:39 +01:00
|
|
|
import net.minecraft.client.renderer.RenderBlocks;
|
|
|
|
import net.minecraft.client.renderer.Tessellator;
|
|
|
|
import net.minecraft.item.ItemStack;
|
2012-11-28 16:33:34 +01:00
|
|
|
import net.minecraftforge.client.IItemRenderer;
|
|
|
|
|
2012-12-20 22:53:39 +01:00
|
|
|
import org.lwjgl.opengl.GL11;
|
|
|
|
|
2013-04-20 00:03:59 +02:00
|
|
|
import cpw.mods.fml.client.registry.RenderingRegistry;
|
2013-04-13 16:33:37 +02:00
|
|
|
import cpw.mods.fml.relauncher.Side;
|
|
|
|
import cpw.mods.fml.relauncher.SideOnly;
|
|
|
|
|
|
|
|
@SideOnly(Side.CLIENT)
|
2012-11-28 16:33:34 +01:00
|
|
|
public class ItemRenderingHandler implements IItemRenderer
|
|
|
|
{
|
2013-05-20 00:43:01 +02:00
|
|
|
public ModelRobit robit = new ModelRobit();
|
2013-07-19 20:59:01 +02:00
|
|
|
public ModelChest electricChest = new ModelChest();
|
2013-05-20 00:43:01 +02:00
|
|
|
|
2012-11-28 16:33:34 +01:00
|
|
|
@Override
|
|
|
|
public boolean handleRenderType(ItemStack item, ItemRenderType type)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void renderItem(ItemRenderType type, ItemStack item, Object... data)
|
|
|
|
{
|
2013-05-14 17:34:26 +02:00
|
|
|
if(type == ItemRenderType.EQUIPPED || type == ItemRenderType.EQUIPPED_FIRST_PERSON)
|
2013-04-20 00:03:59 +02:00
|
|
|
{
|
|
|
|
GL11.glTranslatef(0.5F, 0.5F, 0.5F);
|
|
|
|
}
|
|
|
|
|
2013-01-12 15:52:41 +01:00
|
|
|
if(item.getItem() instanceof IEnergyCube)
|
|
|
|
{
|
2013-03-31 00:13:59 +01:00
|
|
|
EnergyCubeTier tier = ((IEnergyCube)item.getItem()).getEnergyCubeTier(item);
|
2013-01-12 15:52:41 +01:00
|
|
|
|
2013-05-07 22:45:34 +02:00
|
|
|
GL11.glRotatef(90, 0.0F, 1.0F, 0.0F);
|
2013-03-18 17:23:57 +01:00
|
|
|
renderItem((RenderBlocks)data[0], tier.ordinal());
|
2013-01-12 15:52:41 +01:00
|
|
|
}
|
2013-05-20 00:43:01 +02:00
|
|
|
else if(item.getItem() instanceof ItemBlockMachine && item.getItemDamage() == MachineType.ELECTRIC_CHEST.meta)
|
2013-04-20 00:03:59 +02:00
|
|
|
{
|
|
|
|
IElectricChest chest = (IElectricChest)item.getItem();
|
|
|
|
|
|
|
|
GL11.glRotatef(90F, 0.0F, 1.0F, 0.0F);
|
|
|
|
GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
|
|
|
|
GL11.glTranslatef(0, 1.0F, 1.0F);
|
|
|
|
GL11.glScalef(1.0F, -1F, -1F);
|
2013-07-20 18:10:14 +02:00
|
|
|
|
|
|
|
Minecraft.getMinecraft().renderEngine.func_110577_a(MekanismUtils.getResource(ResourceType.RENDER, "ElectricChest.png"));
|
2013-04-20 00:03:59 +02:00
|
|
|
|
2013-07-20 18:10:14 +02:00
|
|
|
float lidangle = chest.getPrevLidAngle(item) + (chest.getLidAngle(item) - chest.getPrevLidAngle(item)) * MekanismRenderer.getPartialTicks();
|
2013-04-20 00:03:59 +02:00
|
|
|
lidangle = 1.0F - lidangle;
|
|
|
|
lidangle = 1.0F - lidangle * lidangle * lidangle;
|
|
|
|
electricChest.chestLid.rotateAngleX = -((lidangle * 3.141593F) / 2.0F);
|
|
|
|
|
|
|
|
electricChest.renderAll();
|
|
|
|
}
|
2013-05-20 00:43:01 +02:00
|
|
|
else if(item.getItem() instanceof ItemRobit)
|
|
|
|
{
|
|
|
|
GL11.glRotatef(180, 0.0F, 0.0F, 1.0F);
|
|
|
|
GL11.glRotatef(90, 0.0F, -1.0F, 0.0F);
|
|
|
|
GL11.glTranslatef(0.0F, -1.5F, 0.0F);
|
2013-07-20 18:10:14 +02:00
|
|
|
Minecraft.getMinecraft().renderEngine.func_110577_a(MekanismUtils.getResource(ResourceType.RENDER, "Robit.png"));
|
2013-05-20 00:43:01 +02:00
|
|
|
robit.render(0.08F);
|
|
|
|
}
|
2013-04-20 00:03:59 +02:00
|
|
|
else {
|
2013-04-28 21:23:08 +02:00
|
|
|
RenderingRegistry.instance().renderInventoryBlock((RenderBlocks)data[0], Block.blocksList[Mekanism.machineBlockID], item.getItemDamage(), ClientProxy.MACHINE_RENDER_ID);
|
2013-04-20 00:03:59 +02:00
|
|
|
}
|
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
|
|
|
|
*/
|
|
|
|
public void renderItem(RenderBlocks renderer, int metadata)
|
|
|
|
{
|
|
|
|
Block block = Block.blocksList[Mekanism.energyCubeID];
|
2013-01-21 02:15:59 +01:00
|
|
|
renderer.setRenderBoundsFromBlock(block);
|
2012-11-28 16:33:34 +01:00
|
|
|
block.setBlockBoundsForItemRender();
|
|
|
|
|
2013-03-11 18:49:01 +01:00
|
|
|
if(renderer.useInventoryTint)
|
2012-11-28 16:33:34 +01:00
|
|
|
{
|
|
|
|
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);
|
2013-05-07 21:57:55 +02:00
|
|
|
renderer.renderFaceYNeg(block, 0.0D, 0.0D, 0.0D, block.getIcon(0, metadata));
|
2012-11-28 16:33:34 +01:00
|
|
|
tessellator.draw();
|
|
|
|
tessellator.startDrawingQuads();
|
|
|
|
tessellator.setNormal(0.0F, 1.0F, 0.0F);
|
2013-05-07 21:57:55 +02:00
|
|
|
renderer.renderFaceYPos(block, 0.0D, 0.0D, 0.0D, block.getIcon(1, metadata));
|
2012-11-28 16:33:34 +01:00
|
|
|
tessellator.draw();
|
|
|
|
tessellator.startDrawingQuads();
|
|
|
|
tessellator.setNormal(0.0F, 0.0F, -1.0F);
|
2013-05-07 21:57:55 +02:00
|
|
|
renderer.renderFaceZNeg(block, 0.0D, 0.0D, 0.0D, block.getIcon(2, metadata));
|
2012-11-28 16:33:34 +01:00
|
|
|
tessellator.draw();
|
|
|
|
tessellator.startDrawingQuads();
|
|
|
|
tessellator.setNormal(0.0F, 0.0F, 1.0F);
|
2013-05-07 21:57:55 +02:00
|
|
|
renderer.renderFaceZPos(block, 0.0D, 0.0D, 0.0D, block.getIcon(3, metadata));
|
2012-11-28 16:33:34 +01:00
|
|
|
tessellator.draw();
|
|
|
|
tessellator.startDrawingQuads();
|
|
|
|
tessellator.setNormal(-1.0F, 0.0F, 0.0F);
|
2013-05-07 21:57:55 +02:00
|
|
|
renderer.renderFaceXNeg(block, 0.0D, 0.0D, 0.0D, block.getIcon(4, metadata));
|
2012-11-28 16:33:34 +01:00
|
|
|
tessellator.draw();
|
|
|
|
tessellator.startDrawingQuads();
|
|
|
|
tessellator.setNormal(1.0F, 0.0F, 0.0F);
|
2013-05-07 21:57:55 +02:00
|
|
|
renderer.renderFaceXPos(block, 0.0D, 0.0D, 0.0D, block.getIcon(5, metadata));
|
2012-11-28 16:33:34 +01:00
|
|
|
tessellator.draw();
|
|
|
|
GL11.glTranslatef(0.5F, 0.5F, 0.5F);
|
|
|
|
}
|
|
|
|
}
|