use of net.minecraft.client.renderer.BufferBuilder in project SilentGems by SilentChaos512.
the class GuiToolSouls method renderAPBarForItem.
private static void renderAPBarForItem(ItemStack stack, int xPosition, int yPosition) {
if (!stack.isEmpty()) {
ToolSoul soul = SoulManager.getSoul(stack);
if (soul != null) {
// SilentGems.logHelper.debug(soul);
GlStateManager.disableLighting();
GlStateManager.disableDepth();
GlStateManager.disableTexture2D();
GlStateManager.disableAlpha();
GlStateManager.disableBlend();
Tessellator tessellator = Tessellator.getInstance();
BufferBuilder bufferbuilder = tessellator.getBuffer();
double ap = 1.0 - ((double) soul.getActionPoints() / soul.getMaxActionPoints());
int rgbfordisplay = new Color(0f, 0.75f * (1f - (float) ap), 1f).getColor();
int i = Math.round(13.0F - (float) ap * 13.0F);
int j = rgbfordisplay;
draw(bufferbuilder, xPosition + 2, yPosition + 13, 13, 2, 0, 0, 0, 255);
draw(bufferbuilder, xPosition + 2, yPosition + 13, i, 1, j >> 16 & 255, j >> 8 & 255, j & 255, 255);
GlStateManager.enableBlend();
GlStateManager.enableAlpha();
GlStateManager.enableTexture2D();
GlStateManager.enableLighting();
GlStateManager.enableDepth();
}
// EntityPlayerSP entityplayersp = Minecraft.getMinecraft().player;
// float f3 = entityplayersp == null ? 0.0F
// : entityplayersp.getCooldownTracker().getCooldown(stack.getItem(),
// Minecraft.getMinecraft().getRenderPartialTicks());
//
// if (f3 > 0.0F) {
// GlStateManager.disableLighting();
// GlStateManager.disableDepth();
// GlStateManager.disableTexture2D();
// Tessellator tessellator1 = Tessellator.getInstance();
// BufferBuilder bufferbuilder1 = tessellator1.getBuffer();
// this.draw(bufferbuilder1, xPosition, yPosition + MathHelper.floor(16.0F * (1.0F - f3)), 16,
// MathHelper.ceil(16.0F * f3), 255, 255, 255, 127);
// // GlStateManager.enableTexture2D();
// // GlStateManager.enableLighting();
// // GlStateManager.enableDepth();
// }
}
}
use of net.minecraft.client.renderer.BufferBuilder in project Charset by CharsetMC.
the class ProjectorRenderer method onRender.
@SubscribeEvent
public void onRender(RenderWorldLastEvent event) {
Minecraft.getMinecraft().mcProfiler.startSection("projectors");
GlStateManager.enableBlend();
GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE);
GlStateManager.glBlendEquation(GL14.GL_FUNC_ADD);
GlStateManager.enableTexture2D();
GlStateManager.enableAlpha();
Tessellator tessellator = Tessellator.getInstance();
BufferBuilder worldrenderer = tessellator.getBuffer();
worldrenderer.setTranslation(0, 0, 0);
Entity cameraEntity = Minecraft.getMinecraft().getRenderViewEntity();
Vec3d cameraPos = EntityUtils.interpolate(cameraEntity, event.getPartialTicks());
ICamera camera = new Frustum();
camera.setPosition(cameraPos.x, cameraPos.y, cameraPos.z);
GlStateManager.pushMatrix();
GlStateManager.translate(-cameraPos.x, -cameraPos.y, -cameraPos.z);
for (TileEntity tileEntity : Minecraft.getMinecraft().world.loadedTileEntityList) {
if (tileEntity instanceof TileProjector) {
LaserColor color = LaserColor.NONE;
Orientation orientation = ((TileProjector) tileEntity).getOrientation();
if (CharsetProjector.useLasers) {
for (int d = 0; d < 6; d++) {
LaserColor color2 = ((TileProjector) tileEntity).colors[d];
if (color2 != null && color2 != LaserColor.NONE) {
if (d == orientation.facing.getOpposite().ordinal()) {
// not rendering anything - laser in the way
color = LaserColor.NONE;
break;
} else {
color = color.union(color2);
}
}
}
} else {
color = ((TileProjector) tileEntity).redstoneLevel > 0 ? LaserColor.WHITE : LaserColor.NONE;
}
if (color != LaserColor.NONE) {
ItemStack stack = ((TileProjector) tileEntity).getStack();
IProjectorHandler<ItemStack> handler = CharsetProjector.getHandler(stack);
if (handler == null) {
continue;
}
Surface surface = getSurface(tileEntity.getWorld(), tileEntity.getPos(), orientation, 0.5f, handler.getAspectRatio(stack));
if (surface == null) {
continue;
}
if (!camera.isBoundingBoxInFrustum(new AxisAlignedBB(surface.cornerStart, surface.cornerEnd))) {
continue;
}
surface.r = color.red ? 1.0f : 0.0f;
surface.g = color.green ? 1.0f : 0.0f;
surface.b = color.blue ? 1.0f : 0.0f;
surface.a = 0.5f;
if (!CharsetProjector.useLasers) {
surface.a *= ((TileProjector) tileEntity).redstoneLevel / 15.0f;
}
EnumDyeColor dyeColor = null;
BlockPos inFrontPos = tileEntity.getPos().offset(((TileProjector) tileEntity).getOrientation().facing);
IBlockState state = tileEntity.getWorld().getBlockState(inFrontPos);
if (state.getBlock() instanceof BlockStainedGlass) {
dyeColor = state.getValue(BlockStainedGlass.COLOR);
}
if (dyeColor != null) {
float[] v = dyeColor.getColorComponentValues();
surface.r *= v[0];
surface.g *= v[1];
surface.b *= v[2];
}
surface.restoreGLColor();
handler.render(stack, (IProjector) tileEntity, surface);
}
}
}
GlStateManager.popMatrix();
GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GlStateManager.glBlendEquation(GL14.GL_FUNC_ADD);
GlStateManager.disableBlend();
Minecraft.getMinecraft().mcProfiler.endSection();
}
use of net.minecraft.client.renderer.BufferBuilder in project Charset by CharsetMC.
the class RenderUtils method drawSelectionBoundingBox.
public static void drawSelectionBoundingBox(AxisAlignedBB box, int lineMask) {
EntityPlayer player = Minecraft.getMinecraft().player;
float partialTicks = Minecraft.getMinecraft().getRenderPartialTicks();
Vec3d cameraPos = EntityUtils.interpolate(player, partialTicks);
AxisAlignedBB boundingBox = box.grow(0.002).offset(cameraPos.scale(-1));
GlStateManager.enableBlend();
GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
GlStateManager.color(0.0F, 0.0F, 0.0F, 0.4F);
GL11.glLineWidth(2.0F);
GlStateManager.disableTexture2D();
GlStateManager.depthMask(false);
Tessellator tessellator = Tessellator.getInstance();
BufferBuilder worldrenderer = tessellator.getBuffer();
worldrenderer.begin(GL11.GL_LINES, DefaultVertexFormats.POSITION);
if ((lineMask & /* getSelectionMask(0, 0, 0) */
0x001) != 0) {
drawLine(worldrenderer, tessellator, boundingBox.minX, boundingBox.minY, boundingBox.minZ, boundingBox.maxX, boundingBox.minY, boundingBox.minZ);
}
if ((lineMask & /* getSelectionMask(0, 0, 1) */
0x002) != 0) {
drawLine(worldrenderer, tessellator, boundingBox.minX, boundingBox.minY, boundingBox.maxZ, boundingBox.maxX, boundingBox.minY, boundingBox.maxZ);
}
if ((lineMask & /* getSelectionMask(0, 1, 0) */
0x004) != 0) {
drawLine(worldrenderer, tessellator, boundingBox.minX, boundingBox.minY, boundingBox.minZ, boundingBox.minX, boundingBox.minY, boundingBox.maxZ);
}
if ((lineMask & /* getSelectionMask(0, 1, 1) */
0x008) != 0) {
drawLine(worldrenderer, tessellator, boundingBox.maxX, boundingBox.minY, boundingBox.minZ, boundingBox.maxX, boundingBox.minY, boundingBox.maxZ);
}
if ((lineMask & /* getSelectionMask(1, 0, 0) */
0x010) != 0) {
drawLine(worldrenderer, tessellator, boundingBox.minX, boundingBox.minY, boundingBox.minZ, boundingBox.minX, boundingBox.maxY, boundingBox.minZ);
}
if ((lineMask & /* getSelectionMask(1, 0, 1) */
0x020) != 0) {
drawLine(worldrenderer, tessellator, boundingBox.minX, boundingBox.minY, boundingBox.maxZ, boundingBox.minX, boundingBox.maxY, boundingBox.maxZ);
}
if ((lineMask & /* getSelectionMask(1, 1, 0) */
0x040) != 0) {
drawLine(worldrenderer, tessellator, boundingBox.maxX, boundingBox.minY, boundingBox.minZ, boundingBox.maxX, boundingBox.maxY, boundingBox.minZ);
}
if ((lineMask & /* getSelectionMask(1, 1, 1) */
0x080) != 0) {
drawLine(worldrenderer, tessellator, boundingBox.maxX, boundingBox.minY, boundingBox.maxZ, boundingBox.maxX, boundingBox.maxY, boundingBox.maxZ);
}
if ((lineMask & /* getSelectionMask(2, 0, 0) */
0x100) != 0) {
drawLine(worldrenderer, tessellator, boundingBox.minX, boundingBox.maxY, boundingBox.minZ, boundingBox.maxX, boundingBox.maxY, boundingBox.minZ);
}
if ((lineMask & /* getSelectionMask(2, 0, 1) */
0x200) != 0) {
drawLine(worldrenderer, tessellator, boundingBox.minX, boundingBox.maxY, boundingBox.maxZ, boundingBox.maxX, boundingBox.maxY, boundingBox.maxZ);
}
if ((lineMask & /* getSelectionMask(2, 1, 0) */
0x400) != 0) {
drawLine(worldrenderer, tessellator, boundingBox.minX, boundingBox.maxY, boundingBox.minZ, boundingBox.minX, boundingBox.maxY, boundingBox.maxZ);
}
if ((lineMask & /* getSelectionMask(2, 1, 1) */
0x800) != 0) {
drawLine(worldrenderer, tessellator, boundingBox.maxX, boundingBox.maxY, boundingBox.minZ, boundingBox.maxX, boundingBox.maxY, boundingBox.maxZ);
}
tessellator.draw();
GlStateManager.depthMask(true);
GlStateManager.enableTexture2D();
GlStateManager.disableBlend();
}
use of net.minecraft.client.renderer.BufferBuilder in project Charset by CharsetMC.
the class NotifyProxyClient method renderMessage.
private void renderMessage(ClientMessage m, float partial, float opacity, Vec3d c) {
int width = 0;
String[] lines = m.msgRendered.split("\n");
FontRenderer fr = Minecraft.getMinecraft().fontRenderer;
Tessellator tessellator = Tessellator.getInstance();
BufferBuilder worldrenderer = tessellator.getBuffer();
for (String line : lines) {
width = Math.max(width, fr.getStringWidth(line));
}
width += 2;
int halfWidth = width / 2;
float scaling = 1.6F / 60F;
scaling *= 2F / 3F;
GlStateManager.pushMatrix();
int lineCount = lines.length;
float centeringOffset = 0;
if (m.show_item) {
if (lineCount == 1) {
centeringOffset = 5F;
}
lineCount = Math.max(2, lineCount);
}
Vec3d vec = m.getPosition(partial);
float x = (float) vec.x;
float y = (float) vec.y;
float z = (float) vec.z;
if (m.style.contains(NoticeStyle.SCALE_SIZE)) {
double dx = x - c.x;
double dy = y - c.y;
double dz = z - c.z;
double dist = Math.sqrt(dx * dx + dy * dy + dz * dz);
scaling *= Math.sqrt(dist);
}
NotificationCoord co = m.asCoord();
if (co != null && !m.position_important) {
BlockPos pos = co.getPos();
IBlockState bs = co.getWorld().getBlockState(pos);
AxisAlignedBB bb = bs.getCollisionBoundingBox(co.getWorld(), pos);
if (bb != null) {
y = (float) Math.max(y, pos.getY() + bb.maxY);
} else {
y = (float) Math.max(y, pos.getY() + 0.5f);
}
}
GlStateManager.translate(x + 0.5F, y, z + 0.5F);
Minecraft mc = Minecraft.getMinecraft();
float pvx = mc.getRenderManager().playerViewX;
float pvy = -mc.getRenderManager().playerViewY;
if (mc.gameSettings.thirdPersonView == 2) {
pvx = -pvx;
}
GlStateManager.rotate(pvy, 0.0F, 1.0F, 0.0F);
GlStateManager.rotate(pvx, 1.0F, 0.0F, 0.0F);
GlStateManager.scale(-scaling, -scaling, scaling);
GlStateManager.translate(0, -10 * lineCount, 0);
{
int lineHeight = (lineCount - 1) * 10;
double item_add = 0;
if (m.show_item) {
item_add += 24;
}
float col = 0.0F;
GlStateManager.disableTexture2D();
GlStateManager.color(col, col, col, Math.min(opacity, 0.2F));
double Z = 0.001D;
// TODO: Use 2 tessellator + 2 draw calls to do all notice rendering
worldrenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION);
worldrenderer.pos(-halfWidth - 1, -1, Z).endVertex();
worldrenderer.pos(-halfWidth - 1, 8 + lineHeight, Z).endVertex();
worldrenderer.pos(halfWidth + 1 + item_add, 8 + lineHeight, Z).endVertex();
worldrenderer.pos(halfWidth + 1 + item_add, -1, Z).endVertex();
tessellator.draw();
GlStateManager.enableTexture2D();
}
{
int i = 0;
int B = (int) (0xFF * Math.min(1, 0.5F + opacity));
int color = (B << 16) + (B << 8) + B + ((int) (0xFF * opacity) << 24);
GlStateManager.translate(0, centeringOffset, 0);
for (String line : lines) {
fr.drawString(line, -fr.getStringWidth(line) / 2, 10 * i, color);
i++;
}
}
{
if (m.show_item) {
// TODO: Add transparency support
GlStateManager.translate(0, -centeringOffset, 0);
GlStateManager.translate((float) (halfWidth + 4), -lineCount / 2, 0);
// Undoes the effects of setupGuiTransform
renderItem.zLevel -= 100;
renderItem.renderItemIntoGUI(m.item, 0, 0);
renderItem.zLevel += 100;
}
}
GlStateManager.popMatrix();
}
use of net.minecraft.client.renderer.BufferBuilder in project Charset by CharsetMC.
the class DualTileEntitySpecialRenderer method renderTileEntityFastFromSlow.
protected void renderTileEntityFastFromSlow(T part, double x, double y, double z, float partialTicks, int destroyStage, float todo_figure_me_out) {
Tessellator tessellator = Tessellator.getInstance();
BufferBuilder builder = tessellator.getBuffer();
this.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
RenderHelper.disableStandardItemLighting();
GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GlStateManager.enableBlend();
GlStateManager.disableCull();
if (Minecraft.isAmbientOcclusionEnabled()) {
GlStateManager.shadeModel(GL11.GL_SMOOTH);
} else {
GlStateManager.shadeModel(GL11.GL_FLAT);
}
builder.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK);
renderTileEntityFast(part, x, y, z, partialTicks, destroyStage, todo_figure_me_out, builder);
builder.setTranslation(0, 0, 0);
tessellator.draw();
RenderHelper.enableStandardItemLighting();
}
Aggregations