use of uk.co.qmunity.lib.client.render.RenderHelper 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 uk.co.qmunity.lib.client.render.RenderHelper in project BluePower by Qmunity.
the class GateNullCell method drawHighlight.
@Override
public boolean drawHighlight(QMovingObjectPosition mop, EntityPlayer player, float frame) {
Vec3d hit = new Vec3d(mop.hitVec).sub(mop.blockX, mop.blockY, mop.blockZ).rotateUndo(getFace(), Vec3d.center);
Vec3 pos = player.getPosition(frame);
ItemStack held = player.getCurrentEquippedItem();
if (held == null)
return false;
if (held.getItem() instanceof ItemPart) {
IPart part = ((ItemPart) held.getItem()).createPart(held, player, null, null);
if (part == null)
return false;
if (!(part instanceof PartRedwireFaceUninsulated))
return false;
PartRedwireFace wire = (PartRedwireFace) part;
RenderHelper renderer = RenderHelper.instance;
renderer.fullReset();
renderer.setRenderCoords(getWorld(), getX(), getY(), getZ());
double height = 2 / 16D;
IIcon wireIcon = IconSupplier.wire;
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture);
Tessellator.instance.startDrawingQuads();
Tessellator.instance.addTranslation((float) -pos.xCoord, (float) -pos.yCoord, (float) -pos.zCoord);
{
switch(getFace()) {
case DOWN:
break;
case UP:
renderer.addTransformation(new Rotation(180, 180, 0, Vec3d.center));
break;
case NORTH:
renderer.addTransformation(new Rotation(90, 0, 0, Vec3d.center));
break;
case SOUTH:
renderer.addTransformation(new Rotation(-90, 0, 0, Vec3d.center));
break;
case WEST:
renderer.addTransformation(new Rotation(0, 0, -90, Vec3d.center));
break;
case EAST:
renderer.addTransformation(new Rotation(0, 0, 90, Vec3d.center));
break;
default:
break;
}
int rotation = getRotation();
if (rotation != -1)
renderer.addTransformation(new Rotation(0, 90 * -rotation, 0));
renderer.setOpacity(0.5);
renderer.setColor(WireHelper.getColorForPowerLevel(wire.getRedwireType(ForgeDirection.UNKNOWN), (byte) (255 / 2)));
ForgeDirection dir = ForgeDirection.NORTH;
if (getRotation() % 2 == 1)
dir = dir.getRotation(getFace());
if (hit.getY() > 2 / 16D) {
if (typeB == null) {
renderer.renderBox(new Vec3dCube(0 / 16D, 2 / 16D, 7 / 16D, 2 / 16D, 10 / 16D, 9 / 16D), wireIcon);
renderer.renderBox(new Vec3dCube(14 / 16D, 2 / 16D, 7 / 16D, 16 / 16D, 10 / 16D, 9 / 16D), wireIcon);
renderer.renderBox(new Vec3dCube(0 / 16D, 10 / 16D, 7 / 16D, 16 / 16D, 12 / 16D, 9 / 16D), wireIcon);
}
} else {
if (typeA == null)
renderer.renderBox(new Vec3dCube(7 / 16D, 2 / 16D, 0 / 16D, 9 / 16D, 2 / 16D + height, 16 / 16D), wireIcon);
}
renderer.fullReset();
}
Tessellator.instance.addTranslation((float) pos.xCoord, (float) pos.yCoord, (float) pos.zCoord);
Tessellator.instance.draw();
GL11.glDisable(GL11.GL_BLEND);
return true;
} else if (held.getItem() instanceof IScrewdriver) {
// List<Vec3dCube> l = new ArrayList<Vec3dCube>();
// super.addBoxes(l);
// boolean def = false;
// for (Vec3dCube c : l)
// if (mop.getCube().equals(c.clone().rotate(getFace(), Vec3d.center).rotate(0, 90 * -getRotation(), 0, Vec3d.center)))
// def = true;
// if (def || hit.getY() <= 2 / 16D) {
// Vec3dCube c = Vec3dCube.merge(getSelectionBoxes()).expand(0.001);
//
// GL11.glEnable(GL11.GL_BLEND);
// GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
// GL11.glDisable(GL11.GL_TEXTURE_2D);
// GL11.glColor4f(0, 0, 0, 0.4F);
// GL11.glLineWidth(2);
// GL11.glDepthMask(true);
// GL11.glPushMatrix();
//
// Tessellator var2 = Tessellator.instance;
// var2.startDrawing(3);
// Tessellator.instance.addTranslation((float) -pos.xCoord + getX(), (float) -pos.yCoord + getY(), (float) -pos.zCoord
// + getZ());
// var2.addVertex(c.getMinX(), c.getMinY(), c.getMinZ());
// var2.addVertex(c.getMaxX(), c.getMinY(), c.getMinZ());
// var2.addVertex(c.getMaxX(), c.getMinY(), c.getMaxZ());
// var2.addVertex(c.getMinX(), c.getMinY(), c.getMaxZ());
// var2.addVertex(c.getMinX(), c.getMinY(), c.getMinZ());
// var2.draw();
// var2.startDrawing(3);
// var2.addVertex(c.getMinX(), c.getMaxY(), c.getMinZ());
// var2.addVertex(c.getMaxX(), c.getMaxY(), c.getMinZ());
// var2.addVertex(c.getMaxX(), c.getMaxY(), c.getMaxZ());
// var2.addVertex(c.getMinX(), c.getMaxY(), c.getMaxZ());
// var2.addVertex(c.getMinX(), c.getMaxY(), c.getMinZ());
// var2.draw();
// var2.startDrawing(1);
// var2.addVertex(c.getMinX(), c.getMinY(), c.getMinZ());
// var2.addVertex(c.getMinX(), c.getMaxY(), c.getMinZ());
// var2.addVertex(c.getMaxX(), c.getMinY(), c.getMinZ());
// var2.addVertex(c.getMaxX(), c.getMaxY(), c.getMinZ());
// var2.addVertex(c.getMaxX(), c.getMinY(), c.getMaxZ());
// var2.addVertex(c.getMaxX(), c.getMaxY(), c.getMaxZ());
// var2.addVertex(c.getMinX(), c.getMinY(), c.getMaxZ());
// var2.addVertex(c.getMinX(), c.getMaxY(), c.getMaxZ());
// Tessellator.instance.addTranslation((float) pos.xCoord - getX(), (float) pos.yCoord - getY(), (float) pos.zCoord - getZ());
// var2.draw();
//
// GL11.glPopMatrix();
// GL11.glDepthMask(false);
// GL11.glEnable(GL11.GL_TEXTURE_2D);
// GL11.glDisable(GL11.GL_BLEND);
//
// return true;
// }
//
// return true;
}
return false;
}
use of uk.co.qmunity.lib.client.render.RenderHelper in project BluePower by Qmunity.
the class RenderCircuitTile method renderItem.
@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
boolean blend = GL11.glGetBoolean(GL11.GL_BLEND);
boolean alpha = GL11.glGetBoolean(GL11.GL_ALPHA_TEST);
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GL11.glEnable(GL11.GL_ALPHA_TEST);
GL11.glPushMatrix();
{
switch(type) {
case ENTITY:
GL11.glTranslated(-0.5, 0, -0.5);
break;
case EQUIPPED:
GL11.glTranslated(-0.375, 0.5, -0.125);
GL11.glScaled(1.5, 1.5, 1.5);
break;
case EQUIPPED_FIRST_PERSON:
GL11.glTranslated(-0.375, 0.75, -0.125);
GL11.glScaled(1.5, 1.5, 1.5);
break;
case INVENTORY:
GL11.glTranslated(0, 0.4, 0);
GL11.glScaled(1.75, 1.75, 1.75);
break;
default:
break;
}
Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture);
Tessellator.instance.startDrawingQuads();
RenderHelper rh = RenderHelper.instance;
rh.renderBox(new Vec3dCube(4 / 16D, 0, 4 / 16D, 12 / 16D, 2 / 16D, 12 / 16D), Blocks.stone_slab.getIcon(0, 0));
rh.reset();
Tessellator.instance.draw();
double wireHeight = 1 / 32D;
double wireWidth = 1.5 / 16D;
double bundledHeight = 4 / 32D;
double bundledWidth = 6 / 16D;
IIcon wireTexture = IconSupplier.wire;
// Bluestone tiles
rh.setColor(WireHelper.getColorForPowerLevel(RedwireType.BLUESTONE, (byte) (255 / 2)));
if (item.getItem() == BPItems.bluestone_cathode_tile) {
com.bluepowermod.client.render.RenderHelper.renderDigitalRedstoneTorch(0, 0, 0, 13 / 16D, true);
Tessellator.instance.startDrawingQuads();
rh.renderBox(new Vec3dCube(0.5 - (wireWidth / 2), 2 / 16D, 4 / 16D, 0.5 + (wireWidth / 2), 2 / 16D + wireHeight, 7 / 16D), wireTexture);
Tessellator.instance.draw();
}
if (item.getItem() == BPItems.bluestone_pointer_tile) {
com.bluepowermod.client.render.RenderHelper.renderDigitalRedstoneTorch(0, 0, 0, 13 / 16D, true);
GL11.glPushMatrix();
GL11.glTranslated(0.5, 0, 0.5);
GL11.glScaled(0.875, 1, 0.875);
GL11.glTranslated(-0.5, 0, -0.5);
com.bluepowermod.client.render.RenderHelper.renderPointer(0, 3 / 16D, 0, 0.25);
GL11.glPopMatrix();
Tessellator.instance.startDrawingQuads();
rh.renderBox(new Vec3dCube(0.5 - (wireWidth / 2), 2 / 16D, 4 / 16D, 0.5 + (wireWidth / 2), 2 / 16D + wireHeight, 7 / 16D), wireTexture);
Tessellator.instance.draw();
}
if (item.getItem() == BPItems.bluestone_anode_tile) {
Tessellator.instance.startDrawingQuads();
rh.renderBox(new Vec3dCube(0.5 - (wireWidth / 2), 2 / 16D, 4 / 16D, 0.5 + (wireWidth / 2), 2 / 16D + wireHeight, 7.5 / 16D), wireTexture);
rh.renderBox(new Vec3dCube(4 / 16D, 2 / 16D, 0.5 - (wireWidth / 2), 12 / 16D, 2 / 16D + wireHeight, 0.5 + (wireWidth / 2)), wireTexture);
Tessellator.instance.draw();
}
if (item.getItem() == BPItems.bluestone_wire_tile) {
Tessellator.instance.startDrawingQuads();
rh.renderBox(new Vec3dCube(0.5 - (wireWidth / 2), 2 / 16D, 4 / 16D, 0.5 + (wireWidth / 2), 2 / 16D + wireHeight, 12 / 16D), wireTexture);
Tessellator.instance.draw();
}
// Redstone tiles
rh.setColor(WireHelper.getColorForPowerLevel(RedwireType.RED_ALLOY, (byte) (255 / 2)));
if (item.getItem() == BPItems.redstone_cathode_tile) {
com.bluepowermod.client.render.RenderHelper.renderAnalogRedstoneTorch(0, 0, 0, 13 / 16D, true);
Tessellator.instance.startDrawingQuads();
rh.renderBox(new Vec3dCube(0.5 - (wireWidth / 2), 2 / 16D, 4 / 16D, 0.5 + (wireWidth / 2), 2 / 16D + wireHeight, 7 / 16D), wireTexture);
Tessellator.instance.draw();
}
if (item.getItem() == BPItems.redstone_pointer_tile) {
com.bluepowermod.client.render.RenderHelper.renderAnalogRedstoneTorch(0, 0, 0, 13 / 16D, true);
GL11.glPushMatrix();
GL11.glTranslated(0.5, 0, 0.5);
GL11.glScaled(0.875, 1, 0.875);
GL11.glTranslated(-0.5, 0, -0.5);
com.bluepowermod.client.render.RenderHelper.renderPointer(0, 3 / 16D, 0, 0.25);
GL11.glPopMatrix();
Tessellator.instance.startDrawingQuads();
rh.renderBox(new Vec3dCube(0.5 - (wireWidth / 2), 2 / 16D, 4 / 16D, 0.5 + (wireWidth / 2), 2 / 16D + wireHeight, 7 / 16D), wireTexture);
Tessellator.instance.draw();
}
if (item.getItem() == BPItems.redstone_anode_tile) {
Tessellator.instance.startDrawingQuads();
rh.renderBox(new Vec3dCube(0.5 - (wireWidth / 2), 2 / 16D, 4 / 16D, 0.5 + (wireWidth / 2), 2 / 16D + wireHeight, 7.5 / 16D), wireTexture);
rh.renderBox(new Vec3dCube(4 / 16D, 2 / 16D, 0.5 - (wireWidth / 2), 12 / 16D, 2 / 16D + wireHeight, 0.5 + (wireWidth / 2)), wireTexture);
Tessellator.instance.draw();
}
if (item.getItem() == BPItems.redstone_wire_tile) {
Tessellator.instance.startDrawingQuads();
rh.renderBox(new Vec3dCube(0.5 - (wireWidth / 2), 2 / 16D, 4 / 16D, 0.5 + (wireWidth / 2), 2 / 16D + wireHeight, 12 / 16D), wireTexture);
Tessellator.instance.draw();
}
rh.setColor(0xFFFFFF);
if (item.getItem() == BPItems.stone_bundle) {
GL11.glPushMatrix();
{
GL11.glTranslated(0.5, 0, 0.5);
GL11.glScaled(0.5, 0.5, 0.5);
GL11.glTranslated(-0.5, 0.125, -0.5);
Tessellator.instance.startDrawingQuads();
rh.renderBox(new Vec3dCube(0.5 - (bundledWidth / 2), 2 / 16D, 0, 0.5 + (bundledWidth / 2), 2 / 16D + bundledHeight, 1), null, IconSupplier.wireBundledStraight1, IconSupplier.wireBundledSide1, IconSupplier.wireBundledSide2, IconSupplier.wireBundledConnection, IconSupplier.wireBundledConnection);
Tessellator.instance.draw();
}
GL11.glPopMatrix();
}
// Misc renderers
rh.setColor(0xFFFFFF);
rh.addTransformation(new Translation(0.375, 0, 0.375));
Tessellator.instance.startDrawingQuads();
if (item.getItem() == BPItems.quartz_resonator_tile) {
new GateComponentQuartzResonator(null, -1).renderStatic(new Vec3i(0, 0, 0), rh, 0);
}
if (item.getItem() == BPItems.silicon_chip_tile) {
new GateComponentSiliconChip(null, -1).setState(true).renderStatic(new Vec3i(0, 0, 0), rh, 0);
}
if (item.getItem() == BPItems.tainted_silicon_chip_tile) {
new GateComponentTaintedSiliconChip(null, -1).setState(true).renderStatic(new Vec3i(0, 0, 0), rh, 0);
}
Tessellator.instance.draw();
rh.reset();
}
GL11.glPopMatrix();
if (!blend)
GL11.glDisable(GL11.GL_BLEND);
if (!alpha)
GL11.glDisable(GL11.GL_ALPHA_TEST);
}
use of uk.co.qmunity.lib.client.render.RenderHelper in project BluePower by Qmunity.
the class GateBase method renderItem.
@Override
@SideOnly(Side.CLIENT)
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
if (this instanceof ISilkyRemovable) {
if (this instanceof IAdvancedSilkyRemovable) {
((IAdvancedSilkyRemovable) this).readSilkyData(null, 0, 0, 0, item.hasTagCompound() ? item.getTagCompound().getCompoundTag("tileData") : new NBTTagCompound());
} else {
readFromNBT(item.hasTagCompound() ? item.getTagCompound().getCompoundTag("tileData") : new NBTTagCompound());
}
}
GL11.glPushMatrix();
{
RenderHelper rh = RenderHelper.instance;
rh.reset();
if (type == ItemRenderType.EQUIPPED_FIRST_PERSON) {
GL11.glTranslated(-0.25, 0.75, 0.25);
}
if (type == ItemRenderType.ENTITY && item.getItemFrame() != null) {
GL11.glTranslated(19 / 32D, 8 / 16D, 1);
GL11.glRotated(-90, 0, 0, 1);
GL11.glRotated(90, 0, 1, 0);
}
if (type == ItemRenderType.INVENTORY && BluePower.proxy.isSneakingInGui()) {
GuiScreen gui = Minecraft.getMinecraft().currentScreen;
if (gui != null && gui instanceof GuiContainer) {
GL11.glRotatef(90F, 0.0F, 1.0F, 0.0F);
GL11.glRotatef(-45F, 0.0F, 1.0F, 0.0F);
GL11.glRotatef(-210F, 1.0F, 0.0F, 0.0F);
GL11.glScaled(1.5, 1.5, 1.5);
GL11.glTranslated(-0.5, 0, 0);
GL11.glTranslated(0, -0.5, 0);
GL11.glRotated(-90, 1, 0, 0);
GL11.glTranslated(0, 0.5, 0);
}
}
Tessellator.instance.startDrawingQuads();
if (shouldRenderOnPass(0))
renderStatic(new Vec3i(0, 0, 0), rh, RenderBlocks.getInstance(), 0);
rh.reset();
if (shouldRenderOnPass(1))
renderStatic(new Vec3i(0, 0, 0), rh, RenderBlocks.getInstance(), 1);
rh.reset();
Tessellator.instance.draw();
if (shouldRenderOnPass(0))
renderDynamic(new Vec3d(0, 0, 0), 0, 0);
if (shouldRenderOnPass(1))
renderDynamic(new Vec3d(0, 0, 0), 0, 1);
}
GL11.glPopMatrix();
}
use of uk.co.qmunity.lib.client.render.RenderHelper in project BluePower by Qmunity.
the class PartLamp method renderDynamic.
/**
* @author Koen Beckers (K4Unl), Amadornes
*/
@Override
@SideOnly(Side.CLIENT)
public void renderDynamic(Vec3d translation, double delta, int pass) {
RenderHelper renderer = RenderHelper.instance;
renderer.reset();
switch(getFace().ordinal()) {
case 0:
break;
case 1:
renderer.addTransformation(new Rotation(180, 0, 0, Vec3d.center));
break;
case 2:
renderer.addTransformation(new Rotation(90, 0, 0, Vec3d.center));
break;
case 3:
renderer.addTransformation(new Rotation(-90, 0, 0, Vec3d.center));
break;
case 4:
renderer.addTransformation(new Rotation(0, 0, -90, Vec3d.center));
break;
case 5:
renderer.addTransformation(new Rotation(0, 0, 90, Vec3d.center));
break;
}
renderGlow(pass);
renderer.resetTransformations();
}
Aggregations