2012-11-27 01:18:50 +01:00
|
|
|
package mekanism.generators.client;
|
|
|
|
|
2013-08-27 00:57:08 +02:00
|
|
|
import mekanism.client.render.MekanismRenderer;
|
|
|
|
import mekanism.common.util.MekanismUtils;
|
|
|
|
import mekanism.common.util.MekanismUtils.ResourceType;
|
2013-08-27 00:49:32 +02:00
|
|
|
import mekanism.generators.client.model.ModelAdvancedSolarGenerator;
|
|
|
|
import mekanism.generators.client.model.ModelBioGenerator;
|
|
|
|
import mekanism.generators.client.model.ModelElectrolyticSeparator;
|
|
|
|
import mekanism.generators.client.model.ModelHeatGenerator;
|
|
|
|
import mekanism.generators.client.model.ModelHydrogenGenerator;
|
2013-11-02 17:00:29 +01:00
|
|
|
import mekanism.generators.client.model.ModelSolarGenerator;
|
2013-08-27 00:49:32 +02:00
|
|
|
import mekanism.generators.client.model.ModelWindTurbine;
|
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;
|
|
|
|
|
2012-11-27 01:18:50 +01:00
|
|
|
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
|
2013-04-13 16:33:37 +02:00
|
|
|
import cpw.mods.fml.relauncher.Side;
|
|
|
|
import cpw.mods.fml.relauncher.SideOnly;
|
2012-11-27 01:18:50 +01:00
|
|
|
|
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();
|
|
|
|
public ModelElectrolyticSeparator electrolyticSeparator = new ModelElectrolyticSeparator();
|
2013-04-28 21:23:08 +02:00
|
|
|
public ModelWindTurbine windTurbine = new ModelWindTurbine();
|
2012-11-27 01:18:50 +01:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer)
|
|
|
|
{
|
|
|
|
GL11.glPushMatrix();
|
2012-11-28 16:33:34 +01:00
|
|
|
GL11.glRotatef(90F, 0.0F, 1.0F, 0.0F);
|
2012-11-27 01:18:50 +01:00
|
|
|
|
|
|
|
if(block.blockID == MekanismGenerators.generatorID)
|
|
|
|
{
|
2012-12-19 21:23:55 +01:00
|
|
|
if(metadata == GeneratorType.BIO_GENERATOR.meta)
|
2012-11-28 16:33:34 +01:00
|
|
|
{
|
|
|
|
GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F);
|
2012-12-03 16:10:48 +01:00
|
|
|
GL11.glRotatef(90F, 0.0F, -1.0F, 0.0F);
|
|
|
|
GL11.glTranslated(0.0F, -1.0F, 0.0F);
|
2013-09-28 03:59:47 +02:00
|
|
|
Minecraft.getMinecraft().renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "BioGenerator.png"));
|
2013-11-03 22:54:33 +01:00
|
|
|
bioGenerator.render(0.0625F);
|
2012-11-28 16:33:34 +01:00
|
|
|
}
|
2012-12-19 21:23:55 +01:00
|
|
|
else if(metadata == GeneratorType.ADVANCED_SOLAR_GENERATOR.meta)
|
2012-11-28 16:33:34 +01:00
|
|
|
{
|
|
|
|
GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F);
|
2012-12-03 16:10:48 +01:00
|
|
|
GL11.glRotatef(90F, 0.0F, 1.0F, 0.0F);
|
2012-11-28 16:33:34 +01:00
|
|
|
GL11.glTranslatef(0.0F, 0.3F, 0.0F);
|
2013-09-28 03:59:47 +02:00
|
|
|
Minecraft.getMinecraft().renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "AdvancedSolarGenerator.png"));
|
2012-12-19 21:23:55 +01:00
|
|
|
advancedSolarGenerator.render(0.0F, 0.022F);
|
|
|
|
}
|
2013-11-02 17:00:29 +01:00
|
|
|
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);
|
|
|
|
}
|
2012-12-19 21:23:55 +01:00
|
|
|
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);
|
2013-09-28 03:59:47 +02:00
|
|
|
Minecraft.getMinecraft().renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "HeatGenerator.png"));
|
2012-12-19 21:23:55 +01:00
|
|
|
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);
|
2013-09-28 03:59:47 +02:00
|
|
|
Minecraft.getMinecraft().renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "HydrogenGenerator.png"));
|
2012-12-19 21:23:55 +01:00
|
|
|
hydrogenGenerator.render(0.0625F);
|
|
|
|
}
|
|
|
|
else if(metadata == GeneratorType.ELECTROLYTIC_SEPARATOR.meta)
|
|
|
|
{
|
|
|
|
GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F);
|
|
|
|
GL11.glTranslated(0.0F, -1.0F, 0.0F);
|
2013-09-28 03:59:47 +02:00
|
|
|
Minecraft.getMinecraft().renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "ElectrolyticSeparatorHydrogen.png"));
|
2012-12-19 21:23:55 +01:00
|
|
|
electrolyticSeparator.render(0.0625F);
|
2012-11-28 16:33:34 +01:00
|
|
|
}
|
2013-04-28 21:23:08 +02:00
|
|
|
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);
|
2013-09-28 03:59:47 +02:00
|
|
|
Minecraft.getMinecraft().renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "WindTurbine.png"));
|
2013-04-28 21:23:08 +02:00
|
|
|
windTurbine.render(0.018F, 0);
|
|
|
|
}
|
2012-11-28 16:33:34 +01:00
|
|
|
else {
|
2013-05-28 06:29:29 +02:00
|
|
|
MekanismRenderer.renderItem(renderer, metadata, block);
|
2012-11-28 16:33:34 +01:00
|
|
|
}
|
2012-11-27 01:18:50 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
GL11.glPopMatrix();
|
|
|
|
}
|
|
|
|
|
|
|
|
@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);
|
|
|
|
|
2012-12-19 21:23:55 +01:00
|
|
|
if(!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
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean shouldRender3DInInventory()
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int getRenderId()
|
|
|
|
{
|
2013-05-14 17:34:26 +02:00
|
|
|
return GeneratorsClientProxy.GENERATOR_RENDER_ID;
|
2012-11-27 01:18:50 +01:00
|
|
|
}
|
|
|
|
}
|