use of net.minecraft.client.renderer.BufferBuilder in project MC-Prefab by Brian-Wuest.
the class GuiStructure method drawModalRectWithCustomSizedTexture.
/**
* Draws a textured rectangle Args: x, y, z, width, height, textureWidth, textureHeight
* @param x The X-Axis screen coordinate.
* @param y The Y-Axis screen coordinate.
* @param z The Z-Axis screen coordinate.
* @param width The width of the rectangle.
* @param height The height of the rectangle.
* @param textureWidth The width of the texture.
* @param textureHeight The height of the texture.
*/
public void drawModalRectWithCustomSizedTexture(int x, int y, int z, int width, int height, float textureWidth, float textureHeight) {
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
GlStateManager.enableBlend();
GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0);
float u = 0;
float v = 0;
float f = 1.0F / textureWidth;
float f1 = 1.0F / textureHeight;
Tessellator tessellator = Tessellator.getInstance();
BufferBuilder vertexbuffer = tessellator.getBuffer();
vertexbuffer.begin(7, DefaultVertexFormats.POSITION_TEX);
vertexbuffer.pos(x, y + height, z).tex(u * f, (v + height) * f1).endVertex();
vertexbuffer.pos(x + width, y + height, z).tex((u + width) * f, (v + height) * f1).endVertex();
vertexbuffer.pos(x + width, y, z).tex((u + width) * f, v * f1).endVertex();
vertexbuffer.pos(x, y, z).tex(u * f, v * f1).endVertex();
tessellator.draw();
}
use of net.minecraft.client.renderer.BufferBuilder in project MC-Prefab by Brian-Wuest.
the class GuiTabScreen method drawModalRectWithCustomSizedTexture.
/**
* Draws a textured rectangle Args: x, y, z, width, height, textureWidth, textureHeight
* @param x The X-Axis screen coordinate.
* @param y The Y-Axis screen coordinate.
* @param z The Z-Axis screen coordinate.
* @param width The width of the rectangle.
* @param height The height of the rectangle.
* @param textureWidth The width of the texture.
* @param textureHeight The height of the texture.
*/
public static void drawModalRectWithCustomSizedTexture(int x, int y, int z, int width, int height, float textureWidth, float textureHeight) {
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
GlStateManager.enableBlend();
GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0);
float u = 0;
float v = 0;
float f = 1.0F / textureWidth;
float f1 = 1.0F / textureHeight;
Tessellator tessellator = Tessellator.getInstance();
BufferBuilder vertexbuffer = tessellator.getBuffer();
vertexbuffer.begin(7, DefaultVertexFormats.POSITION_TEX);
vertexbuffer.pos(x, y + height, z).tex(u * f, (v + height) * f1).endVertex();
vertexbuffer.pos(x + width, y + height, z).tex((u + width) * f, (v + height) * f1).endVertex();
vertexbuffer.pos(x + width, y, z).tex((u + width) * f, v * f1).endVertex();
vertexbuffer.pos(x, y, z).tex(u * f, v * f1).endVertex();
tessellator.draw();
}
use of net.minecraft.client.renderer.BufferBuilder in project Ceramics by KnightMiner.
the class RenderUtils method renderFluidCuboid.
/**
* Renders block with offset x/y/z from x1/y1/z1 to x2/y2/z2 inside the block local coordinates, so from 0-1
*/
public static void renderFluidCuboid(FluidStack fluid, BlockPos pos, double x, double y, double z, double x1, double y1, double z1, double x2, double y2, double z2, int color) {
Tessellator tessellator = Tessellator.getInstance();
BufferBuilder renderer = tessellator.getBuffer();
renderer.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK);
mc.renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
// RenderUtil.setColorRGBA(color);
int brightness = mc.world.getCombinedLight(pos, fluid.getFluid().getLuminosity());
pre(x, y, z);
TextureAtlasSprite still = mc.getTextureMapBlocks().getTextureExtry(fluid.getFluid().getStill(fluid).toString());
TextureAtlasSprite flowing = mc.getTextureMapBlocks().getTextureExtry(fluid.getFluid().getFlowing(fluid).toString());
// x/y/z2 - x/y/z1 is because we need the width/height/depth
putTexturedQuad(renderer, still, x1, y1, z1, x2 - x1, y2 - y1, z2 - z1, EnumFacing.DOWN, color, brightness, false);
putTexturedQuad(renderer, flowing, x1, y1, z1, x2 - x1, y2 - y1, z2 - z1, EnumFacing.NORTH, color, brightness, true);
putTexturedQuad(renderer, flowing, x1, y1, z1, x2 - x1, y2 - y1, z2 - z1, EnumFacing.EAST, color, brightness, true);
putTexturedQuad(renderer, flowing, x1, y1, z1, x2 - x1, y2 - y1, z2 - z1, EnumFacing.SOUTH, color, brightness, true);
putTexturedQuad(renderer, flowing, x1, y1, z1, x2 - x1, y2 - y1, z2 - z1, EnumFacing.WEST, color, brightness, true);
putTexturedQuad(renderer, still, x1, y1, z1, x2 - x1, y2 - y1, z2 - z1, EnumFacing.UP, color, brightness, false);
tessellator.draw();
post();
}
use of net.minecraft.client.renderer.BufferBuilder in project Wizardry by TeamWizardry.
the class TableModule method drawWire.
@SuppressWarnings("unused")
public static void drawWire(Vec2d start, Vec2d end, Color primary, Color secondary) {
GlStateManager.pushMatrix();
GlStateManager.enableBlend();
GlStateManager.disableCull();
GlStateManager.blendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
GlStateManager.color(1, 1, 1, 1);
GlStateManager.translate(0, 0, -1);
streak.getTex().bind();
InterpBezier2D bezier = new InterpBezier2D(start, end);
List<Vec2d> list = bezier.list(50);
Vec2d pointerPos = null, behindPointer = null;
float p = 0;
for (int i = 0; i < list.size() - 1; i++) {
float x = (float) (start.length() + ClientTickHandler.getTicks() + ClientTickHandler.getPartialTicks()) / 30f;
if (i == (int) ((x - Math.floor(x)) * 50f)) {
p = i / (list.size() - 1.0f);
}
}
Tessellator tessellator = Tessellator.getInstance();
BufferBuilder vb = tessellator.getBuffer();
vb.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_COLOR);
Vec2d lastPoint = null;
for (int i = 0; i < list.size() - 1; i++) {
Vec2d point = list.get(i);
if (lastPoint == null) {
lastPoint = point;
continue;
}
float dist = (i / (list.size() - 1.0f));
float wire;
if (dist < p) {
float z = Math.abs(dist - p);
wire = 256.0f / 27.0f * (z * z * z - z * z * z * z);
} else {
float z = Math.abs(dist - (p + 1f));
wire = 256.0f / 27.0f * (z * z * z - z * z * z * z);
}
float r = lerp(primary.getRed(), secondary.getRed(), wire) / 255f;
float g = lerp(primary.getGreen(), secondary.getGreen(), wire) / 255f;
float b = lerp(primary.getBlue(), secondary.getBlue(), wire) / 255f;
Vec2d normal = point.sub(lastPoint).normalize();
Vec2d perp = new Vec2d(-normal.getYf(), normal.getXf()).mul((1.0f - 2.0f * Math.abs(dist - 0.5f) + 0.3f));
Vec2d point1 = lastPoint.sub(normal.mul(0.5)).add(perp);
Vec2d point2 = point.add(normal.mul(0.5)).add(perp);
Vec2d point3 = point.add(normal.mul(0.5)).sub(perp);
Vec2d point4 = lastPoint.sub(normal.mul(0.5)).sub(perp);
vb.pos(point1.getXf(), point1.getYf(), 0).tex(0, 0).color(r, g, b, 1f).endVertex();
vb.pos(point2.getXf(), point2.getYf(), 0).tex(0, 1).color(r, g, b, 1f).endVertex();
vb.pos(point3.getXf(), point3.getYf(), 0).tex(1, 0).color(r, g, b, 1f).endVertex();
vb.pos(point4.getXf(), point4.getYf(), 0).tex(1, 1).color(r, g, b, 1f).endVertex();
lastPoint = point;
}
tessellator.draw();
GlStateManager.enableTexture2D();
GlStateManager.popMatrix();
}
use of net.minecraft.client.renderer.BufferBuilder in project Wizardry by TeamWizardry.
the class FireRecipeJEI method drawGradientRect.
protected void drawGradientRect(int left, int top, int right, int bottom) {
GlStateManager.disableTexture2D();
GlStateManager.enableBlend();
GlStateManager.disableAlpha();
GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
Tessellator tessellator = Tessellator.getInstance();
BufferBuilder bufferbuilder = tessellator.getBuffer();
bufferbuilder.begin(7, DefaultVertexFormats.POSITION_COLOR);
bufferbuilder.pos((double) right, (double) top, 0).color(1f, 1f, 1f, .5f).endVertex();
bufferbuilder.pos((double) left, (double) top, 0).color(1f, 1f, 1f, .5f).endVertex();
bufferbuilder.pos((double) left, (double) bottom, 0).color(1f, 1f, 1f, .5f).endVertex();
bufferbuilder.pos((double) right, (double) bottom, 0).color(1f, 1f, 1f, .5f).endVertex();
tessellator.draw();
GlStateManager.disableBlend();
GlStateManager.enableAlpha();
GlStateManager.enableTexture2D();
}
Aggregations