From ee585c05dcbc10a51335fe4f9610e8823dc055d4 Mon Sep 17 00:00:00 2001 From: Ben Spiers Date: Mon, 15 Dec 2014 00:02:22 +0000 Subject: [PATCH] Make glowing plastic blocks glow. --- .../java/mekanism/client/ClientProxy.java | 3 + .../client/render/RenderGlowPanel.java | 6 -- .../render/block/PlasticRenderingHandler.java | 94 +++++++++++++++++++ .../mekanism/common/block/BlockPlastic.java | 6 ++ 4 files changed, 103 insertions(+), 6 deletions(-) create mode 100644 src/main/java/mekanism/client/render/block/PlasticRenderingHandler.java diff --git a/src/main/java/mekanism/client/ClientProxy.java b/src/main/java/mekanism/client/ClientProxy.java index f2bc01856..d3f5a25da 100644 --- a/src/main/java/mekanism/client/ClientProxy.java +++ b/src/main/java/mekanism/client/ClientProxy.java @@ -51,6 +51,7 @@ import mekanism.client.render.RenderPartTransmitter; import mekanism.client.render.RenderTickHandler; import mekanism.client.render.block.BasicRenderingHandler; import mekanism.client.render.block.MachineRenderingHandler; +import mekanism.client.render.block.PlasticRenderingHandler; import mekanism.client.render.entity.RenderBalloon; import mekanism.client.render.entity.RenderObsidianTNTPrimed; import mekanism.client.render.entity.RenderRobit; @@ -159,6 +160,7 @@ public class ClientProxy extends CommonProxy { public static int MACHINE_RENDER_ID = RenderingRegistry.getNextAvailableRenderId(); public static int BASIC_RENDER_ID = RenderingRegistry.getNextAvailableRenderId(); + public static int PLASTIC_RENDER_ID = RenderingRegistry.getNextAvailableRenderId(); @Override public void loadConfiguration() @@ -339,6 +341,7 @@ public class ClientProxy extends CommonProxy //Register block handlers RenderingRegistry.registerBlockHandler(new MachineRenderingHandler()); RenderingRegistry.registerBlockHandler(new BasicRenderingHandler()); + RenderingRegistry.registerBlockHandler(new PlasticRenderingHandler()); Mekanism.logger.info("Render registrations complete."); } diff --git a/src/main/java/mekanism/client/render/RenderGlowPanel.java b/src/main/java/mekanism/client/render/RenderGlowPanel.java index a007219d7..51d7a0196 100644 --- a/src/main/java/mekanism/client/render/RenderGlowPanel.java +++ b/src/main/java/mekanism/client/render/RenderGlowPanel.java @@ -55,18 +55,12 @@ public class RenderGlowPanel implements IIconSelfRegister { c.computeLighting(LightModel.standardLightModel); } - - for(CCModel c : lightModels) - { - c.computeLighting(LightModel.standardLightModel); - } } public void renderStatic(PartGlowPanel panel) { CCRenderState.reset(); CCRenderState.setBrightness(panel.world(), panel.x(), panel.y(), panel.z()); - CCRenderState.hasColour = true; Colour colour = new ColourRGBA(panel.colour.getColor(0), panel.colour.getColor(1), panel.colour.getColor(2), 1); int side = panel.side.ordinal(); diff --git a/src/main/java/mekanism/client/render/block/PlasticRenderingHandler.java b/src/main/java/mekanism/client/render/block/PlasticRenderingHandler.java new file mode 100644 index 000000000..6779e466c --- /dev/null +++ b/src/main/java/mekanism/client/render/block/PlasticRenderingHandler.java @@ -0,0 +1,94 @@ +package mekanism.client.render.block; + +import mekanism.client.ClientProxy; +import mekanism.client.render.MekanismRenderer; +import mekanism.common.Mekanism; + +import net.minecraft.block.Block; +import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.world.IBlockAccess; +import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +@SideOnly(Side.CLIENT) +public class PlasticRenderingHandler implements ISimpleBlockRenderingHandler +{ + @Override + public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) + { + MekanismRenderer.renderItem(renderer, metadata, block); + } + + @Override + public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) + { + boolean flag = false; + if(block == Mekanism.BlockGlowHDPE) + { + Tessellator tessellator = Tessellator.instance; + tessellator.setBrightness(240); + int meta = world.getBlockMetadata(x, y, z); + int l = block.getRenderColor(meta); + int r = l >> 16 & 0xFF; + int g = l >> 8 & 0xFF; + int b = l & 0xFF; + tessellator.setColorOpaque(r, g, b); + + if((renderer.renderAllFaces) || (block.shouldSideBeRendered(renderer.blockAccess, x, y - 1, z, 0))) + { + renderer.renderFaceYNeg(block, x, y, z, renderer.getBlockIcon(block, renderer.blockAccess, x, y, z, 0)); + flag = true; + } + + if((renderer.renderAllFaces) || (block.shouldSideBeRendered(renderer.blockAccess, x, y + 1, z, 1))) + { + renderer.renderFaceYPos(block, x, y, z, renderer.getBlockIcon(block, renderer.blockAccess, x, y, z, 1)); + flag = true; + } + + if((renderer.renderAllFaces) || (block.shouldSideBeRendered(renderer.blockAccess, x, y, z - 1, 2))) + { + renderer.renderFaceZNeg(block, x, y, z, renderer.getBlockIcon(block, renderer.blockAccess, x, y, z, 2)); + flag = true; + } + + if((renderer.renderAllFaces) || (block.shouldSideBeRendered(renderer.blockAccess, x, y, z + 1, 3))) + { + renderer.renderFaceZPos(block, x, y, z, renderer.getBlockIcon(block, renderer.blockAccess, x, y, z, 3)); + flag = true; + } + + if((renderer.renderAllFaces) || (block.shouldSideBeRendered(renderer.blockAccess, x - 1, y, z, 4))) + { + renderer.renderFaceXNeg(block, x, y, z, renderer.getBlockIcon(block, renderer.blockAccess, x, y, z, 4)); + flag = true; + } + + if((renderer.renderAllFaces) || (block.shouldSideBeRendered(renderer.blockAccess, x + 1, y, z, 5))) + { + renderer.renderFaceXPos(block, x, y, z, renderer.getBlockIcon(block, renderer.blockAccess, x, y, z, 5)); + flag = true; + } + + return flag; + } + flag = renderer.renderStandardBlock(block, x, y, z); + renderer.setRenderBoundsFromBlock(block); + return flag; + + } + + @Override + public int getRenderId() + { + return ClientProxy.PLASTIC_RENDER_ID; + } + + @Override + public boolean shouldRender3DInInventory(int modelId) + { + return true; + } +} diff --git a/src/main/java/mekanism/common/block/BlockPlastic.java b/src/main/java/mekanism/common/block/BlockPlastic.java index 935159c62..066dbe7ae 100644 --- a/src/main/java/mekanism/common/block/BlockPlastic.java +++ b/src/main/java/mekanism/common/block/BlockPlastic.java @@ -3,6 +3,7 @@ package mekanism.common.block; import java.util.List; import mekanism.api.EnumColor; +import mekanism.client.ClientProxy; import mekanism.common.Mekanism; import net.minecraft.block.Block; @@ -122,4 +123,9 @@ public class BlockPlastic extends Block } return false; } + + public int getRenderType() + { + return ClientProxy.PLASTIC_RENDER_ID; + } }