Discover native block colouring support within normal block rendering code.

This commit is contained in:
Ben Spiers 2014-04-13 23:40:51 +01:00
parent 3dd06cca78
commit 1a6030c1a5
5 changed files with 10 additions and 38 deletions

View file

@ -155,6 +155,7 @@ public class ClientProxy extends CommonProxy
public static int MACHINE_RENDER_ID = RenderingRegistry.getNextAvailableRenderId();
public static int TRANSMITTER_RENDER_ID = RenderingRegistry.getNextAvailableRenderId();
public static int BASIC_RENDER_ID = RenderingRegistry.getNextAvailableRenderId();
public static int PLASTIC_RENDER_ID = RenderingRegistry.getNextAvailableRenderId();
@Override
public void loadConfiguration()
@ -318,7 +319,6 @@ public class ClientProxy extends CommonProxy
ClientRegistry.registerTileEntity(TileEntityChemicalWasher.class, "ChemicalWasher", new RenderChemicalWasher());
ClientRegistry.registerTileEntity(TileEntityChemicalCrystallizer.class, "ChemicalCrystallizer", new RenderChemicalCrystallizer());
ClientRegistry.registerTileEntity(TileEntityPRC.class, "PressurizedReactionChamber", new RenderConfigurableMachine());
ClientRegistry.registerTileEntity(TileEntityPlasticBlock.class, "PlasticBlock", new RenderPlastic());
}
@Override

View file

@ -17,7 +17,7 @@ import org.lwjgl.opengl.GL11;
@SideOnly(Side.CLIENT)
public class RenderPlastic extends TileEntitySpecialRenderer
public class RenderPlastic
{
public static Model3D toRender;
@ -27,27 +27,6 @@ public class RenderPlastic extends TileEntitySpecialRenderer
toRender.setBlockBounds(0,0,0,1,1,1);
}
@Override
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float partialTick)
{
renderAModelAt((TileEntityPlasticBlock) tileEntity, x, y, z, partialTick);
}
public void renderAModelAt(TileEntityPlasticBlock plastic, double x, double y, double z, float partialTick)
{
GL11.glPushMatrix();
GL11.glTranslatef((float) x, (float) y, (float) z);
bindTexture(MekanismRenderer.getBlocksTexture());
toRender.setTexture(Mekanism.BlockHDPE.getBlockTexture(plastic.worldObj, plastic.xCoord, plastic.yCoord, plastic.zCoord, 0));
EnumColor color = EnumColor.DYES[plastic.colour];
float[] colour = {color.getColor(0), color.getColor(1), color.getColor(2)};
GL11.glColor3f(colour[0], colour[1], colour[2]);
RenderHelper.disableStandardItemLighting();
MekanismRenderer.renderObject(toRender);
GL11.glPopMatrix();
}
public static void renderItem(ItemStack stack)
{
GL11.glPushMatrix();

View file

@ -129,7 +129,6 @@ public class CommonProxy
GameRegistry.registerTileEntity(TileEntityChemicalWasher.class, "ChemicalWasher");
GameRegistry.registerTileEntity(TileEntityChemicalCrystallizer.class, "ChemicalCrystallizer");
GameRegistry.registerTileEntity(TileEntityPRC.class, "PressurizedReactionChamber");
GameRegistry.registerTileEntity(TileEntityPlasticBlock.class, "PlasticBlock");
}
/**

View file

@ -126,6 +126,7 @@ import mekanism.common.tile.TileEntityBoundingBlock;
import mekanism.common.tile.TileEntityCardboardBox;
import mekanism.common.tile.TileEntityElectricBlock;
import mekanism.common.tile.TileEntityEnergizedSmelter;
import mekanism.common.tile.TileEntityPlasticBlock;
import mekanism.common.tile.TileEntitySalinationTank;
import mekanism.common.tile.TileEntitySalinationValve;
import mekanism.common.tile.TileEntitySeismicVibrator;
@ -1164,6 +1165,7 @@ public class Mekanism
GameRegistry.registerTileEntity(TileEntitySeismicVibrator.class, "SeismicVibrator");
GameRegistry.registerTileEntity(TileEntitySalinationValve.class, "SalinationValve");
GameRegistry.registerTileEntity(TileEntitySalinationTank.class, "SalinationTank");
GameRegistry.registerTileEntity(TileEntityPlasticBlock.class, "PlasticBlock");
//Load tile entities that have special renderers.
proxy.registerSpecialTileEntities();

View file

@ -2,6 +2,8 @@ package mekanism.common.block;
import java.util.List;
import mekanism.api.EnumColor;
import mekanism.client.ClientProxy;
import mekanism.common.Mekanism;
import mekanism.common.tile.TileEntityPlasticBlock;
@ -76,21 +78,11 @@ public class BlockPlastic extends Block
}
@Override
public boolean renderAsNormalBlock()
public int colorMultiplier(IBlockAccess world, int x, int y, int z)
{
return false;
}
@Override
public boolean isOpaqueCube()
{
return false;
}
@Override
public int getRenderType()
{
return -1;
TileEntityPlasticBlock plastic = (TileEntityPlasticBlock)world.getBlockTileEntity(x, y, z);
EnumColor colour = EnumColor.DYES[plastic.colour];
return (int)(colour.getColor(0)*255) << 16 | (int)(colour.getColor(1)*255) << 8 | (int)(colour.getColor(2)*255);
}
@Override