Search in sources :

Example 1 with BlockLamp

use of com.bluepowermod.block.machine.BlockLamp in project BluePower by Qmunity.

the class RenderLamp method renderItem.

@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
    GL11.glPushMatrix();
    {
        switch(type) {
            case ENTITY:
                GL11.glTranslated(-0.5, -0.5, -0.5);
                break;
            case EQUIPPED:
                break;
            case EQUIPPED_FIRST_PERSON:
                GL11.glTranslated(0, -0.1, 0);
                break;
            case INVENTORY:
                GL11.glTranslated(0, -0.1, 0);
                break;
            default:
                break;
        }
        BlockLamp block = (BlockLamp) Block.getBlockFromItem(item.getItem());
        int redMask = 0xFF0000, greenMask = 0xFF00, blueMask = 0xFF;
        int r = (block.getColor() & redMask) >> 16;
        int g = (block.getColor() & greenMask) >> 8;
        int b = (block.getColor() & blueMask);
        Vec3dCube cube = new Vec3dCube(0.0, 0.0, 0.0, 1.0, 1.0, 1.0);
        Tessellator t = Tessellator.instance;
        t.startDrawingQuads();
        t.setColorOpaque(r, g, b);
        RenderHelper h = RenderHelper.instance;
        h.reset();
        h.setColor(block.getColor());
        h.renderBox(cube, block.isInverted() ? BlockLamp.on : BlockLamp.off);
        h.reset();
        t.draw();
        if (block.isInverted()) {
            GL11.glEnable(GL11.GL_BLEND);
            GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE);
            // GL11.glAlphaFunc(GL11.GL_EQUAL, (power / 15F) * 1F);
            GL11.glDisable(GL11.GL_TEXTURE_2D);
            GL11.glDisable(GL11.GL_LIGHTING);
            // GL11.glDisable(GL11.GL_CULL_FACE);
            GL11.glDepthMask(false);
            GL11.glBegin(GL11.GL_QUADS);
            com.bluepowermod.client.render.RenderHelper.drawColoredCube(cube.clone().expand(0.8 / 16D), r / 256D, g / 256D, b / 256D, 0.625D);
            GL11.glEnd();
            GL11.glDepthMask(true);
            GL11.glEnable(GL11.GL_CULL_FACE);
            GL11.glEnable(GL11.GL_LIGHTING);
            GL11.glEnable(GL11.GL_TEXTURE_2D);
            GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
            // GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F);
            GL11.glDisable(GL11.GL_BLEND);
        }
    }
    GL11.glPopMatrix();
}
Also used : Tessellator(net.minecraft.client.renderer.Tessellator) RenderHelper(uk.co.qmunity.lib.client.render.RenderHelper) BlockLamp(com.bluepowermod.block.machine.BlockLamp) Vec3dCube(uk.co.qmunity.lib.vec.Vec3dCube)

Example 2 with BlockLamp

use of com.bluepowermod.block.machine.BlockLamp in project BluePower by Qmunity.

the class RenderLamp method renderTileEntityAt.

/******* TESR ***********/
@Override
public void renderTileEntityAt(TileEntity te, double x, double y, double z, float f) {
    if (!(te.getBlockType() instanceof BlockLamp))
        return;
    if (pass != 0) {
        BlockLamp bLamp = (BlockLamp) te.getBlockType();
        int power = ((TileLamp) te).getPower();
        int color = bLamp.getColor(te.getWorldObj(), te.xCoord, te.yCoord, te.zCoord);
        int redMask = 0xFF0000, greenMask = 0xFF00, blueMask = 0xFF;
        int r = (color & redMask) >> 16;
        int g = (color & greenMask) >> 8;
        int b = (color & blueMask);
        if (bLamp.isInverted()) {
            power = 15 - power;
        }
        // power = 15;
        Vec3i vector = new Vec3i(te);
        Vec3dCube box = new Vec3dCube(-0.5, -0.5, -0.5, 0.5, 0.5, 0.5).expand(0.8 / 16D);
        boolean[] renderFaces = new boolean[] { true, true, true, true, true, true };
        for (ForgeDirection d : ForgeDirection.VALID_DIRECTIONS) {
            Vec3i v = vector.getRelative(d);
            Block bl = v.getBlock();
            if (bl instanceof BlockLamp && ((BlockLamp) bl).getPower(v.getWorld(), v.getX(), v.getY(), v.getZ()) > 0) {
                if (d.offsetX < 0) {
                    box.getMin().setX(-0.5);
                    renderFaces[2] = false;
                } else if (d.offsetY < 0) {
                    box.getMin().setY(-0.5);
                    renderFaces[1] = false;
                } else if (d.offsetZ < 0) {
                    box.getMin().setZ(-0.5);
                    renderFaces[4] = false;
                } else if (d.offsetX > 0) {
                    box.getMax().setX(0.5);
                    renderFaces[3] = false;
                } else if (d.offsetY > 0) {
                    box.getMax().setY(0.5);
                    renderFaces[0] = false;
                } else if (d.offsetZ > 0) {
                    box.getMax().setZ(0.5);
                    renderFaces[5] = false;
                }
            }
        }
        box.getMin().add(0.5, 0.5, 0.5);
        box.getMax().add(0.5, 0.5, 0.5);
        GL11.glTranslated(x, y, z);
        GL11.glEnable(GL11.GL_BLEND);
        GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE);
        GL11.glDisable(GL11.GL_TEXTURE_2D);
        GL11.glDisable(GL11.GL_LIGHTING);
        // GL11.glDisable(GL11.GL_CULL_FACE);
        GL11.glBegin(GL11.GL_QUADS);
        double powerDivision = power / 18D;
        com.bluepowermod.client.render.RenderHelper.drawColoredCube(box, r / 256D, g / 256D, b / 256D, powerDivision * 0.625D, renderFaces);
        GL11.glEnd();
        GL11.glEnable(GL11.GL_CULL_FACE);
        GL11.glEnable(GL11.GL_LIGHTING);
        GL11.glEnable(GL11.GL_TEXTURE_2D);
        GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
        // GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F);
        GL11.glDisable(GL11.GL_BLEND);
        GL11.glTranslated(-x, -y, -z);
    }
}
Also used : Vec3i(uk.co.qmunity.lib.vec.Vec3i) ForgeDirection(net.minecraftforge.common.util.ForgeDirection) TileLamp(com.bluepowermod.tile.tier1.TileLamp) Block(net.minecraft.block.Block) BlockLamp(com.bluepowermod.block.machine.BlockLamp) Vec3dCube(uk.co.qmunity.lib.vec.Vec3dCube)

Example 3 with BlockLamp

use of com.bluepowermod.block.machine.BlockLamp in project BluePower by Qmunity.

the class BPBlocks method instantiateBlocks.

private static void instantiateBlocks() {
    basalt = new BlockBasalt(Refs.BASALT_NAME).setResistance(25.0F);
    marble = new BlockStoneOre(Refs.MARBLE_NAME).setResistance(1.0F).setHardness(1.5F);
    basalt_cobble = new BlockStoneOre(Refs.BASALTCOBBLE_NAME);
    basalt_brick = new BlockStoneOre(Refs.BASALTBRICK_NAME);
    marble_brick = new BlockStoneOre(Refs.MARBLEBRICK_NAME);
    cracked_basalt_lava = new BlockCrackedBasalt(Refs.CRACKED_BASALT);
    basaltbrick_cracked = new BlockStoneOre(Refs.CRACKEDBASALTBRICK_NAME);
    basalt_brick_small = new BlockStoneOre(Refs.SMALLBASALTBRICK_NAME);
    marble_brick_small = new BlockStoneOre(Refs.SMALLMARBLEBRICK_NAME);
    fancy_basalt = new BlockStoneOre(Refs.CHISELEDBASALTBRICK_NAME);
    fancy_marble = new BlockStoneOre(Refs.CHISELEDMARBLEBRICK_NAME);
    marble_tile = new BlockStoneOreConnected(Refs.MARBLETILE_NAME);
    basalt_tile = new BlockStoneOreConnected(Refs.BASALTTILE_NAME);
    marble_paver = new BlockStoneOre(Refs.MARBLEPAVER_NAME);
    basalt_paver = new BlockStoneOre(Refs.BASALTPAVER_NAME);
    tiles = new BlockStoneOre(Refs.TILES);
    teslatite_ore = new BlockTeslatiteOre(Refs.TESLATITEORE_NAME);
    ruby_ore = new BlockRubyOre(Refs.RUBYORE_NAME);
    sapphire_ore = new BlockSapphireOre(Refs.SAPPHIREORE_NAME);
    amethyst_ore = new BlockAmethystOre(Refs.AMETHYSTORE_NAME);
    copper_ore = new BlockStoneOre(Refs.COPPERORE_NAME);
    silver_ore = new BlockStoneOre(Refs.SILVERORE_NAME).setToolLevel(2);
    zinc_ore = new BlockStoneOre(Refs.ZINCORE_NAME);
    tungsten_ore = new BlockStoneOre(Refs.TUNGSTENORE_NAME).setToolLevel(3).setResistance(6.0F).setHardness(15.0F);
    ruby_block = new BlockStoneOre(Refs.RUBYBLOCK_NAME).setToolLevel(2);
    sapphire_block = new BlockStoneOre(Refs.SAPPHIREBLOCK_NAME).setToolLevel(2);
    amethyst_block = new BlockStoneOre(Refs.AMETHYSTBLOCK_NAME).setToolLevel(2);
    teslatite_block = new BlockStoneOre(Refs.TESLATITEBLOCK_NAME).setToolLevel(2);
    copper_block = new BlockStoneOre(Refs.COPPERBLOCK_NAME);
    silver_block = new BlockStoneOre(Refs.SILVERBLOCK_NAME).setToolLevel(2);
    zinc_block = new BlockStoneOre(Refs.ZINCBLOCK_NAME);
    tungsten_block = new BlockStoneOre(Refs.TUNGSTENBLOCK_NAME).setToolLevel(3).setResistance(25.0F).setHardness(5.0F);
    sapphire_glass = new BlockStoneOreConnected(Refs.SAPPHIREGLASS_NAME).setTransparent(true).setHardness(10).setResistance(10000);
    reinforced_sapphire_glass = new BlockStoneOreConnected(Refs.REINFORCEDSAPPHIREGLASS_NAME).setTransparent(true).setWitherproof(true).setTooltip(MinecraftColor.RED.getChatColor() + "Witherproof").setHardness(30).setResistance(Integer.MAX_VALUE);
    flax_crop = new BlockCrop().setBlockName(Refs.FLAXCROP_NAME);
    indigo_flower = new BlockCustomFlower(Refs.INDIGOFLOWER_NAME);
    alloyfurnace = new BlockAlloyFurnace();
    block_breaker = new BlockContainerFrontRender(Material.rock, TileBlockBreaker.class).setBlockName(Refs.BLOCKBREAKER_NAME);
    igniter = new BlockIgniter();
    buffer = new BlockContainerBase(Material.rock, TileBuffer.class).setGuiId(GuiIDs.BUFFER).setBlockName(Refs.BLOCKBUFFER_NAME);
    deployer = new BlockContainerFrontRender(Material.rock, TileDeployer.class).setGuiId(GuiIDs.DEPLOYER_ID).setBlockName(Refs.BLOCKDEPLOYER_NAME);
    transposer = new BlockContainerBase(Material.rock, TileTransposer.class).setBlockName(Refs.TRANSPOSER_NAME);
    sorting_machine = new BlockContainerBase(Material.rock, TileSortingMachine.class).setGuiId(GuiIDs.SORTING_MACHINE).setBlockName(Refs.SORTING_MACHINE_NAME);
    project_table = new BlockProjectTable().setGuiId(GuiIDs.PROJECTTABLE_ID);
    auto_project_table = new BlockProjectTable(TileAutoProjectTable.class).setGuiId(GuiIDs.PROJECTTABLE_ID).setBlockName(Refs.AUTOPROJECTTABLE_NAME);
    circuit_table = new BlockProjectTable(TileCircuitTable.class).setGuiId(GuiIDs.CIRCUITTABLE_ID).setBlockName(Refs.CIRCUITTABLE_NAME);
    circuit_database = new BlockCircuitDatabase(TileCircuitDatabase.class).setGuiId(GuiIDs.CIRCUITDATABASE_MAIN_ID).setBlockName(Refs.CIRCUITDATABASE_NAME);
    ejector = new BlockContainerTwoSideRender(Material.rock, TileEjector.class).setGuiId(GuiIDs.EJECTOR_ID).setBlockName(Refs.EJECTOR_NAME);
    relay = new BlockContainerTwoSideRender(Material.rock, TileRelay.class).setGuiId(GuiIDs.RELAY_ID).setBlockName(Refs.RELAY_NAME);
    filter = new BlockContainerBase(Material.rock, TileFilter.class).setGuiId(GuiIDs.FILTER_ID).setBlockName(Refs.FILTER_NAME);
    retriever = new BlockContainerBase(Material.rock, TileRetriever.class).setGuiId(GuiIDs.RETRIEVER_ID).setBlockName(Refs.RETRIEVER_NAME);
    regulator = new BlockContainerTwoSideRender(Material.rock, TileRegulator.class).setGuiId(GuiIDs.REGULATOR_ID).emitsRedstone().setBlockName(Refs.REGULATOR_NAME);
    item_detector = new BlockContainerTwoSideRender(Material.rock, TileItemDetector.class).setGuiId(GuiIDs.ITEMDETECTOR_ID).emitsRedstone().setBlockName(Refs.ITEMDETECTOR_NAME);
    manager = new BlockRejecting(Material.rock, TileManager.class).setGuiId(GuiIDs.MANAGER_ID).emitsRedstone().setBlockName(Refs.MANAGER_NAME);
    // engine = new BlockEngine();
    // kinetic_generator = new BlockKineticGenerator();
    // windmill = new BlockWindmill();
    // cpu = new BlockCPU();
    // monitor = new BlockMonitor();
    // disk_drive = new BlockDiskDrive();
    // io_expander = new BlockIOExpander();
    blockLamp = new Block[MinecraftColor.VALID_COLORS.length];
    blockLampRGB = new BlockLampRGB(false);
    blockLampInverted = new Block[MinecraftColor.VALID_COLORS.length];
    blockLampRGBInverted = new BlockLampRGB(true);
    for (int i = 0; i < MinecraftColor.VALID_COLORS.length; i++) blockLamp[i] = new BlockLamp(false, MinecraftColor.VALID_COLORS[i]);
    for (int i = 0; i < MinecraftColor.VALID_COLORS.length; i++) blockLampInverted[i] = new BlockLamp(true, MinecraftColor.VALID_COLORS[i]);
}
Also used : BlockAmethystOre(com.bluepowermod.block.worldgen.BlockAmethystOre) BlockCircuitDatabase(com.bluepowermod.block.machine.BlockCircuitDatabase) BlockSapphireOre(com.bluepowermod.block.worldgen.BlockSapphireOre) TileFilter(com.bluepowermod.tile.tier1.TileFilter) TileEjector(com.bluepowermod.tile.tier1.TileEjector) BlockLamp(com.bluepowermod.block.machine.BlockLamp) BlockRubyOre(com.bluepowermod.block.worldgen.BlockRubyOre) BlockRejecting(com.bluepowermod.block.machine.BlockRejecting) TileBuffer(com.bluepowermod.tile.tier1.TileBuffer) BlockStoneOre(com.bluepowermod.block.worldgen.BlockStoneOre) BlockAlloyFurnace(com.bluepowermod.block.machine.BlockAlloyFurnace) TileCircuitDatabase(com.bluepowermod.tile.tier3.TileCircuitDatabase) BlockContainerFrontRender(com.bluepowermod.block.machine.BlockContainerFrontRender) TileRelay(com.bluepowermod.tile.tier1.TileRelay) BlockLampRGB(com.bluepowermod.block.machine.BlockLampRGB) BlockContainerBase(com.bluepowermod.block.BlockContainerBase) BlockIgniter(com.bluepowermod.block.machine.BlockIgniter) TileAutoProjectTable(com.bluepowermod.tile.tier2.TileAutoProjectTable) BlockProjectTable(com.bluepowermod.block.machine.BlockProjectTable) TileRetriever(com.bluepowermod.tile.tier2.TileRetriever) TileSortingMachine(com.bluepowermod.tile.tier2.TileSortingMachine) BlockCrackedBasalt(com.bluepowermod.block.worldgen.BlockCrackedBasalt) BlockCrop(com.bluepowermod.block.worldgen.BlockCrop) BlockTeslatiteOre(com.bluepowermod.block.worldgen.BlockTeslatiteOre) BlockStoneOreConnected(com.bluepowermod.block.worldgen.BlockStoneOreConnected) BlockBasalt(com.bluepowermod.block.worldgen.BlockBasalt) BlockContainerTwoSideRender(com.bluepowermod.block.machine.BlockContainerTwoSideRender) BlockCustomFlower(com.bluepowermod.block.worldgen.BlockCustomFlower) TileDeployer(com.bluepowermod.tile.tier1.TileDeployer) TileCircuitTable(com.bluepowermod.tile.tier2.TileCircuitTable)

Example 4 with BlockLamp

use of com.bluepowermod.block.machine.BlockLamp in project BluePower by Qmunity.

the class TileLamp method onUpdate.

public void onUpdate() {
    if (blockType instanceof BlockLampRGB) {
        connections.recalculateConnections();
        int connected = 0;
        for (ForgeDirection s : ForgeDirection.VALID_DIRECTIONS) connected += (connections.getConnectionOnSide(s) != null) ? 1 : 0;
        if (connected == 0)
            bundledPower = new byte[16];
        int pow = 0;
        if (((BlockLamp) blockType).isInverted()) {
            pow = 255 - Math.min(Math.min(bundledPower[MinecraftColor.RED.ordinal()] & 0xFF, bundledPower[MinecraftColor.GREEN.ordinal()] & 0xFF), bundledPower[MinecraftColor.BLUE.ordinal()] & 0xFF);
        } else {
            pow = Math.max(Math.max(bundledPower[MinecraftColor.RED.ordinal()] & 0xFF, bundledPower[MinecraftColor.GREEN.ordinal()] & 0xFF), bundledPower[MinecraftColor.BLUE.ordinal()] & 0xFF);
        }
        power = (int) ((pow / 256D) * 15);
        sendUpdatePacket();
    } else {
        int pow = RedstoneHelper.getInput(getWorldObj(), xCoord, yCoord, zCoord);
        if (pow != power) {
            power = pow;
            sendUpdatePacket();
            getWorldObj().markBlockRangeForRenderUpdate(xCoord, yCoord, zCoord, xCoord, yCoord, zCoord);
            try {
                getWorldObj().updateLightByType(EnumSkyBlock.Block, xCoord, yCoord, zCoord);
            } catch (Exception ex) {
            }
            getWorldObj().notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord, getBlockType());
        }
    }
}
Also used : BlockLampRGB(com.bluepowermod.block.machine.BlockLampRGB) ForgeDirection(net.minecraftforge.common.util.ForgeDirection) BlockLamp(com.bluepowermod.block.machine.BlockLamp)

Aggregations

BlockLamp (com.bluepowermod.block.machine.BlockLamp)4 BlockLampRGB (com.bluepowermod.block.machine.BlockLampRGB)2 ForgeDirection (net.minecraftforge.common.util.ForgeDirection)2 Vec3dCube (uk.co.qmunity.lib.vec.Vec3dCube)2 BlockContainerBase (com.bluepowermod.block.BlockContainerBase)1 BlockAlloyFurnace (com.bluepowermod.block.machine.BlockAlloyFurnace)1 BlockCircuitDatabase (com.bluepowermod.block.machine.BlockCircuitDatabase)1 BlockContainerFrontRender (com.bluepowermod.block.machine.BlockContainerFrontRender)1 BlockContainerTwoSideRender (com.bluepowermod.block.machine.BlockContainerTwoSideRender)1 BlockIgniter (com.bluepowermod.block.machine.BlockIgniter)1 BlockProjectTable (com.bluepowermod.block.machine.BlockProjectTable)1 BlockRejecting (com.bluepowermod.block.machine.BlockRejecting)1 BlockAmethystOre (com.bluepowermod.block.worldgen.BlockAmethystOre)1 BlockBasalt (com.bluepowermod.block.worldgen.BlockBasalt)1 BlockCrackedBasalt (com.bluepowermod.block.worldgen.BlockCrackedBasalt)1 BlockCrop (com.bluepowermod.block.worldgen.BlockCrop)1 BlockCustomFlower (com.bluepowermod.block.worldgen.BlockCustomFlower)1 BlockRubyOre (com.bluepowermod.block.worldgen.BlockRubyOre)1 BlockSapphireOre (com.bluepowermod.block.worldgen.BlockSapphireOre)1 BlockStoneOre (com.bluepowermod.block.worldgen.BlockStoneOre)1