2012-11-27 01:18:50 +01:00
|
|
|
package mekanism.generators.client;
|
|
|
|
|
2014-01-03 03:09:21 +01:00
|
|
|
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
|
|
|
|
import cpw.mods.fml.relauncher.Side;
|
|
|
|
import cpw.mods.fml.relauncher.SideOnly;
|
2013-08-27 00:57:08 +02:00
|
|
|
import mekanism.client.render.MekanismRenderer;
|
|
|
|
import mekanism.common.util.MekanismUtils;
|
|
|
|
import mekanism.common.util.MekanismUtils.ResourceType;
|
2014-01-03 03:09:21 +01:00
|
|
|
import mekanism.generators.client.model.*;
|
2012-12-20 22:53:39 +01:00
|
|
|
import mekanism.generators.common.MekanismGenerators;
|
2013-11-02 17:00:29 +01:00
|
|
|
import mekanism.generators.common.block.BlockGenerator.GeneratorType;
|
2012-12-20 22:53:39 +01:00
|
|
|
import net.minecraft.block.Block;
|
2013-07-20 18:10:14 +02:00
|
|
|
import net.minecraft.client.Minecraft;
|
2012-12-20 22:53:39 +01:00
|
|
|
import net.minecraft.client.renderer.RenderBlocks;
|
|
|
|
import net.minecraft.world.IBlockAccess;
|
|
|
|
import org.lwjgl.opengl.GL11;
|
|
|
|
|
2013-04-13 16:33:37 +02:00
|
|
|
@SideOnly(Side.CLIENT)
|
2012-11-27 01:18:50 +01:00
|
|
|
public class BlockRenderingHandler implements ISimpleBlockRenderingHandler
|
|
|
|
{
|
2012-12-19 21:23:55 +01:00
|
|
|
public ModelAdvancedSolarGenerator advancedSolarGenerator = new ModelAdvancedSolarGenerator();
|
2013-11-02 17:00:29 +01:00
|
|
|
public ModelSolarGenerator solarGenerator = new ModelSolarGenerator();
|
2012-11-27 01:18:50 +01:00
|
|
|
public ModelBioGenerator bioGenerator = new ModelBioGenerator();
|
2012-12-19 21:23:55 +01:00
|
|
|
public ModelHeatGenerator heatGenerator = new ModelHeatGenerator();
|
|
|
|
public ModelHydrogenGenerator hydrogenGenerator = new ModelHydrogenGenerator();
|
2013-04-28 21:23:08 +02:00
|
|
|
public ModelWindTurbine windTurbine = new ModelWindTurbine();
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2012-11-27 01:18:50 +01:00
|
|
|
@Override
|
|
|
|
public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer)
|
|
|
|
{
|
2014-03-08 02:00:25 +01:00
|
|
|
GL11.glPushMatrix();
|
|
|
|
GL11.glRotatef(90F, 0.0F, 1.0F, 0.0F);
|
|
|
|
|
|
|
|
if(block.blockID == MekanismGenerators.generatorID)
|
|
|
|
{
|
|
|
|
if(metadata == GeneratorType.BIO_GENERATOR.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);
|
|
|
|
Minecraft.getMinecraft().renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "BioGenerator.png"));
|
|
|
|
bioGenerator.render(0.0625F);
|
|
|
|
}
|
|
|
|
else if(metadata == GeneratorType.ADVANCED_SOLAR_GENERATOR.meta)
|
|
|
|
{
|
|
|
|
GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F);
|
|
|
|
GL11.glRotatef(90F, 0.0F, 1.0F, 0.0F);
|
|
|
|
GL11.glTranslatef(0.0F, 0.2F, 0.0F);
|
|
|
|
Minecraft.getMinecraft().renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "AdvancedSolarGenerator.png"));
|
|
|
|
advancedSolarGenerator.render(0.022F);
|
|
|
|
}
|
|
|
|
else if(metadata == GeneratorType.SOLAR_GENERATOR.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);
|
|
|
|
Minecraft.getMinecraft().renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "SolarGenerator.png"));
|
|
|
|
solarGenerator.render(0.0625F);
|
|
|
|
}
|
|
|
|
else if(metadata == GeneratorType.HEAT_GENERATOR.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);
|
|
|
|
Minecraft.getMinecraft().renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "HeatGenerator.png"));
|
|
|
|
heatGenerator.render(0.0625F);
|
|
|
|
}
|
|
|
|
else if(metadata == GeneratorType.HYDROGEN_GENERATOR.meta)
|
|
|
|
{
|
|
|
|
GL11.glRotatef(180F, 0.0F, 1.0F, 1.0F);
|
|
|
|
GL11.glRotatef(90F, -1.0F, 0.0F, 0.0F);
|
|
|
|
GL11.glTranslated(0.0F, -1.0F, 0.0F);
|
|
|
|
Minecraft.getMinecraft().renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "HydrogenGenerator.png"));
|
|
|
|
hydrogenGenerator.render(0.0625F);
|
|
|
|
}
|
|
|
|
else if(metadata == GeneratorType.WIND_TURBINE.meta)
|
|
|
|
{
|
|
|
|
GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F);
|
|
|
|
GL11.glRotatef(180F, 0.0F, 1.0F, 0.0F);
|
|
|
|
GL11.glTranslatef(0.0F, 0.35F, 0.0F);
|
|
|
|
Minecraft.getMinecraft().renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "WindTurbine.png"));
|
|
|
|
windTurbine.render(0.018F, 0);
|
|
|
|
}
|
|
|
|
else if(metadata != 2) {
|
|
|
|
MekanismRenderer.renderItem(renderer, metadata, block);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
GL11.glPopMatrix();
|
2012-11-27 01:18:50 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer)
|
|
|
|
{
|
|
|
|
if(block.blockID == MekanismGenerators.generatorID)
|
|
|
|
{
|
2012-11-28 16:33:34 +01:00
|
|
|
int metadata = world.getBlockMetadata(x, y, z);
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2014-01-05 21:20:58 +01:00
|
|
|
if(GeneratorType.getFromMetadata(metadata) == null || !GeneratorType.getFromMetadata(metadata).hasModel)
|
2012-11-28 16:33:34 +01:00
|
|
|
{
|
|
|
|
renderer.renderStandardBlock(block, x, y, z);
|
2013-01-21 02:15:59 +01:00
|
|
|
renderer.setRenderBoundsFromBlock(block);
|
2012-11-28 16:33:34 +01:00
|
|
|
return true;
|
|
|
|
}
|
2012-11-27 01:18:50 +01:00
|
|
|
}
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2012-11-27 01:18:50 +01:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2014-03-08 02:00:25 +01:00
|
|
|
public boolean shouldRender3DInInventory()
|
2012-11-27 01:18:50 +01:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2014-03-08 02:00:25 +01:00
|
|
|
public int getRenderId()
|
2012-11-27 01:18:50 +01:00
|
|
|
{
|
2013-05-14 17:34:26 +02:00
|
|
|
return GeneratorsClientProxy.GENERATOR_RENDER_ID;
|
2012-11-27 01:18:50 +01:00
|
|
|
}
|
|
|
|
}
|