Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class FuelBlockRenderHandler implements ISimpleBlockRenderingHandler{
- @Override
- public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) {
- }
- @Override
- public boolean renderWorldBlock(IBlockAccess world, int xCoord, int yCoord, int zCoord, Block block, int modelId, RenderBlocks renderer) {
- BlockFuel blockFuel = (BlockFuel) world.getBlock(xCoord, yCoord, zCoord);
- int worldBlockMetaData = world.getBlockMetadata(xCoord, yCoord, zCoord);
- int worldLightValue = blockFuel.getMixedBrightnessForBlock(world, xCoord, yCoord, zCoord);
- Tessellator t = Tessellator.instance;
- if (Client.renderPass == 0) {
- /* Render the block texture itself */
- //renderer.overrideBlockTexture = Blocks.coal_block.getIcon(1, 0);
- //renderer.renderStandardBlock(blockFuel, xCoord, yCoord, zCoord);
- /* Render the Item in the center of the block face */
- renderer.overrideBlockTexture = blockFuel.getIcon(1, Metadata.ARCANE_FUEL);
- drawItemOntoBlock(blockFuel.getIcon(1, Metadata.ARCANE_FUEL), xCoord, yCoord, zCoord, worldLightValue, t);
- renderer.clearOverrideBlockTexture();
- } else if (Client.renderPass == 1) {
- switch (worldBlockMetaData) {
- case Metadata.ARCANE_FUEL:
- /* Transparent Cyan Texture */
- //renderer.overrideBlockTexture = blockFuel.getIcon(1, 11);
- //drawFuelBlock(blockFuel, xCoordD, yCoordD, zCoordD, Metadata.ARCANE_FUEL, worldLightValue, t);
- //renderer.clearOverrideBlockTexture();
- break;
- case Metadata.TAINT_INFUSED_COAL:
- /* Transparent Purple Texture */
- //renderer.overrideBlockTexture = blockFuel.getIcon(1, 11);
- //drawFuelBlock(blockFuel, xCoordD, yCoordD, zCoordD, Metadata.TAINT_INFUSED_COAL, worldLightValue, t);
- //renderer.clearOverrideBlockTexture();
- break;
- case Metadata.COMBUSIBLE_DARK_MATTER:
- /* Transparent Black Texture */
- //renderer.overrideBlockTexture = blockFuel.getIcon(1, 11);
- //drawFuelBlock(blockFuel, xCoordD, yCoordD, zCoordD, Metadata.COMBUSIBLE_DARK_MATTER, worldLightValue, t);
- //renderer.clearOverrideBlockTexture();
- break;
- case Metadata.COSMIC_INCENDIARY_CHUNK:
- /* Transparent Red Texture */
- //renderer.overrideBlockTexture = blockFuel.getIcon(1, 11);
- //drawFuelBlock(blockFuel, xCoordD, yCoordD, zCoordD, Metadata.COSMIC_INCENDIARY_CHUNK, worldLightValue, t);
- //renderer.clearOverrideBlockTexture();
- break;
- }
- }
- return true;
- }
- @Override
- public boolean shouldRender3DInInventory(int modelId) {
- return true;
- }
- @Override
- public int getRenderId() {
- return Client.fuelBlockRenderTypeID;
- }
- public void drawItemOntoBlock(IIcon icon, int xCoord, int yCoord, int zCoord, int light, Tessellator t) {
- /* TODO: Find a way to scale / reposition the texture on the block face.
- * TODO: Only insert vanilla coal texture, try to have no textures created manually.
- * TODO: Play with GL11 scale methods
- * TODO: World goes transparent when block is placed below ground? */
- GL11.glEnable(GL11.GL_BLEND);
- t.addTranslation(xCoord, yCoord, zCoord);
- addBlockVeticies(t, xCoord, yCoord, zCoord, icon, "Down");
- }
- public void drawFuelBlock(Block block, int xCoord, int yCoord, int zCoord, int metaData, int light, Tessellator t) {
- IIcon overlay = block.getIcon(1, 11);
- float overlayMaxV = overlay.getMaxV();
- float overlayMinV = overlay.getMinV();
- float overlayWidth = overlay.getIconWidth();
- float overlayHeight = overlay.getIconHeight();
- float overlayMaxU = overlay.getMaxU();
- float overlayMinU = overlay.getMinU();
- float redRGB[] = new float[] {
- 198, 52, 52
- };
- float cyanRGB[] = new float[] {
- 0, 153, 153
- };
- float blackRGB[] = new float[] {
- 0, 0, 0
- };
- float purpleRGB[] = new float[] {
- 153, 0, 153
- };
- int R = 0;
- int G = 1;
- int B = 2;
- float overlayAlpha = 0.20F;
- GL11.glEnable(GL11.GL_BLEND);
- t.setBrightness(light);
- switch (metaData) {
- case Metadata.ARCANE_FUEL:
- t.setColorRGBA_F(cyanRGB[R], cyanRGB[G], cyanRGB[B], overlayAlpha);
- break;
- case Metadata.TAINT_INFUSED_COAL:
- t.setColorRGBA_F(purpleRGB[R], purpleRGB[G], purpleRGB[B], overlayAlpha);
- break;
- case Metadata.COMBUSIBLE_DARK_MATTER:
- t.setColorRGBA_F(blackRGB[R], blackRGB[G], blackRGB[B], overlayAlpha);
- break;
- case Metadata.COSMIC_INCENDIARY_CHUNK:
- t.setColorRGBA_F(redRGB[R], redRGB[G], redRGB[B], overlayAlpha);
- break;
- }
- }
- public void addBlockVeticies(Tessellator t, int xCoord, int yCoord, int zCoord, IIcon icon, String side) {
- float iconMaxU = icon.getMaxU();
- float iconMaxV = icon.getMaxV();
- float iconMinU = icon.getMinU();
- float iconMinV = icon.getMinV();
- /* Block X Value Block Y Value Block Z Value Icon X Value, Icon Y Value */
- if (side.equals("Down")) {
- /* Test */
- t.addVertexWithUV(xCoord + 0, yCoord + 0, zCoord + 0, iconMinU, iconMinV);
- t.addVertexWithUV(xCoord + 0, yCoord + 1.0002F, zCoord + 0, iconMinU, iconMaxV);
- t.addVertexWithUV(xCoord + 1.0002F, yCoord + 1.0002F, zCoord + 0, iconMaxU, iconMaxV);
- t.addVertexWithUV(xCoord + 1.0002F, yCoord + 0, zCoord + 0, iconMaxU, iconMinV);
- } else if (side.equals("Up")) {
- /* Test */
- t.addVertexWithUV(xCoord + 0, yCoord + 1.0002F, zCoord + 1.0002F, iconMinU, iconMinV);
- t.addVertexWithUV(xCoord + 1.0002F, yCoord + 1.0002F, zCoord + 1.0002F, iconMinU, iconMaxV);
- t.addVertexWithUV(xCoord + 1.0002F, yCoord + 1.0002F, zCoord + 0, iconMaxU, iconMaxV);
- t.addVertexWithUV(xCoord + 0, yCoord + 1.0002F, zCoord + 0, iconMaxU, iconMinV);
- } else if (side.equals("North")) {
- /* Test */
- t.addVertexWithUV(xCoord + 0, yCoord + 0, zCoord + 1.0002F, iconMinU, iconMinV);
- t.addVertexWithUV(xCoord + 0, yCoord + 1.0002F, zCoord + 1.0002F, iconMinU, iconMaxV);
- t.addVertexWithUV(xCoord + 1.0002F, yCoord + 1.0002F, zCoord + 1.0002F, iconMaxU, iconMaxV);
- t.addVertexWithUV(xCoord + 1.0002F, yCoord + 0, zCoord + 1.0002F, iconMaxU, iconMinV);
- } else if (side.equals("West")) {
- /* Not Done */
- t.addVertexWithUV(xCoord + 0, yCoord + 0, zCoord + 1.0002F, iconMinU, iconMinV);
- t.addVertexWithUV(xCoord + 0, yCoord + 1.0002F, zCoord + 1.0002F, iconMinU, iconMaxV);
- t.addVertexWithUV(xCoord + 1.0002F, yCoord + 1.0002F, zCoord + 1.0002F, iconMaxU, iconMaxV);
- t.addVertexWithUV(xCoord + 1.0002F, yCoord + 0, zCoord + 1.0002F, iconMaxU, iconMinV);
- } else if (side.equals("South")) {
- /* Test */
- t.addVertexWithUV(xCoord + 0, yCoord + 0, zCoord + 0, iconMinU, iconMinV);
- t.addVertexWithUV(xCoord + 0, yCoord + 1.0002F, zCoord + 0, iconMinU, iconMaxV);
- t.addVertexWithUV(xCoord + 1.0002F, yCoord + 1.0002F, zCoord + 0, iconMaxU, iconMaxV);
- t.addVertexWithUV(xCoord + 1.0002F, yCoord + 0, zCoord + 0, iconMaxU, iconMinV);
- } else if (side.equals("East")) {
- /* Not Done */
- t.addVertexWithUV(xCoord + 0, yCoord + 0, zCoord + 0, iconMinU, iconMinV);
- t.addVertexWithUV(xCoord + 0, yCoord + 1.0002F, zCoord + 0, iconMinU, iconMaxV);
- t.addVertexWithUV(xCoord + 1.0002F, yCoord + 1.0002F, zCoord + 0, iconMaxU, iconMaxV);
- t.addVertexWithUV(xCoord + 1.0002F, yCoord + 0, zCoord + 0, iconMaxU, iconMinV);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment