Search in sources :

Example 1 with TileLamp

use of com.bluepowermod.tile.tier1.TileLamp in project BluePower by Qmunity.

the class BlockLamp method onNeighborBlockChange.

@Override
public void onNeighborBlockChange(World world, int x, int y, int z, Block block) {
    super.onNeighborBlockChange(world, x, y, z, block);
    if (this instanceof BlockLampRGB && block instanceof BlockLampRGB)
        return;
    TileLamp te = get(world, x, y, z);
    if (te == null)
        return;
    te.onUpdate();
}
Also used : TileLamp(com.bluepowermod.tile.tier1.TileLamp)

Example 2 with TileLamp

use of com.bluepowermod.tile.tier1.TileLamp 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 TileLamp

use of com.bluepowermod.tile.tier1.TileLamp in project BluePower by Qmunity.

the class BlockLamp method getPower.

public int getPower(IBlockAccess w, int x, int y, int z) {
    TileLamp te = get(w, x, y, z);
    if (te == null)
        return 0;
    int power = te.getPower();
    if (isInverted())
        power = 15 - power;
    return power;
}
Also used : TileLamp(com.bluepowermod.tile.tier1.TileLamp)

Example 4 with TileLamp

use of com.bluepowermod.tile.tier1.TileLamp in project BluePower by Qmunity.

the class BlockLamp method onBlockAdded.

@Override
public void onBlockAdded(World world, int x, int y, int z) {
    super.onBlockAdded(world, x, y, z);
    TileLamp te = get(world, x, y, z);
    if (te == null)
        return;
    te.onUpdate();
}
Also used : TileLamp(com.bluepowermod.tile.tier1.TileLamp)

Aggregations

TileLamp (com.bluepowermod.tile.tier1.TileLamp)4 BlockLamp (com.bluepowermod.block.machine.BlockLamp)1 Block (net.minecraft.block.Block)1 ForgeDirection (net.minecraftforge.common.util.ForgeDirection)1 Vec3dCube (uk.co.qmunity.lib.vec.Vec3dCube)1 Vec3i (uk.co.qmunity.lib.vec.Vec3i)1