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();
}
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);
}
}
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;
}
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();
}