Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class FuelBlockRenderHandler implements ISimpleBlockRenderingHandler{
- public static int lightValue;
- @Override
- public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) {
- /* TODO: Make this fucker work so the blocks render in hand */
- }
- @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);
- IIcon overlayFade = blockFuel.getIcon(1, 11);
- IIcon overlayBox = blockFuel.getIcon(1, 12);
- IIcon overlayCorners = blockFuel.getIcon(1, 13);
- IIcon coalTexture = Blocks.coal_block.getIcon(1, 0);
- lightValue = blockFuel.getMixedBrightnessForBlock(world, xCoord, yCoord, zCoord);
- int worldBlockMetaData = world.getBlockMetadata(xCoord, yCoord, zCoord);
- float redRGB[] = new float[] {
- 204, 0, 0
- };
- float cyanRGB[] = new float[] {
- 0, 153, 153
- };
- float blackRGB[] = new float[] {
- 0, 0, 0
- };
- float purpleRGB[] = new float[] {
- 153, 0, 153
- };
- float goldRGB[] = new float[] {
- 204, 204, 0
- };
- float brownRGB[] = new float[] {
- 102, 51, 0
- };
- int R = 0;
- int G = 1;
- int B = 2;
- float overlayFadeAlpha = 1.0F;
- float overlayBoxAlpha = 1.5F;
- float overlayCornersAlpha = 1.5F;
- Tessellator t = Tessellator.instance;
- if (Client.renderPass == 0) {
- /* Render the block texture itself */
- renderer.overrideBlockTexture = coalTexture;
- renderer.renderStandardBlock(blockFuel, xCoord, yCoord, zCoord);
- /* Render the Opaque item onto the block face */
- renderer.overrideBlockTexture = blockFuel.getIcon(1, Metadata.ARCANE_FUEL);
- drawItemOntoBlock(blockFuel.getIcon(1, Metadata.ARCANE_FUEL), xCoord, yCoord, zCoord, 1, t);
- renderer.overrideBlockTexture = overlayBox;
- drawColoredTextureToBlock(overlayBox, xCoord, yCoord, zCoord, goldRGB[R], goldRGB[G], goldRGB[B], overlayBoxAlpha, 2, t);
- renderer.overrideBlockTexture = overlayCorners;
- drawColoredTextureToBlock(overlayCorners, xCoord, yCoord, zCoord, brownRGB[R], brownRGB[G], brownRGB[B], overlayCornersAlpha, 3, t);
- renderer.clearOverrideBlockTexture();
- } else if (Client.renderPass == 1) {
- switch (worldBlockMetaData) {
- case Metadata.ARCANE_FUEL:
- /* Transparent Cyan Texture */
- renderer.overrideBlockTexture = overlayFade;
- drawColoredTextureToBlock(overlayFade, xCoord, yCoord, zCoord, cyanRGB[R], cyanRGB[G], cyanRGB[B], overlayFadeAlpha, 1, t);
- renderer.clearOverrideBlockTexture();
- break;
- case Metadata.TAINT_INFUSED_COAL:
- /* Transparent Purple Texture */
- renderer.overrideBlockTexture = overlayFade;
- drawColoredTextureToBlock(overlayFade, xCoord, yCoord, zCoord, purpleRGB[R], purpleRGB[G], purpleRGB[B], overlayFadeAlpha, 1, t);
- renderer.clearOverrideBlockTexture();
- break;
- case Metadata.COMBUSIBLE_DARK_MATTER:
- /* Transparent Black Texture */
- renderer.overrideBlockTexture = overlayFade;
- drawColoredTextureToBlock(overlayFade, xCoord, yCoord, zCoord, blackRGB[R], blackRGB[G], blackRGB[B], overlayFadeAlpha, 1, t);
- renderer.clearOverrideBlockTexture();
- break;
- case Metadata.COSMIC_INCENDIARY_CHUNK:
- /* Transparent Red Texture */
- renderer.overrideBlockTexture = overlayFade;
- drawColoredTextureToBlock(overlayFade, xCoord, yCoord, zCoord, redRGB[R], redRGB[G], redRGB[B], overlayFadeAlpha, 1, 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 layer, Tessellator t) {
- addBlockVeticies(t, xCoord, yCoord, zCoord, icon, "North", layer);
- addBlockVeticies(t, xCoord, yCoord, zCoord, icon, "South", layer);
- addBlockVeticies(t, xCoord, yCoord, zCoord, icon, "West", layer);
- addBlockVeticies(t, xCoord, yCoord, zCoord, icon, "East", layer);
- }
- public void drawColoredTextureToBlock(IIcon icon, int xCoord, int yCoord, int zCoord, float r, float g, float b, float alpha, int layer, Tessellator t) {
- t.setColorRGBA_F(r, g, b, alpha);
- addBlockVeticies(t, xCoord, yCoord, zCoord, icon, "North", layer);
- addBlockVeticies(t, xCoord, yCoord, zCoord, icon, "South", layer);
- addBlockVeticies(t, xCoord, yCoord, zCoord, icon, "West", layer);
- addBlockVeticies(t, xCoord, yCoord, zCoord, icon, "East", layer);
- addBlockVeticies(t, xCoord, yCoord, zCoord, icon, "Up", layer);
- }
- public void addBlockVeticies(Tessellator t, int xCoord, int yCoord, int zCoord, IIcon icon, String side, int layer) {
- float iconMaxU = icon.getMaxU();
- float iconMaxV = icon.getMaxV();
- float iconMinU = icon.getMinU();
- float iconMinV = icon.getMinV();
- float xAdd = 1.0001F;
- float yAdd = 1.0001F;
- float zAdd = 1.0001F;
- float setLayerLevel = 0.0F;
- for (int layerLevel = 0; layerLevel < layer; layerLevel++) {
- setLayerLevel = setLayerLevel + 0.0002F;
- }
- //t.setBrightness(lightValue);
- if (side.equals("North")) {
- //North
- GL11.glPushMatrix();
- t.addVertexWithUV(xCoord + xAdd,yCoord + yAdd, zCoord - setLayerLevel, iconMinU, iconMinV);
- t.addVertexWithUV(xCoord + xAdd,yCoord, zCoord - setLayerLevel, iconMinU, iconMaxV);
- t.addVertexWithUV(xCoord, yCoord, zCoord - setLayerLevel, iconMaxU, iconMaxV);
- t.addVertexWithUV(xCoord, yCoord + yAdd, zCoord - setLayerLevel, iconMaxU, iconMinV);
- GL11.glPopMatrix();
- } else if (side.equals("Up")) {
- //Up
- GL11.glPushMatrix();
- t.addVertexWithUV(xCoord, yCoord + yAdd + setLayerLevel, zCoord + zAdd, iconMinU, iconMinV);
- t.addVertexWithUV(xCoord + xAdd,yCoord + yAdd + setLayerLevel, zCoord + zAdd, iconMinU, iconMaxV);
- t.addVertexWithUV(xCoord + xAdd,yCoord + yAdd + setLayerLevel, zCoord, iconMaxU, iconMaxV);
- t.addVertexWithUV(xCoord, yCoord + yAdd + setLayerLevel, zCoord, iconMaxU, iconMinV);
- GL11.glPopMatrix();
- } else if (side.equals("Down")) {
- //Down
- GL11.glPushMatrix();
- t.addVertexWithUV(xCoord, yCoord - setLayerLevel, zCoord, iconMinU, iconMinV);
- t.addVertexWithUV(xCoord, yCoord - setLayerLevel, zCoord + zAdd, iconMinU, iconMaxV);
- t.addVertexWithUV(xCoord + xAdd,yCoord - setLayerLevel, zCoord + zAdd, iconMaxU, iconMaxV);
- t.addVertexWithUV(xCoord + xAdd,yCoord - setLayerLevel, zCoord, iconMaxU, iconMinV);
- GL11.glPopMatrix();
- } else if (side.equals("West")) {
- //West
- GL11.glPushMatrix();
- t.addVertexWithUV(xCoord + xAdd + setLayerLevel,yCoord + yAdd, zCoord + zAdd, iconMinU, iconMinV);
- t.addVertexWithUV(xCoord + xAdd + setLayerLevel,yCoord, zCoord + zAdd, iconMinU, iconMaxV);
- t.addVertexWithUV(xCoord + xAdd + setLayerLevel,yCoord, zCoord, iconMaxU, iconMaxV);
- t.addVertexWithUV(xCoord + xAdd + setLayerLevel,yCoord + yAdd, zCoord, iconMaxU, iconMinV);
- GL11.glPopMatrix();
- } else if (side.equals("South")) {
- //South
- GL11.glPushMatrix();
- t.addVertexWithUV(xCoord + xAdd,yCoord + yAdd, zCoord + zAdd + setLayerLevel, iconMinU, iconMinV);
- t.addVertexWithUV(xCoord + xAdd,yCoord, zCoord + zAdd + setLayerLevel, iconMinU, iconMaxV);
- t.addVertexWithUV(xCoord, yCoord, zCoord + zAdd + setLayerLevel, iconMinU, iconMinV);
- t.addVertexWithUV(xCoord, yCoord + yAdd, zCoord + zAdd + setLayerLevel, iconMinU, iconMaxV);
- GL11.glPopMatrix();
- } else if (side.equals("East")) {
- //East
- GL11.glPushMatrix();
- t.addVertexWithUV(xCoord - setLayerLevel, yCoord + yAdd, zCoord + zAdd, iconMinU, iconMinV);
- t.addVertexWithUV(xCoord - setLayerLevel, yCoord, zCoord + zAdd, iconMinU, iconMaxV);
- t.addVertexWithUV(xCoord - setLayerLevel, yCoord, zCoord, iconMaxU, iconMaxV);
- t.addVertexWithUV(xCoord - setLayerLevel, yCoord + yAdd, zCoord, iconMaxU, iconMinV);
- GL11.glPopMatrix();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement