Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package tterrag.stoneLamp.client;
- import net.minecraft.block.Block;
- import net.minecraft.client.renderer.RenderBlocks;
- import net.minecraft.client.renderer.Tessellator;
- import net.minecraft.item.ItemStack;
- import net.minecraft.util.Icon;
- import net.minecraft.world.IBlockAccess;
- import tterrag.stoneLamp.block.BlockLamp;
- import tterrag.stoneLamp.block.ModBlock;
- import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
- public class ColoredLampRenderer implements ISimpleBlockRenderingHandler {
- static int renderPass;
- @Override
- public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) {
- renderer.setOverrideBlockTexture(BlockLamp.icons[0]);
- renderer.renderBlockAsItem(Block.glass, 0, 1);
- renderer.clearOverrideBlockTexture();
- }
- @Override
- public boolean shouldRender3DInInventory() {
- return true;
- }
- @Override
- public int getRenderId() {
- return BlockLamp.renderId;
- }
- @Override
- public boolean renderWorldBlock(IBlockAccess blockAccess, int x, int y, int z, Block rawBlock, int modelId, RenderBlocks renderer) {
- if(renderPass == 0)
- {
- RenderUtil.setTesselatorBrightness(blockAccess, x, y, z);
- System.out.println(blockAccess.getBlockId(x, y, z));
- int id = blockAccess.getBlockId(x, y, z);
- int brightness = rawBlock.getMixedBrightnessForBlock(blockAccess, x, y, z);
- if (rawBlock instanceof BlockLamp && id == ModBlock.LAMP_ID || id == ModBlock.EMPTYLAMP_ID || id == ModBlock.COLOREDLAMP_ID || id == ModBlock.EMPTYCOLOREDLAMP_ID)
- {
- BlockLamp block = ((BlockLamp) rawBlock);
- renderer.renderFaceYNeg(block, x, y, z, BlockLamp.icons[15]);
- renderer.renderFaceYPos(block, x, y, z, BlockLamp.icons[15]);
- renderer.renderFaceXNeg(block, x, y, z, BlockLamp.icons[15]);
- renderer.renderFaceXPos(block, x, y, z, BlockLamp.icons[15]);
- renderer.renderFaceZNeg(block, x, y, z, BlockLamp.icons[15]);
- renderer.renderFaceZPos(block, x, y, z, BlockLamp.icons[15]);
- for (Icon icon : getIconsToDraw(blockAccess, x, y, z, block, 0))
- if (icon != null)
- renderer.renderFaceYNeg(block, x, y, z, icon);
- for (Icon icon : getIconsToDraw(blockAccess, x, y, z, block, 1))
- if (icon != null)
- renderer.renderFaceYPos(block, x, y, z, icon);
- for (Icon icon : getIconsToDraw(blockAccess, x, y, z, block, 2))
- if (icon != null)
- renderer.renderFaceXNeg(block, x, y, z, icon);
- for (Icon icon : getIconsToDraw(blockAccess, x, y, z, block, 3))
- if (icon != null)
- renderer.renderFaceXPos(block, x, y, z, icon);
- for (Icon icon : getIconsToDraw(blockAccess, x, y, z, block, 4))
- if (icon != null)
- renderer.renderFaceZNeg(block, x, y, z, icon);
- for (Icon icon : getIconsToDraw(blockAccess, x, y, z, block, 5))
- if (icon != null)
- renderer.renderFaceZPos(block, x, y, z, icon);
- //renderer.renderStandardBlock(block, x, y, z);
- }
- else
- {
- renderer.setOverrideBlockTexture(BlockLamp.icons[0]);
- renderer.renderStandardBlock(rawBlock, x, y, z);
- renderer.clearOverrideBlockTexture();
- }
- }
- Tessellator tessellator = Tessellator.instance;
- tessellator.setBrightness(rawBlock.getMixedBrightnessForBlock(blockAccess, x, y, z));
- return true;
- }
- public void renderFrameItem(ItemStack stack) {
- RenderUtil.bindBlockTexture();
- Tessellator.instance.draw();
- }
- public Icon[] getIconsToDraw(IBlockAccess blockAccess, int x, int y, int z, Block block, int side)
- {
- boolean up, down, left, right, upLeft, upRight, downLeft, downRight;
- int id = block.blockID;
- switch (side) {
- case 0:
- up = id == blockAccess.getBlockId(x + 1, y, z);
- down = id == blockAccess.getBlockId(x - 1, y, z);
- left = id == blockAccess.getBlockId(x, y, z + 1);
- right = id == blockAccess.getBlockId(x, y, z - 1);
- upLeft = id == blockAccess.getBlockId(x + 1, y, z + 1);
- upRight = id == blockAccess.getBlockId(x + 1, y, z - 1);
- downLeft = id == blockAccess.getBlockId(x - 1, y, z + 1);
- downRight = id == blockAccess.getBlockId(x - 1, y, z + 1);
- break;
- case 1:
- up = id == blockAccess.getBlockId(x + 1, y, z);
- down = id == blockAccess.getBlockId(x - 1, y, z);
- left = id == blockAccess.getBlockId(x, y, z + 1);
- right = id == blockAccess.getBlockId(x, y, z - 1);
- upLeft = id == blockAccess.getBlockId(x + 1, y, z + 1);
- upRight = id == blockAccess.getBlockId(x + 1, y, z - 1);
- downLeft = id == blockAccess.getBlockId(x - 1, y, z + 1);
- downRight = id == blockAccess.getBlockId(x - 1, y, z + 1);
- break;
- case 2:
- up = id == blockAccess.getBlockId(x + 1, y, z);
- down = id == blockAccess.getBlockId(x - 1, y, z);
- left = id == blockAccess.getBlockId(x, y, z + 1);
- right = id == blockAccess.getBlockId(x, y, z - 1);
- upLeft = id == blockAccess.getBlockId(x + 1, y, z + 1);
- upRight = id == blockAccess.getBlockId(x + 1, y, z - 1);
- downLeft = id == blockAccess.getBlockId(x - 1, y, z + 1);
- downRight = id == blockAccess.getBlockId(x - 1, y, z + 1);
- break;
- case 3:
- up = id == blockAccess.getBlockId(x + 1, y, z);
- down = id == blockAccess.getBlockId(x - 1, y, z);
- left = id == blockAccess.getBlockId(x, y, z + 1);
- right = id == blockAccess.getBlockId(x, y, z - 1);
- upLeft = id == blockAccess.getBlockId(x + 1, y, z + 1);
- upRight = id == blockAccess.getBlockId(x + 1, y, z - 1);
- downLeft = id == blockAccess.getBlockId(x - 1, y, z + 1);
- downRight = id == blockAccess.getBlockId(x - 1, y, z + 1);
- break;
- case 4:
- up = id == blockAccess.getBlockId(x + 1, y, z);
- down = id == blockAccess.getBlockId(x - 1, y, z);
- left = id == blockAccess.getBlockId(x, y, z + 1);
- right = id == blockAccess.getBlockId(x, y, z - 1);
- upLeft = id == blockAccess.getBlockId(x + 1, y, z + 1);
- upRight = id == blockAccess.getBlockId(x + 1, y, z - 1);
- downLeft = id == blockAccess.getBlockId(x - 1, y, z + 1);
- downRight = id == blockAccess.getBlockId(x - 1, y, z + 1);
- break;
- case 5:
- up = id == blockAccess.getBlockId(x + 1, y, z);
- down = id == blockAccess.getBlockId(x - 1, y, z);
- left = id == blockAccess.getBlockId(x, y, z + 1);
- right = id == blockAccess.getBlockId(x, y, z - 1);
- upLeft = id == blockAccess.getBlockId(x + 1, y, z + 1);
- upRight = id == blockAccess.getBlockId(x + 1, y, z - 1);
- downLeft = id == blockAccess.getBlockId(x - 1, y, z + 1);
- downRight = id == blockAccess.getBlockId(x - 1, y, z + 1);
- break;
- }
- return new Icon[1];
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment