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