/** * Draws a sprite from assets/textures/gui/container/stats_icons.png */ private void drawSprite(int p_146527_1_, int p_146527_2_, int p_146527_3_, int p_146527_4_) { GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); this.mc.getTextureManager().bindTexture(statIcons); float f = 0.0078125F; float f1 = 0.0078125F; int i = 18; int j = 18; Tessellator tessellator = Tessellator.getInstance(); WorldRenderer worldrenderer = tessellator.getWorldRenderer(); worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX); worldrenderer.pos((double)(p_146527_1_ + 0), (double)(p_146527_2_ + 18), (double)this.zLevel).tex((double)((float)(p_146527_3_ + 0) * 0.0078125F), (double)((float)(p_146527_4_ + 18) * 0.0078125F)).endVertex(); worldrenderer.pos((double)(p_146527_1_ + 18), (double)(p_146527_2_ + 18), (double)this.zLevel).tex((double)((float)(p_146527_3_ + 18) * 0.0078125F), (double)((float)(p_146527_4_ + 18) * 0.0078125F)).endVertex(); worldrenderer.pos((double)(p_146527_1_ + 18), (double)(p_146527_2_ + 0), (double)this.zLevel).tex((double)((float)(p_146527_3_ + 18) * 0.0078125F), (double)((float)(p_146527_4_ + 0) * 0.0078125F)).endVertex(); worldrenderer.pos((double)(p_146527_1_ + 0), (double)(p_146527_2_ + 0), (double)this.zLevel).tex((double)((float)(p_146527_3_ + 0) * 0.0078125F), (double)((float)(p_146527_4_ + 0) * 0.0078125F)).endVertex(); tessellator.draw(); }
public void renderPathLine(float p_190067_1_, Path p_190067_2_) { Tessellator tessellator = Tessellator.getInstance(); VertexBuffer vertexbuffer = tessellator.getBuffer(); vertexbuffer.begin(3, DefaultVertexFormats.POSITION_COLOR); for (int i = 0; i < p_190067_2_.getCurrentPathLength(); ++i) { PathPoint pathpoint = p_190067_2_.getPathPointFromIndex(i); if (this.addDistanceToPlayer(pathpoint) <= 40.0F) { float f = (float)i / (float)p_190067_2_.getCurrentPathLength() * 0.33F; int j = i == 0 ? 0 : MathHelper.hsvToRGB(f, 0.9F, 0.9F); int k = j >> 16 & 255; int l = j >> 8 & 255; int i1 = j & 255; vertexbuffer.pos((double)pathpoint.xCoord - this.xo + 0.5D, (double)pathpoint.yCoord - this.yo + 0.5D, (double)pathpoint.zCoord - this.zo + 0.5D).color(k, l, i1, 255).endVertex(); } } tessellator.draw(); }
private void blitSlotIcon(int p_148171_1_, int p_148171_2_, int p_148171_3_, int p_148171_4_) { GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); this.mc.getTextureManager().bindTexture(Gui.STAT_ICONS); float f = 0.0078125F; float f1 = 0.0078125F; int i = 18; int j = 18; Tessellator tessellator = Tessellator.getInstance(); VertexBuffer vertexbuffer = tessellator.getBuffer(); vertexbuffer.begin(7, DefaultVertexFormats.POSITION_TEX); vertexbuffer.pos((double)(p_148171_1_ + 0), (double)(p_148171_2_ + 18), (double)GuiFlatPresets.this.zLevel).tex((double)((float)(p_148171_3_ + 0) * 0.0078125F), (double)((float)(p_148171_4_ + 18) * 0.0078125F)).endVertex(); vertexbuffer.pos((double)(p_148171_1_ + 18), (double)(p_148171_2_ + 18), (double)GuiFlatPresets.this.zLevel).tex((double)((float)(p_148171_3_ + 18) * 0.0078125F), (double)((float)(p_148171_4_ + 18) * 0.0078125F)).endVertex(); vertexbuffer.pos((double)(p_148171_1_ + 18), (double)(p_148171_2_ + 0), (double)GuiFlatPresets.this.zLevel).tex((double)((float)(p_148171_3_ + 18) * 0.0078125F), (double)((float)(p_148171_4_ + 0) * 0.0078125F)).endVertex(); vertexbuffer.pos((double)(p_148171_1_ + 0), (double)(p_148171_2_ + 0), (double)GuiFlatPresets.this.zLevel).tex((double)((float)(p_148171_3_ + 0) * 0.0078125F), (double)((float)(p_148171_4_ + 0) * 0.0078125F)).endVertex(); tessellator.draw(); }
@Override public void render() { FMLClientHandler.instance().getClient().getTextureManager().bindTexture(getTexture()); int width = getWidth() + (getParameters() != null && getParameters().length > 0 ? 10 : 0); int height = getHeight() + (hasStepOutput() ? 10 : 0); Pair<Double, Double> maxUV = getMaxUV(); double u = maxUV.getLeft(); double v = maxUV.getRight(); BufferBuilder wr = Tessellator.getInstance().getBuffer(); wr.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX); wr.pos(0, 0, 0).tex(0, 0).endVertex(); wr.pos(0, height, 0).tex(0, v).endVertex(); wr.pos(width, height, 0).tex(u, v).endVertex(); wr.pos(width, 0, 0).tex(u, 0).endVertex(); Tessellator.getInstance().draw(); }
private void func_148224_c(int p_148224_1_, int p_148224_2_, int p_148224_3_, int p_148224_4_) { GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); this.mc.getTextureManager().bindTexture(Gui.statIcons); float f = 0.0078125F; float f1 = 0.0078125F; int i = 18; int j = 18; Tessellator tessellator = Tessellator.getInstance(); WorldRenderer worldrenderer = tessellator.getWorldRenderer(); worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX); worldrenderer.pos((double)(p_148224_1_ + 0), (double)(p_148224_2_ + 18), (double)GuiCreateFlatWorld.this.zLevel).tex((double)((float)(p_148224_3_ + 0) * 0.0078125F), (double)((float)(p_148224_4_ + 18) * 0.0078125F)).endVertex(); worldrenderer.pos((double)(p_148224_1_ + 18), (double)(p_148224_2_ + 18), (double)GuiCreateFlatWorld.this.zLevel).tex((double)((float)(p_148224_3_ + 18) * 0.0078125F), (double)((float)(p_148224_4_ + 18) * 0.0078125F)).endVertex(); worldrenderer.pos((double)(p_148224_1_ + 18), (double)(p_148224_2_ + 0), (double)GuiCreateFlatWorld.this.zLevel).tex((double)((float)(p_148224_3_ + 18) * 0.0078125F), (double)((float)(p_148224_4_ + 0) * 0.0078125F)).endVertex(); worldrenderer.pos((double)(p_148224_1_ + 0), (double)(p_148224_2_ + 0), (double)GuiCreateFlatWorld.this.zLevel).tex((double)((float)(p_148224_3_ + 0) * 0.0078125F), (double)((float)(p_148224_4_ + 0) * 0.0078125F)).endVertex(); tessellator.draw(); }
/** * Draws the background (i is always 0 as of 1.2.2) */ public void drawBackground(int tint) { GlStateManager.disableLighting(); GlStateManager.disableFog(); Tessellator tessellator = Tessellator.getInstance(); WorldRenderer worldrenderer = tessellator.getWorldRenderer(); this.mc.getTextureManager().bindTexture(optionsBackground); GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); float f = 32.0F; worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR); worldrenderer.pos(0.0D, (double)this.height, 0.0D).tex(0.0D, (double)((float)this.height / 32.0F + (float)tint)).color(64, 64, 64, 255).endVertex(); worldrenderer.pos((double)this.width, (double)this.height, 0.0D).tex((double)((float)this.width / 32.0F), (double)((float)this.height / 32.0F + (float)tint)).color(64, 64, 64, 255).endVertex(); worldrenderer.pos((double)this.width, 0.0D, 0.0D).tex((double)((float)this.width / 32.0F), (double)tint).color(64, 64, 64, 255).endVertex(); worldrenderer.pos(0.0D, 0.0D, 0.0D).tex(0.0D, (double)tint).color(64, 64, 64, 255).endVertex(); tessellator.draw(); }
public void drawTexturedModalRectZ(final float i, final float y, final int k, final int i1, final int j1, final int k1, final float zLevel) { float f = 0.015625F; float f1 = 0.03125F; Tessellator tesselator = Tessellator.getInstance(); VertexBuffer vertexbuffer = tesselator.getBuffer(); vertexbuffer.begin(7, DefaultVertexFormats.POSITION_TEX); /* tesselator.getWorldRenderer().addVertexWithUV(i + 0, y + k1, zLevel, (k + 0) * f, (i1 + k1) * f1); tesselator.getWorldRenderer().addVertexWithUV(i + j1, y + k1, zLevel, (k + j1) * f, (i1 + k1) * f1); tesselator.getWorldRenderer().addVertexWithUV(i + j1, y + 0, zLevel, (k + j1) * f, (i1 + 0) * f1); tesselator.getWorldRenderer().addVertexWithUV(i + 0, y + 0, zLevel, (k + 0) * f, (i1 + 0) * f1); */ vertexbuffer.pos(i + 0, y + k1, zLevel); vertexbuffer.pos(i + j1, y + k1, zLevel); vertexbuffer.pos(i + j1, y + 0, zLevel); vertexbuffer.pos(i + 0, y + 0, zLevel); tesselator.draw(); }
/** * Draws a sprite from assets/textures/gui/container/stats_icons.png */ private void drawSprite(int p_146527_1_, int p_146527_2_, int p_146527_3_, int p_146527_4_) { GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); this.mc.getTextureManager().bindTexture(STAT_ICONS); float f = 0.0078125F; float f1 = 0.0078125F; int i = 18; int j = 18; Tessellator tessellator = Tessellator.getInstance(); VertexBuffer vertexbuffer = tessellator.getBuffer(); vertexbuffer.begin(7, DefaultVertexFormats.POSITION_TEX); vertexbuffer.pos((double)(p_146527_1_ + 0), (double)(p_146527_2_ + 18), (double)this.zLevel).tex((double)((float)(p_146527_3_ + 0) * 0.0078125F), (double)((float)(p_146527_4_ + 18) * 0.0078125F)).endVertex(); vertexbuffer.pos((double)(p_146527_1_ + 18), (double)(p_146527_2_ + 18), (double)this.zLevel).tex((double)((float)(p_146527_3_ + 18) * 0.0078125F), (double)((float)(p_146527_4_ + 18) * 0.0078125F)).endVertex(); vertexbuffer.pos((double)(p_146527_1_ + 18), (double)(p_146527_2_ + 0), (double)this.zLevel).tex((double)((float)(p_146527_3_ + 18) * 0.0078125F), (double)((float)(p_146527_4_ + 0) * 0.0078125F)).endVertex(); vertexbuffer.pos((double)(p_146527_1_ + 0), (double)(p_146527_2_ + 0), (double)this.zLevel).tex((double)((float)(p_146527_3_ + 0) * 0.0078125F), (double)((float)(p_146527_4_ + 0) * 0.0078125F)).endVertex(); tessellator.draw(); }
public RenderChunk(World worldIn, RenderGlobal renderGlobalIn, BlockPos blockPosIn, int indexIn) { this.world = worldIn; this.renderGlobal = renderGlobalIn; this.index = indexIn; if (!blockPosIn.equals(this.getPosition())) { this.setPosition(blockPosIn); } if (OpenGlHelper.useVbo()) { for (int i = 0; i < EnumWorldBlockLayer.values().length; ++i) { this.vertexBuffers[i] = new VertexBuffer(DefaultVertexFormats.BLOCK); } } }
public static void drawLine(double x, double y, double x2, double y2, float red, float green, float blue, float lineWidth, float fadeSpeed) { int count = FMLClientHandler.instance().getClient().player.ticksExisted; float alpha = fadeSpeed + MathHelper.sin((float) (count + x)) * 0.3F + 0.3F; Tessellator tess = Tessellator.getInstance(); VertexBuffer buff = tess.getBuffer(); GL11.glPushMatrix(); GL11.glLineWidth(lineWidth); GL11.glDisable(3553); GL11.glBlendFunc(770, 771); buff.begin(3, DefaultVertexFormats.POSITION_COLOR); buff.pos(x, y, 0).color(red, green, blue, alpha).endVertex(); buff.pos(x2, y2, 0).color(red, green, blue, alpha).endVertex(); tess.draw(); GL11.glBlendFunc(770, 771); GL11.glDisable(32826); GL11.glDisable(3042); GL11.glEnable(3553); GL11.glPopMatrix(); }
private void func_148171_c(int p_148171_1_, int p_148171_2_, int p_148171_3_, int p_148171_4_) { GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); this.mc.getTextureManager().bindTexture(Gui.statIcons); float f = 0.0078125F; float f1 = 0.0078125F; int i = 18; int j = 18; Tessellator tessellator = Tessellator.getInstance(); WorldRenderer worldrenderer = tessellator.getWorldRenderer(); worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX); worldrenderer.pos((double)(p_148171_1_ + 0), (double)(p_148171_2_ + 18), (double)GuiFlatPresets.this.zLevel).tex((double)((float)(p_148171_3_ + 0) * 0.0078125F), (double)((float)(p_148171_4_ + 18) * 0.0078125F)).endVertex(); worldrenderer.pos((double)(p_148171_1_ + 18), (double)(p_148171_2_ + 18), (double)GuiFlatPresets.this.zLevel).tex((double)((float)(p_148171_3_ + 18) * 0.0078125F), (double)((float)(p_148171_4_ + 18) * 0.0078125F)).endVertex(); worldrenderer.pos((double)(p_148171_1_ + 18), (double)(p_148171_2_ + 0), (double)GuiFlatPresets.this.zLevel).tex((double)((float)(p_148171_3_ + 18) * 0.0078125F), (double)((float)(p_148171_4_ + 0) * 0.0078125F)).endVertex(); worldrenderer.pos((double)(p_148171_1_ + 0), (double)(p_148171_2_ + 0), (double)GuiFlatPresets.this.zLevel).tex((double)((float)(p_148171_3_ + 0) * 0.0078125F), (double)((float)(p_148171_4_ + 0) * 0.0078125F)).endVertex(); tessellator.draw(); }
public static void drawOutlinedRect(int x, int y, int w, int h, int color, float width) { float r = (float)(color >> 16 & 255) / 255.0F; float g = (float)(color >> 8 & 255) / 255.0F; float b = (float)(color & 255) / 255.0F; float a = (float)(color >> 24 & 255) / 255.0F; Tessellator tessellator = Tessellator.getInstance(); BufferBuilder BufferBuilder = tessellator.getBuffer(); GlStateManager.enableBlend(); GlStateManager.disableTexture2D(); GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO); GlStateManager.color(r, g, b, a); GL11.glLineWidth(width); BufferBuilder.begin(GL11.GL_LINE_LOOP, DefaultVertexFormats.POSITION); BufferBuilder.pos((double)x, (double)y, 0.0D).endVertex(); BufferBuilder.pos((double)x, (double)y + h, 0.0D).endVertex(); BufferBuilder.pos((double)x + w, (double)y + h, 0.0D).endVertex(); BufferBuilder.pos((double)x + w, (double)y, 0.0D).endVertex(); tessellator.draw(); GlStateManager.enableTexture2D(); GlStateManager.disableBlend(); }
@Override public void loadTexture(IResourceManager resourceManager) throws IOException { TextureUtil.uploadTextureImageAllocate(this.getGlTextureId(), image, false, false); ImmutableList.Builder<BakedQuad> builder = ImmutableList.builder(); tasi = new TextureAtlasSpriteBufferedImage(this.rl, this.image); tasi.load(Minecraft.getMinecraft().getResourceManager(), rl); builder.addAll(ItemLayerModel.getQuadsForSprite(0, tasi, DefaultVertexFormats.ITEM, Optional.empty())); quads = builder.build(); }
public static void drawTexturedModalRect(int x, int y, int textureX, int textureY, int width, int height, int totw, int toth) { float f = 1.0f/totw; float f1 = 1.0f/toth; double zLevel = 50; Tessellator tessellator = Tessellator.getInstance(); VertexBuffer vertexbuffer = tessellator.getBuffer(); vertexbuffer.begin(7, DefaultVertexFormats.POSITION_TEX); vertexbuffer.pos((x + 0), (y + height), zLevel).tex(((textureX + 0) * f), ((textureY + height) * f1)).endVertex(); vertexbuffer.pos((x + width), (y + height), zLevel).tex(((textureX + width) * f), ((textureY + height) * f1)).endVertex(); vertexbuffer.pos((x + width), (y + 0), zLevel).tex(((textureX + width) * f), ((textureY + 0) * f1)).endVertex(); vertexbuffer.pos((x + 0), (y + 0), zLevel).tex(((textureX + 0) * f), ((textureY + 0) * f1)).endVertex(); tessellator.draw(); }
public static void drawBoundingBox(double minX, double minY, double minZ, double maxX, double maxY, double maxZ, float red, float green, float blue, float alpha) { Tessellator tessellator = Tessellator.getInstance(); VertexBuffer vertexbuffer = tessellator.getBuffer(); vertexbuffer.begin(3, DefaultVertexFormats.POSITION_COLOR); drawBoundingBox(vertexbuffer, minX, minY, minZ, maxX, maxY, maxZ, red, green, blue, alpha); tessellator.draw(); }
/** * Draws a scaled, textured, tiled modal rect at z = 0. This method isn't used anywhere in vanilla code. */ public static void drawScaledCustomSizeModalRect(int x, int y, float u, float v, int uWidth, int vHeight, int width, int height, float tileWidth, float tileHeight) { float f = 1.0F / tileWidth; float f1 = 1.0F / tileHeight; Tessellator tessellator = Tessellator.getInstance(); WorldRenderer worldrenderer = tessellator.getWorldRenderer(); worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX); worldrenderer.pos((double)x, (double)(y + height), 0.0D).tex((double)(u * f), (double)((v + (float)vHeight) * f1)).endVertex(); worldrenderer.pos((double)(x + width), (double)(y + height), 0.0D).tex((double)((u + (float)uWidth) * f), (double)((v + (float)vHeight) * f1)).endVertex(); worldrenderer.pos((double)(x + width), (double)y, 0.0D).tex((double)((u + (float)uWidth) * f), (double)(v * f1)).endVertex(); worldrenderer.pos((double)x, (double)y, 0.0D).tex((double)(u * f), (double)(v * f1)).endVertex(); tessellator.draw(); }
public static void drawModalRectWithCustomSizedTexture(int x, int y, float u, float v, int width, int height, float textureWidth, float textureHeight, float z) { float f = 1.0F / textureWidth; float f1 = 1.0F / textureHeight; Tessellator tessellator = Tessellator.getInstance(); WorldRenderer worldrenderer = tessellator.getWorldRenderer(); worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX); worldrenderer.pos((double)x, (double)(y + height), z).tex((double)(u * f), (double)((v + (float)height) * f1)).endVertex(); worldrenderer.pos((double)(x + width), (double)(y + height), z).tex((double)((u + (float)width) * f), (double)((v + (float)height) * f1)).endVertex(); worldrenderer.pos((double)(x + width), (double)y, z).tex((double)((u + (float)width) * f), (double)(v * f1)).endVertex(); worldrenderer.pos((double)x, (double)y, z).tex((double)(u * f), (double)(v * f1)).endVertex(); tessellator.draw(); }
/** * Draws the current selection and a vertical line cursor in the text box. */ private void drawCursorVertical(int startX, int startY, int endX, int endY) { if(startX < endX) { int i = startX; startX = endX; endX = i; } if(startY < endY) { int j = startY; startY = endY; endY = j; } if(endX > xPosition + width) endX = xPosition + width; if(startX > xPosition + width) startX = xPosition + width; Tessellator tessellator = Tessellator.getInstance(); BufferBuilder bufferbuilder = tessellator.getBuffer(); GlStateManager.color(0.0F, 0.0F, 255.0F, 255.0F); GlStateManager.disableTexture2D(); GlStateManager.enableColorLogic(); GlStateManager.colorLogicOp(GlStateManager.LogicOp.OR_REVERSE); bufferbuilder.begin(7, DefaultVertexFormats.POSITION); bufferbuilder.pos(startX, endY, 0.0D).endVertex(); bufferbuilder.pos(endX, endY, 0.0D).endVertex(); bufferbuilder.pos(endX, startY, 0.0D).endVertex(); bufferbuilder.pos(startX, startY, 0.0D).endVertex(); tessellator.draw(); GlStateManager.disableColorLogic(); GlStateManager.enableTexture2D(); }
private static void renderOffsetAABB(AxisAlignedBB aabb, double x, double y, double z) { BufferBuilder wr = Tessellator.getInstance().getBuffer(); wr.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_NORMAL); wr.setTranslation(x, y, z); wr.pos(aabb.minX, aabb.maxY, aabb.minZ).normal(0, 0, -1).endVertex(); wr.pos(aabb.maxX, aabb.maxY, aabb.minZ).normal(0, 0, -1).endVertex(); wr.pos(aabb.maxX, aabb.minY, aabb.minZ).normal(0, 0, -1).endVertex(); wr.pos(aabb.minX, aabb.minY, aabb.minZ).normal(0, 0, -1).endVertex(); wr.pos(aabb.minX, aabb.minY, aabb.maxZ).normal(0, 0, 1).endVertex(); wr.pos(aabb.maxX, aabb.minY, aabb.maxZ).normal(0, 0, 1).endVertex(); wr.pos(aabb.maxX, aabb.maxY, aabb.maxZ).normal(0, 0, 1).endVertex(); wr.pos(aabb.minX, aabb.maxY, aabb.maxZ).normal(0, 0, 1).endVertex(); wr.pos(aabb.minX, aabb.minY, aabb.minZ).normal(0, -1, 0).endVertex(); wr.pos(aabb.maxX, aabb.minY, aabb.minZ).normal(0, -1, 0).endVertex(); wr.pos(aabb.maxX, aabb.minY, aabb.maxZ).normal(0, -1, 0).endVertex(); wr.pos(aabb.minX, aabb.minY, aabb.maxZ).normal(0, -1, 0).endVertex(); wr.pos(aabb.minX, aabb.maxY, aabb.maxZ).normal(0, 1, 0).endVertex(); wr.pos(aabb.maxX, aabb.maxY, aabb.maxZ).normal(0, 1, 0).endVertex(); wr.pos(aabb.maxX, aabb.maxY, aabb.minZ).normal(0, 1, 0).endVertex(); wr.pos(aabb.minX, aabb.maxY, aabb.minZ).normal(0, 1, 0).endVertex(); wr.pos(aabb.minX, aabb.minY, aabb.maxZ).normal(-1, 0, 0).endVertex(); wr.pos(aabb.minX, aabb.maxY, aabb.maxZ).normal(-1, 0, 0).endVertex(); wr.pos(aabb.minX, aabb.maxY, aabb.minZ).normal(-1, 0, 0).endVertex(); wr.pos(aabb.minX, aabb.minY, aabb.minZ).normal(-1, 0, 0).endVertex(); wr.pos(aabb.maxX, aabb.minY, aabb.minZ).normal(1, 0, 0).endVertex(); wr.pos(aabb.maxX, aabb.maxY, aabb.minZ).normal(1, 0, 0).endVertex(); wr.pos(aabb.maxX, aabb.maxY, aabb.maxZ).normal(1, 0, 0).endVertex(); wr.pos(aabb.maxX, aabb.minY, aabb.maxZ).normal(1, 0, 0).endVertex(); wr.setTranslation(0.0D, 0.0D, 0.0D); Tessellator.getInstance().draw(); }
/** * Rotate and blurs the skybox view in the main menu */ private void rotateAndBlurSkybox(float p_73968_1_) { this.mc.getTextureManager().bindTexture(this.backgroundTexture); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR); GL11.glCopyTexSubImage2D(GL11.GL_TEXTURE_2D, 0, 0, 0, 0, 0, 256, 256); GlStateManager.enableBlend(); GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); GlStateManager.colorMask(true, true, true, false); Tessellator tessellator = Tessellator.getInstance(); WorldRenderer worldrenderer = tessellator.getWorldRenderer(); worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR); GlStateManager.disableAlpha(); int i = 3; for (int j = 0; j < i; ++j) { float f = 1.0F / (float)(j + 1); int k = this.width; int l = this.height; float f1 = (float)(j - i / 2) / 256.0F; worldrenderer.pos((double)k, (double)l, (double)this.zLevel).tex((double)(0.0F + f1), 1.0D).color(1.0F, 1.0F, 1.0F, f).endVertex(); worldrenderer.pos((double)k, 0.0D, (double)this.zLevel).tex((double)(1.0F + f1), 1.0D).color(1.0F, 1.0F, 1.0F, f).endVertex(); worldrenderer.pos(0.0D, 0.0D, (double)this.zLevel).tex((double)(1.0F + f1), 0.0D).color(1.0F, 1.0F, 1.0F, f).endVertex(); worldrenderer.pos(0.0D, (double)l, (double)this.zLevel).tex((double)(0.0F + f1), 0.0D).color(1.0F, 1.0F, 1.0F, f).endVertex(); } tessellator.draw(); GlStateManager.enableAlpha(); GlStateManager.colorMask(true, true, true, true); }
/** * Draw with the WorldRenderer */ private void draw(VertexBuffer renderer, int x, int y, int width, int height, int red, int green, int blue, int alpha) { renderer.begin(7, DefaultVertexFormats.POSITION_COLOR); renderer.pos((double)(x + 0), (double)(y + 0), 0.0D).color(red, green, blue, alpha).endVertex(); renderer.pos((double)(x + 0), (double)(y + height), 0.0D).color(red, green, blue, alpha).endVertex(); renderer.pos((double)(x + width), (double)(y + height), 0.0D).color(red, green, blue, alpha).endVertex(); renderer.pos((double)(x + width), (double)(y + 0), 0.0D).color(red, green, blue, alpha).endVertex(); Tessellator.getInstance().draw(); }
private static void drawRectWithFullTexture(double x, double y, int width, int height) { Tessellator tessellator = Tessellator.getInstance(); BufferBuilder buffer = tessellator.getBuffer(); buffer.begin(7, DefaultVertexFormats.POSITION_TEX); buffer.pos(x, y + height, 0).tex(0, 1).endVertex(); buffer.pos(x + width, y + height, 0).tex(1, 1).endVertex(); buffer.pos(x + width, y, 0).tex(1, 0).endVertex(); buffer.pos(x, y, 0).tex(0, 0).endVertex(); tessellator.draw(); }
@Override @SideOnly(Side.CLIENT) public void render() { Minecraft.getMinecraft().getTextureManager().bindTexture(location); GL11.glBindTexture(GL11.GL_TEXTURE_2D, Minecraft.getMinecraft().getTextureManager().getTexture(location).getGlTextureId()); final Tessellator t = Tessellator.getInstance(); final VertexBuffer r = t.getBuffer(); r.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX); r.pos(0, 16, 0).tex(0, 1).endVertex(); r.pos(16, 16, 0).tex(1, 1).endVertex(); r.pos(16, 0, 0).tex(1, 0).endVertex(); r.pos(0, 0, 0).tex(0, 0).endVertex(); t.draw(); }
private void func_180474_b(float p_180474_1_, ScaledResolution p_180474_2_) { if (p_180474_1_ < 1.0F) { p_180474_1_ = p_180474_1_ * p_180474_1_; p_180474_1_ = p_180474_1_ * p_180474_1_; p_180474_1_ = p_180474_1_ * 0.8F + 0.2F; } GlStateManager.disableAlpha(); GlStateManager.disableDepth(); GlStateManager.depthMask(false); GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); GlStateManager.color(1.0F, 1.0F, 1.0F, p_180474_1_); this.mc.getTextureManager().bindTexture(TextureMap.locationBlocksTexture); TextureAtlasSprite textureatlassprite = this.mc.getBlockRendererDispatcher().getBlockModelShapes().getTexture(Blocks.portal.getDefaultState()); float f = textureatlassprite.getMinU(); float f1 = textureatlassprite.getMinV(); float f2 = textureatlassprite.getMaxU(); float f3 = textureatlassprite.getMaxV(); Tessellator tessellator = Tessellator.getInstance(); WorldRenderer worldrenderer = tessellator.getWorldRenderer(); worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX); worldrenderer.pos(0.0D, (double)p_180474_2_.getScaledHeight(), -90.0D).tex((double)f, (double)f3).endVertex(); worldrenderer.pos((double)p_180474_2_.getScaledWidth(), (double)p_180474_2_.getScaledHeight(), -90.0D).tex((double)f2, (double)f3).endVertex(); worldrenderer.pos((double)p_180474_2_.getScaledWidth(), 0.0D, -90.0D).tex((double)f2, (double)f1).endVertex(); worldrenderer.pos(0.0D, 0.0D, -90.0D).tex((double)f, (double)f1).endVertex(); tessellator.draw(); GlStateManager.depthMask(true); GlStateManager.enableDepth(); GlStateManager.enableAlpha(); GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); }
/** * Utility method for rendering an atlas texture as the front-side overlay * over a specified horizontal area. * * @param texture the atlas texture to use to render the overlay. * @param u0 the lower end of the vertical area to render at. * @param u1 the upper end of the vertical area to render at. */ public void renderOverlayFromAtlas(final ResourceLocation texture, final float u0, final float u1) { Minecraft.getMinecraft().getTextureManager().bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); final TextureAtlasSprite icon = Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite(texture.toString()); final Tessellator t = Tessellator.getInstance(); final VertexBuffer r = t.getBuffer(); r.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX); r.pos(u0, v1, 0).tex(icon.getInterpolatedU(u0 * 16), icon.getInterpolatedV(v1 * 16)).endVertex(); r.pos(u1, v1, 0).tex(icon.getInterpolatedU(u1 * 16), icon.getInterpolatedV(v1 * 16)).endVertex(); r.pos(u1, v0, 0).tex(icon.getInterpolatedU(u1 * 16), icon.getInterpolatedV(v0 * 16)).endVertex(); r.pos(u0, v0, 0).tex(icon.getInterpolatedU(u0 * 16), icon.getInterpolatedV(v0 * 16)).endVertex(); t.draw(); }
/** * Draw this primitve. This is typically called only once as the generated drawing instructions are saved by the * renderer and reused later. */ public void draw(WorldRenderer renderer, float scale) { Vec3 vec3 = this.vertexPositions[1].vector3D.subtractReverse(this.vertexPositions[0].vector3D); Vec3 vec31 = this.vertexPositions[1].vector3D.subtractReverse(this.vertexPositions[2].vector3D); Vec3 vec32 = vec31.crossProduct(vec3).normalize(); float f = (float)vec32.xCoord; float f1 = (float)vec32.yCoord; float f2 = (float)vec32.zCoord; if (this.invertNormal) { f = -f; f1 = -f1; f2 = -f2; } if (Config.isShaders()) { renderer.begin(7, SVertexFormat.defVertexFormatTextured); } else { renderer.begin(7, DefaultVertexFormats.OLDMODEL_POSITION_TEX_NORMAL); } for (int i = 0; i < 4; ++i) { PositionTextureVertex positiontexturevertex = this.vertexPositions[i]; renderer.pos(positiontexturevertex.vector3D.xCoord * (double)scale, positiontexturevertex.vector3D.yCoord * (double)scale, positiontexturevertex.vector3D.zCoord * (double)scale).tex((double)positiontexturevertex.texturePositionX, (double)positiontexturevertex.texturePositionY).normal(f, f1, f2).endVertex(); } Tessellator.getInstance().draw(); }
/** * Draw this primitve. This is typically called only once as the generated drawing instructions are saved by the * renderer and reused later. */ public void draw(WorldRenderer renderer, float scale) { Vec3 vec3 = this.vertexPositions[1].vector3D.subtractReverse(this.vertexPositions[0].vector3D); Vec3 vec31 = this.vertexPositions[1].vector3D.subtractReverse(this.vertexPositions[2].vector3D); Vec3 vec32 = vec31.crossProduct(vec3).normalize(); float f = (float)vec32.xCoord; float f1 = (float)vec32.yCoord; float f2 = (float)vec32.zCoord; if (this.invertNormal) { f = -f; f1 = -f1; f2 = -f2; } renderer.begin(7, DefaultVertexFormats.OLDMODEL_POSITION_TEX_NORMAL); for (int i = 0; i < 4; ++i) { PositionTextureVertex positiontexturevertex = this.vertexPositions[i]; renderer.pos(positiontexturevertex.vector3D.xCoord * (double)scale, positiontexturevertex.vector3D.yCoord * (double)scale, positiontexturevertex.vector3D.zCoord * (double)scale).tex((double)positiontexturevertex.texturePositionX, (double)positiontexturevertex.texturePositionY).normal(f, f1, f2).endVertex(); } Tessellator.getInstance().draw(); }
/** * Draw with the WorldRenderer */ public void draw(int posX, int posY, int texU, int texV, int width, int height, int red, int green, int blue, int alpha) { VertexBuffer vertexbuffer = Tessellator.getInstance().getBuffer(); vertexbuffer.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR); float f = 0.00390625F; float f1 = 0.00390625F; vertexbuffer.pos((double)posX, (double)(posY + height), 0.0D).tex((double)((float)texU * 0.00390625F), (double)((float)(texV + height) * 0.00390625F)).color(red, green, blue, alpha).endVertex(); vertexbuffer.pos((double)(posX + width), (double)(posY + height), 0.0D).tex((double)((float)(texU + width) * 0.00390625F), (double)((float)(texV + height) * 0.00390625F)).color(red, green, blue, alpha).endVertex(); vertexbuffer.pos((double)(posX + width), (double)posY, 0.0D).tex((double)((float)(texU + width) * 0.00390625F), (double)((float)texV * 0.00390625F)).color(red, green, blue, alpha).endVertex(); vertexbuffer.pos((double)posX, (double)posY, 0.0D).tex((double)((float)texU * 0.00390625F), (double)((float)texV * 0.00390625F)).color(red, green, blue, alpha).endVertex(); Tessellator.getInstance().draw(); }
private void renderWater(ResourceLocation loc) { final TextureAtlasSprite sprite = Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite(loc.toString()); final Tessellator tessellator = Tessellator.getInstance(); tessellator.getBuffer().begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX); tessellator.getBuffer().pos(0, 16, 0).tex(sprite.getMinU(), sprite.getMaxV()).endVertex(); tessellator.getBuffer().pos(16, 16, 0).tex(sprite.getMaxU(), sprite.getMaxV()).endVertex(); tessellator.getBuffer().pos(16, 0, 0).tex(sprite.getMaxU(), sprite.getMinV()).endVertex(); tessellator.getBuffer().pos(0, 0, 0).tex(sprite.getMinU(), sprite.getMinV()).endVertex(); tessellator.draw(); }
public static void drawTexture(int x, int y, float u, float v, float uWidth, float vHeight, int width, int height, float tileWidth, float tileHeight) { float f = 1.0F / tileWidth; float f1 = 1.0F / tileHeight; Tessellator tessellator = Tessellator.getInstance(); BufferBuilder bufferbuilder = tessellator.getBuffer(); bufferbuilder.begin(7, DefaultVertexFormats.POSITION_TEX); bufferbuilder.pos((double)x, (double)(y + height), 0.0D).tex((double)(u * f), (double)((v + vHeight) * f1)).endVertex(); bufferbuilder.pos((double)(x + width), (double)(y + height), 0.0D).tex((double)((u + uWidth) * f), (double)((v + vHeight) * f1)).endVertex(); bufferbuilder.pos((double)(x + width), (double)y, 0.0D).tex((double)((u + uWidth) * f), (double)(v * f1)).endVertex(); bufferbuilder.pos((double)x, (double)y, 0.0D).tex((double)(u * f), (double)(v * f1)).endVertex(); tessellator.draw(); }
public static void renderGhostBlock(IBlockState state, BlockPos position, Color color, boolean noDepth, float partialTicks) { if(!(state.getBlock() instanceof BlockLiquid) && !(state.getBlock() instanceof BlockFluidBase)) { renderGhostModel(Minecraft.getMinecraft().getBlockRendererDispatcher().getModelForState(state), position, color, noDepth, partialTicks); return; } GlStateManager.enableBlend(); GL11.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE_MINUS_DST_COLOR); BufferBuilder vb; if(noDepth) { GlStateManager.depthFunc(519); vb = prepRenderBlockDepth(partialTicks, true); } else vb = prepRender(partialTicks, true); vb.begin(7, DefaultVertexFormats.BLOCK); World world = Minecraft.getMinecraft().world; Minecraft.getMinecraft().getBlockRendererDispatcher().renderBlock(state, position.add(0, noDepth ? 500 : 0, 0), world, vb); for(int i = 0; i < vb.getVertexCount(); i++) vb.putColorMultiplier(color.getRed() / 255f, color.getGreen() / 255f, color.getBlue() / 255f, i); vb.color(1, 1, 1, 0.1f); postRender(); GlStateManager.disableBlend(); GlStateManager.depthFunc(515); }
/** * Render Block with {@link Tessellator} and {@link BlockRendererDispatcher} */ public static void renderBlock(IBlockState state, BlockPos pos) { Tessellator tessellator = Tessellator.getInstance(); BufferBuilder BufferBuilder = tessellator.getBuffer(); BufferBuilder.begin(GL_QUADS, DefaultVertexFormats.BLOCK); BlockRendererDispatcher dispatcher = minecraft.getBlockRendererDispatcher(); dispatcher.renderBlock(state, pos, minecraft.world, BufferBuilder); tessellator.draw(); }
/** * Overlays the background to hide scrolled items */ protected void overlayBackground(int startY, int endY, int startAlpha, int endAlpha) { Tessellator tessellator = Tessellator.getInstance(); WorldRenderer worldrenderer = tessellator.getWorldRenderer(); this.mc.getTextureManager().bindTexture(Gui.optionsBackground); GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); float f = 32.0F; worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR); worldrenderer.pos((double)this.left, (double)endY, 0.0D).tex(0.0D, (double)((float)endY / 32.0F)).color(64, 64, 64, endAlpha).endVertex(); worldrenderer.pos((double)(this.left + this.width), (double)endY, 0.0D).tex((double)((float)this.width / 32.0F), (double)((float)endY / 32.0F)).color(64, 64, 64, endAlpha).endVertex(); worldrenderer.pos((double)(this.left + this.width), (double)startY, 0.0D).tex((double)((float)this.width / 32.0F), (double)((float)startY / 32.0F)).color(64, 64, 64, startAlpha).endVertex(); worldrenderer.pos((double)this.left, (double)startY, 0.0D).tex(0.0D, (double)((float)startY / 32.0F)).color(64, 64, 64, startAlpha).endVertex(); tessellator.draw(); }
public static IBakedModel getModel(ResourceLocation resourceLocation) { IBakedModel bakedModel; IModel model; try { model = ModelLoaderRegistry.getModel(resourceLocation); } catch (Exception e) { throw new RuntimeException(e); } bakedModel = model.bake(TRSRTransformation.identity(), DefaultVertexFormats.BLOCK, location -> Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite(location.toString())); return bakedModel; }
private void drawCustomGui(double x, double y, double width, double height, double zLevel) { GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); Tessellator tessellator = Tessellator.getInstance(); BufferBuilder bufferbuilder = tessellator.getBuffer(); GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); bufferbuilder.begin(7, DefaultVertexFormats.POSITION); bufferbuilder.pos(x + 0, y + height, zLevel).endVertex(); bufferbuilder.pos(x + width, y + height, zLevel).endVertex(); bufferbuilder.pos(x + width, y + 0, zLevel).endVertex(); bufferbuilder.pos(x + 0, y + 0, zLevel).endVertex(); tessellator.draw(); }