Java Code Examples for net.minecraft.client.renderer.GlStateManager#enableBlend()
The following examples show how to use
net.minecraft.client.renderer.GlStateManager#enableBlend() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ButtonSlider.java From SkyblockAddons with MIT License | 6 votes |
@Override public void drawButton(Minecraft mc, int mouseX, int mouseY) { mc.getTextureManager().bindTexture(buttonTextures); GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); this.hovered = mouseX >= this.xPosition && mouseY >= this.yPosition && mouseX < this.xPosition + this.width && mouseY < this.yPosition + this.height; GlStateManager.enableBlend(); GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); GlStateManager.blendFunc(770, 771); int boxAlpha = 100; if (hovered) { boxAlpha = 170; } drawRect(this.xPosition, this.yPosition, this.xPosition+this.width, this.yPosition+this.height, main.getUtils().getDefaultColor(boxAlpha)); this.mouseDragged(mc, mouseX, mouseY); int j = 14737632; if (packedFGColour != 0) { j = packedFGColour; } else if (!this.enabled) { j = 10526880; } else if (this.hovered) { j = 16777120; } MinecraftReflection.FontRenderer.drawCenteredString(this.displayString, this.xPosition + this.width / 2, this.yPosition + (this.height - 8) / 2, j); }
Example 2
Source File: PhasedBlockRenderer.java From Wizardry with GNU Lesser General Public License v3.0 | 6 votes |
public static BufferBuilder beginRender() { GlStateManager.enableAlpha(); GlStateManager.enableBlend(); GlStateManager.disableTexture2D(); GlStateManager.enableCull(); GlStateManager.cullFace(GlStateManager.CullFace.BACK); GlStateManager.depthMask(false); GlStateManager.enablePolygonOffset(); GlStateManager.doPolygonOffset(-0.1f, -1000f); GlStateManager.enableColorMaterial(); GlStateManager.color(1, 1, 1, 1); GlStateManager.shadeModel(GL11.GL_SMOOTH); GlStateManager.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE); GL14.glBlendEquation(GL14.GL_FUNC_SUBTRACT); BufferBuilder buffer = Tessellator.getInstance().getBuffer(); buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_COLOR_NORMAL); buffer.setTranslation(-TileEntityRendererDispatcher.staticPlayerX, -TileEntityRendererDispatcher.staticPlayerY, -TileEntityRendererDispatcher.staticPlayerZ); return buffer; }
Example 3
Source File: RenderUtils.java From LiquidBounce with GNU General Public License v3.0 | 6 votes |
public static void drawCircle(float x, float y, float radius, int start, int end) { GlStateManager.enableBlend(); GlStateManager.disableTexture2D(); GlStateManager.tryBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ZERO); glColor(Color.WHITE); glEnable(GL_LINE_SMOOTH); glLineWidth(2F); glBegin(GL_LINE_STRIP); for (float i = end; i >= start; i -= (360 / 90.0f)) { glVertex2f((float) (x + (cos(i * PI / 180) * (radius * 1.001F))), (float) (y + (sin(i * PI / 180) * (radius * 1.001F)))); } glEnd(); glDisable(GL_LINE_SMOOTH); GlStateManager.enableTexture2D(); GlStateManager.disableBlend(); }
Example 4
Source File: LayoutManager.java From NotEnoughItems with MIT License | 5 votes |
public static void drawIcon(int x, int y, Image image) { changeTexture("nei:textures/nei_sprites.png"); GlStateManager.color(1, 1, 1, 1); GlStateManager.enableBlend(); GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); drawTexturedModalRect(x, y, image.x, image.y, image.width, image.height); GlStateManager.disableBlend(); }
Example 5
Source File: GuiCustom.java From Custom-Main-Menu with MIT License | 5 votes |
private void rotateAndBlurSkybox(float p_73968_1_) { this.mc.getTextureManager().bindTexture(this.field_110351_G); 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(); BufferBuilder vertexBuffer = tessellator.getBuffer(); vertexBuffer.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR); GlStateManager.disableAlpha(); int i = 3; if (guiConfig.panorama.blur) { 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; vertexBuffer.pos((double) k, (double) l, (double) this.zLevel).tex((double) (0.0F + f1), 1.0D).color(1.0F, 1.0F, 1.0F, f).endVertex(); vertexBuffer.pos((double) k, 0.0D, (double) this.zLevel).tex((double) (1.0F + f1), 1.0D).color(1.0F, 1.0F, 1.0F, f).endVertex(); vertexBuffer.pos(0.0D, 0.0D, (double) this.zLevel).tex((double) (1.0F + f1), 0.0D).color(1.0F, 1.0F, 1.0F, f).endVertex(); vertexBuffer.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); }
Example 6
Source File: RenderUtil.java From seppuku with GNU General Public License v3.0 | 5 votes |
public static void drawGradientRect(float left, float top, float right, float bottom, int startColor, int endColor) { float f = (float) (startColor >> 24 & 255) / 255.0F; float f1 = (float) (startColor >> 16 & 255) / 255.0F; float f2 = (float) (startColor >> 8 & 255) / 255.0F; float f3 = (float) (startColor & 255) / 255.0F; float f4 = (float) (endColor >> 24 & 255) / 255.0F; float f5 = (float) (endColor >> 16 & 255) / 255.0F; float f6 = (float) (endColor >> 8 & 255) / 255.0F; float f7 = (float) (endColor & 255) / 255.0F; GlStateManager.disableTexture2D(); GlStateManager.enableBlend(); GlStateManager.disableAlpha(); GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO); GlStateManager.shadeModel(7425); Tessellator tessellator = Tessellator.getInstance(); BufferBuilder bufferbuilder = tessellator.getBuffer(); bufferbuilder.begin(7, DefaultVertexFormats.POSITION_COLOR); bufferbuilder.pos((double) right, (double) top, (double) 0).color(f1, f2, f3, f).endVertex(); bufferbuilder.pos((double) left, (double) top, (double) 0).color(f1, f2, f3, f).endVertex(); bufferbuilder.pos((double) left, (double) bottom, (double) 0).color(f5, f6, f7, f4).endVertex(); bufferbuilder.pos((double) right, (double) bottom, (double) 0).color(f5, f6, f7, f4).endVertex(); tessellator.draw(); GlStateManager.shadeModel(7424); GlStateManager.disableBlend(); GlStateManager.enableAlpha(); GlStateManager.enableTexture2D(); }
Example 7
Source File: TabGui.java From ClientBase with MIT License | 5 votes |
public static void drawRect(int glFlag, int left, int top, int right, int bottom, int color) { if (left < right) { int i = left; left = right; right = i; } if (top < bottom) { int j = top; top = bottom; bottom = j; } float f3 = (float) (color >> 24 & 255) / 255.0F; float f = (float) (color >> 16 & 255) / 255.0F; float f1 = (float) (color >> 8 & 255) / 255.0F; float f2 = (float) (color & 255) / 255.0F; Tessellator tessellator = Tessellator.getInstance(); WorldRenderer worldrenderer = tessellator.getWorldRenderer(); GlStateManager.enableBlend(); GlStateManager.disableTexture2D(); GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); GlStateManager.color(f, f1, f2, f3); worldrenderer.begin(glFlag, DefaultVertexFormats.POSITION); worldrenderer.pos((double) left, (double) bottom, 0.0D).endVertex(); worldrenderer.pos((double) right, (double) bottom, 0.0D).endVertex(); worldrenderer.pos((double) right, (double) top, 0.0D).endVertex(); worldrenderer.pos((double) left, (double) top, 0.0D).endVertex(); tessellator.draw(); GlStateManager.enableTexture2D(); GlStateManager.disableBlend(); }
Example 8
Source File: LayoutManager.java From NotEnoughItems with MIT License | 5 votes |
public static void drawIcon(int x, int y, Rectangle4i image) { changeTexture("nei:textures/nei_sprites.png"); GlStateManager.color(1, 1, 1, 1); GlStateManager.enableBlend(); GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); drawTexturedModalRect(x, y, image.x, image.y, image.w, image.h); GlStateManager.disableBlend(); }
Example 9
Source File: MixinGuiInGame.java From LiquidBounce with GNU General Public License v3.0 | 5 votes |
@Inject(method = "renderTooltip", at = @At("HEAD"), cancellable = true) private void renderTooltip(ScaledResolution sr, float partialTicks, CallbackInfo callbackInfo) { final HUD hud = (HUD) LiquidBounce.moduleManager.getModule(HUD.class); if (Minecraft.getMinecraft().getRenderViewEntity() instanceof EntityPlayer && hud.getState() && hud.blackHotbarValue.get()) { EntityPlayer entityPlayer = (EntityPlayer) Minecraft.getMinecraft().getRenderViewEntity(); int middleScreen = sr.getScaledWidth() / 2; GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); GuiIngame.drawRect(middleScreen - 91, sr.getScaledHeight() - 24, middleScreen + 90, sr.getScaledHeight(), Integer.MIN_VALUE); GuiIngame.drawRect(middleScreen - 91 - 1 + entityPlayer.inventory.currentItem * 20 + 1, sr.getScaledHeight() - 24, middleScreen - 91 - 1 + entityPlayer.inventory.currentItem * 20 + 22, sr.getScaledHeight() - 22 - 1 + 24, Integer.MAX_VALUE); GlStateManager.enableRescaleNormal(); GlStateManager.enableBlend(); GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); RenderHelper.enableGUIStandardItemLighting(); for (int j = 0; j < 9; ++j) { int k = sr.getScaledWidth() / 2 - 90 + j * 20 + 2; int l = sr.getScaledHeight() - 16 - 3; this.renderHotbarItem(j, k, l, partialTicks, entityPlayer); } RenderHelper.disableStandardItemLighting(); GlStateManager.disableRescaleNormal(); GlStateManager.disableBlend(); LiquidBounce.eventManager.callEvent(new Render2DEvent(partialTicks)); AWTFontRenderer.Companion.garbageCollectionTick(); callbackInfo.cancel(); } }
Example 10
Source File: GuiCustomizeWorld.java From YUNoMakeGoodMap with Apache License 2.0 | 5 votes |
protected void drawHeader(int entryRight, int relativeY, Tessellator tess) { int top = relativeY; if (logoPath != null) { GlStateManager.enableBlend(); GuiCustomizeWorld.this.mc.renderEngine.bindTexture(logoPath); BufferBuilder wr = tess.getBuffer(); int offset = (this.left + this.listWidth/2) - (logoDims.width / 2); wr.begin(7, DefaultVertexFormats.POSITION_TEX); wr.pos(offset, top + logoDims.height, zLevel).tex(0, 1).endVertex(); wr.pos(offset + logoDims.width, top + logoDims.height, zLevel).tex(1, 1).endVertex(); wr.pos(offset + logoDims.width, top, zLevel).tex(1, 0).endVertex(); wr.pos(offset, top, zLevel).tex(0, 0).endVertex(); tess.draw(); GlStateManager.disableBlend(); top += logoDims.height + 10; } for (ITextComponent line : lines) { if (line != null) { GlStateManager.enableBlend(); GuiCustomizeWorld.this.fontRenderer.drawStringWithShadow(line.getFormattedText(), this.left + 4, top, 0xFFFFFF); GlStateManager.disableAlpha(); GlStateManager.disableBlend(); } top += 10; } }
Example 11
Source File: PhantomFluidWidget.java From GregTech with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void drawInBackground(int mouseX, int mouseY, IRenderContext context) { Position pos = getPosition(); Size size = getSize(); if (backgroundTexture != null) { backgroundTexture.draw(pos.x, pos.y, size.width, size.height); } if (lastFluidStack != null) { GlStateManager.disableBlend(); RenderUtil.drawFluidForGui(lastFluidStack, lastFluidStack.amount, pos.x + 1, pos.y + 1, size.width - 1, size.height - 1); GlStateManager.enableBlend(); GlStateManager.color(1.0f, 1.0f, 1.0f); } }
Example 12
Source File: Widget.java From GregTech with GNU Lesser General Public License v3.0 | 4 votes |
@SideOnly(Side.CLIENT) protected static void drawGradientRect(int x, int y, int width, int height, int startColor, int endColor) { GuiUtils.drawGradientRect(0, x, y, x + width, y + height, startColor, endColor); GlStateManager.enableBlend(); }
Example 13
Source File: SmallVesselHighlightHandler.java From TFC2 with GNU General Public License v3.0 | 4 votes |
@SubscribeEvent public void drawBlockHighlightEvent(DrawBlockHighlightEvent evt) { RayTraceResult target = evt.getTarget(); if(target.typeOfHit != RayTraceResult.Type.BLOCK) return; World world = evt.getPlayer().world; EntityPlayer player = evt.getPlayer(); IBlockState state = world.getBlockState(target.getBlockPos()); double posX = player.lastTickPosX + (player.posX - player.lastTickPosX) * evt.getPartialTicks(); double posY = player.lastTickPosY + (player.posY - player.lastTickPosY) * evt.getPartialTicks(); double posZ = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * evt.getPartialTicks(); double hitX = Math.round((target.hitVec.xCoord - target.getBlockPos().getX())*100)/100.0d; double hitY = Math.round((target.hitVec.yCoord - target.getBlockPos().getY())*100)/100.0d; double hitZ = Math.round((target.hitVec.zCoord - target.getBlockPos().getZ())*100)/100.0d; AxisAlignedBB box = null; int index = getIndex(hitX, hitZ); if((state.getBlock() == TFCBlocks.SmallVessel) || (target.sideHit == EnumFacing.UP && player.getHeldItemMainhand().getItem() == TFCItems.PotteryVessel && state.getBlock().isSideSolid(state, world, target.getBlockPos(), EnumFacing.UP) && player.isSneaking() && player.getHeldItemMainhand().getItemDamage() == 1)) { GlStateManager.enableBlend(); GlStateManager.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA); GlStateManager.disableCull(); if(index == 0) box = aabb0.offset(target.getBlockPos()); else if(index == 1) box = aabb1.offset(target.getBlockPos()); else if(index == 2) box = aabb2.offset(target.getBlockPos()); else box = aabb3.offset(target.getBlockPos()); if(state.getBlock() != TFCBlocks.SmallVessel) box = box.offset(0, 1, 0); GlStateManager.enableTexture2D(); Core.bindTexture(selectTex); drawFace(box.expand(0.002F, 0.002F, 0.002F).offset(-posX, -posY, -posZ), new float[]{1f,1f,1f, 1f}, EnumFacing.UP); GlStateManager.disableTexture2D(); GlStateManager.enableCull(); GlStateManager.disableBlend(); } }
Example 14
Source File: RocketEventHandler.java From AdvancedRocketry with MIT License | 4 votes |
private void renderModuleSlots(ItemStack armorStack, int slot, RenderGameOverlayEvent event) { int index = 1; float color = 0.85f + 0.15F*MathHelper.sin( 2f*(float)Math.PI*((Minecraft.getMinecraft().world.getTotalWorldTime()) % 60)/60f ); BufferBuilder buffer = Tessellator.getInstance().getBuffer(); GlStateManager.enableBlend(); GlStateManager.enableAlpha(); GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); float alpha = 0.6f; if( armorStack != null ) { boolean modularArmorFlag = armorStack.getItem() instanceof IModularArmor; if(modularArmorFlag || ItemAirUtils.INSTANCE.isStackValidAirContainer(armorStack)) { int size = 24; int screenY = suitPanel.getRenderY() + (slot-1)*(size + 8); int screenX = suitPanel.getRenderX(); //Draw BG GL11.glColor4f(1f,1f,1f, 1f); Minecraft.getMinecraft().renderEngine.bindTexture(TextureResources.frameHUDBG); buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX); RenderHelper.renderNorthFaceWithUV(buffer, this.zLevel-1, screenX - 4, screenY - 4, screenX + size, screenY + size + 4,0d,0.5d,0d,1d); Tessellator.getInstance().draw(); Minecraft.getMinecraft().renderEngine.bindTexture(TextureResources.frameHUDBG); buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX); RenderHelper.renderNorthFaceWithUV(buffer, this.zLevel-1, screenX + size, screenY - 3, screenX + 2 + size, screenY + size + 3,0.5d,0.5d,0d,0d); Tessellator.getInstance().draw(); //Draw Icon GlStateManager.color(color,color,color, color); Minecraft.getMinecraft().renderEngine.bindTexture(TextureResources.armorSlots[slot-1]); buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX); RenderHelper.renderNorthFaceWithUV(buffer, this.zLevel-1, screenX, screenY, screenX + size, screenY + size,0d,1d,1d,0d); Tessellator.getInstance().draw(); if(modularArmorFlag) { List<ItemStack> stacks = ((IModularArmor)armorStack.getItem()).getComponents(armorStack); for(ItemStack stack : stacks) { GL11.glColor4f(1f, 1f, 1f, 1f); ((IArmorComponent)stack.getItem()).renderScreen(stack, stacks, event, this); ResourceIcon icon = ((IArmorComponent)stack.getItem()).getComponentIcon(stack); ResourceLocation texture = null; if(icon != null) texture= icon.getResourceLocation(); //if(texture != null) { screenX = suitPanel.getRenderX() + 4 + index*(size+2); //Draw BG Minecraft.getMinecraft().renderEngine.bindTexture(TextureResources.frameHUDBG); buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX); RenderHelper.renderNorthFaceWithUV(buffer, this.zLevel -1, screenX - 4, screenY - 4, screenX + size - 2, screenY + size + 4,0.5d,0.5d,0d,1d); Tessellator.getInstance().draw(); if(texture != null) { //Draw Icon Minecraft.getMinecraft().renderEngine.bindTexture(texture); GlStateManager.color(color,color,color, alpha); buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX); RenderHelper.renderNorthFaceWithUV(buffer, this.zLevel-1, screenX, screenY, screenX + size, screenY + size, icon.getMinU(),icon.getMaxU(), icon.getMaxV(),icon.getMinV()); Tessellator.getInstance().draw(); } else { GL11.glPushMatrix(); GlStateManager.translate(screenX , screenY, 0); GlStateManager.scale(1.5f, 1.5f, 1.5f); Minecraft.getMinecraft().getRenderItem().renderItemIntoGUI(stack, 0,0); GL11.glPopMatrix(); } index++; //} } } screenX = (index)*(size+2) + suitPanel.getRenderX() - 12; //Draw BG GlStateManager.color(1,1,1, 1f); Minecraft.getMinecraft().renderEngine.bindTexture(TextureResources.frameHUDBG); buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX); RenderHelper.renderNorthFaceWithUV(buffer, this.zLevel-1, screenX + 12, screenY - 4, screenX + size, screenY + size + 4,0.75d,1d,0d,1d); Tessellator.getInstance().draw(); } } GlStateManager.disableAlpha(); }
Example 15
Source File: GuiDownloadTofuTerrain.java From TofuCraftReload with MIT License | 4 votes |
private void drawPanorama(float ticks) { Tessellator tessellator = Tessellator.getInstance(); BufferBuilder buffer = tessellator.getBuffer(); GlStateManager.matrixMode(GL11.GL_PROJECTION); GlStateManager.pushMatrix(); GlStateManager.loadIdentity(); Project.gluPerspective(120.0F, 1.0F, 0.05F, 10.0F); GlStateManager.matrixMode(GL11.GL_MODELVIEW); GlStateManager.pushMatrix(); GlStateManager.loadIdentity(); GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); GlStateManager.rotate(180.0F, 1.0F, 0.0F, 0.0F); GlStateManager.rotate(90.0F, 0.0F, 0.0F, 1.0F); GlStateManager.enableBlend(); GlStateManager.disableAlpha(); GlStateManager.disableCull(); GlStateManager.depthMask(false); GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO); byte b0 = 8; for (int k = 0; k < b0 * b0; ++k) { GlStateManager.pushMatrix(); float f1 = ((float) (k % b0) / (float) b0 - 0.5F) / 64.0F; float f2 = ((float) (k / b0) / (float) b0 - 0.5F) / 64.0F; float f3 = 0.0F; GlStateManager.translate(f1, f2, f3); GlStateManager.rotate(MathHelper.sin((panoramaTimer + ticks) / 400.0F) * 15.0F + 10.0F, 1.0F, 0.0F, 0.0F); GlStateManager.rotate(-(panoramaTimer + ticks) * 0.08F, 0.0F, 1.0F, 0.0F); for (int l = 0; l < 6; ++l) { GlStateManager.pushMatrix(); switch (l) { case 1: GlStateManager.rotate(90.0F, 0.0F, 1.0F, 0.0F); break; case 2: GlStateManager.rotate(180.0F, 0.0F, 1.0F, 0.0F); break; case 3: GlStateManager.rotate(-90.0F, 0.0F, 1.0F, 0.0F); break; case 4: GlStateManager.rotate(90.0F, 1.0F, 0.0F, 0.0F); break; case 5: GlStateManager.rotate(-90.0F, 1.0F, 0.0F, 0.0F); break; } mc.getTextureManager().bindTexture(getPanoramaPaths().getPath(l)); buffer.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR); int i = 255 / (k + 1); buffer.pos(-1.0D, -1.0D, 1.0D).tex(0.0D, 0.0D).color(255, 255, 255, i).endVertex(); buffer.pos(1.0D, -1.0D, 1.0D).tex(1.0D, 0.0D).color(255, 255, 255, i).endVertex(); buffer.pos(1.0D, 1.0D, 1.0D).tex(1.0D, 1.0D).color(255, 255, 255, i).endVertex(); buffer.pos(-1.0D, 1.0D, 1.0D).tex(0.0D, 1.0D).color(255, 255, 255, i).endVertex(); tessellator.draw(); GlStateManager.popMatrix(); } GlStateManager.popMatrix(); GlStateManager.colorMask(true, true, true, false); } buffer.setTranslation(0.0D, 0.0D, 0.0D); GlStateManager.colorMask(true, true, true, true); GlStateManager.matrixMode(GL11.GL_PROJECTION); GlStateManager.popMatrix(); GlStateManager.matrixMode(GL11.GL_MODELVIEW); GlStateManager.popMatrix(); GlStateManager.depthMask(true); GlStateManager.enableCull(); GlStateManager.enableDepth(); }
Example 16
Source File: SurfaceHelper.java From ForgeHax with MIT License | 4 votes |
protected static void renderItemOverlayIntoGUI( FontRenderer fr, ItemStack stack, double xPosition, double yPosition, @Nullable String text, double scale) { final double SCALE_RATIO = 1.23076923077D; if (!stack.isEmpty()) { if (stack.getCount() != 1 || text != null) { String s = text == null ? String.valueOf(stack.getCount()) : text; GlStateManager.disableLighting(); GlStateManager.disableDepth(); GlStateManager.disableBlend(); fr.drawStringWithShadow( s, (float) (xPosition + 19 - 2 - fr.getStringWidth(s)), (float) (yPosition + 6 + 3), 16777215); GlStateManager.enableLighting(); GlStateManager.enableDepth(); // Fixes opaque cooldown overlay a bit lower // TODO: check if enabled blending still screws things up down the line. GlStateManager.enableBlend(); } if (stack.getItem().showDurabilityBar(stack)) { GlStateManager.disableLighting(); GlStateManager.disableDepth(); GlStateManager.disableTexture2D(); GlStateManager.disableAlpha(); GlStateManager.disableBlend(); double health = stack.getItem().getDurabilityForDisplay(stack); int rgbfordisplay = stack.getItem().getRGBDurabilityForDisplay(stack); int i = Math.round(13.0F - (float) health * 13.0F); int j = rgbfordisplay; draw(xPosition + (scale / 8.D), yPosition + (scale / SCALE_RATIO), 13, 2, 0, 0, 0, 255); draw( xPosition + (scale / 8.D), yPosition + (scale / SCALE_RATIO), 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(); draw(xPosition, yPosition + scale * (1.0F - f3), 16, scale * f3, 255, 255, 255, 127); GlStateManager.enableTexture2D(); GlStateManager.enableLighting(); GlStateManager.enableDepth(); } } }
Example 17
Source File: GuiOreMappingSatellite.java From AdvancedRocketry with MIT License | 4 votes |
@Override protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_) { BufferBuilder buffer = Tessellator.getInstance().getBuffer(); //Draw fancy things GlStateManager.disableTexture2D(); GlStateManager.color(0f, 0.8f, 0f); buffer.begin(GL11.GL_QUADS, buffer.getVertexFormat()); buffer.pos(-21, 82 + fancyScanOffset, (double)this.zLevel).endVertex(); buffer.pos(0, 84 + fancyScanOffset, (double)this.zLevel).endVertex(); buffer.pos(0, 81 + fancyScanOffset, (double)this.zLevel).endVertex(); buffer.pos(-21, 81 + fancyScanOffset, (double)this.zLevel).endVertex(); buffer.finishDrawing(); buffer.begin(GL11.GL_QUADS, buffer.getVertexFormat()); buffer.pos(-21, 82 - fancyScanOffset + FANCYSCANMAXSIZE, (double)this.zLevel).endVertex(); buffer.pos(0, 84 - fancyScanOffset + FANCYSCANMAXSIZE, (double)this.zLevel).endVertex(); buffer.pos(0, 81 - fancyScanOffset + FANCYSCANMAXSIZE, (double)this.zLevel).endVertex(); buffer.pos(-21, 81 - fancyScanOffset + FANCYSCANMAXSIZE, (double)this.zLevel).endVertex(); buffer.finishDrawing(); GlStateManager.enableBlend(); GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_DST_ALPHA); GlStateManager.color(0.5f, 0.5f, 0.0f,0.3f + ((float)Math.sin(Math.PI*(fancyScanOffset/(float)FANCYSCANMAXSIZE))/3f)); buffer.begin(GL11.GL_QUADS, buffer.getVertexFormat()); RenderHelper.renderNorthFace(buffer, this.zLevel, 173, 82, 194, 141); buffer.finishDrawing(); GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glDisable(GL11.GL_BLEND); if(world.getTotalWorldTime() - prevWorldTickTime >= 1 ) { prevWorldTickTime = world.getTotalWorldTime(); if(fancyScanOffset >= FANCYSCANMAXSIZE) fancyScanOffset = 0; else fancyScanOffset++; } //If a slot is selected draw an indicator int slot; if(tile != null && (slot = tile.getSelectedSlot()) != -1) { GlStateManager.disableTexture2D(); GlStateManager.color(0f, 0.8f, 0f, 1f); buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX); RenderHelper.renderNorthFaceWithUV(buffer, this.zLevel, 13 + (18*slot), 155, 13 + 16 + (18*slot), 155 + 16, 0, 1, 0, 1); Tessellator.getInstance().draw(); GlStateManager.enableTexture2D(); } }
Example 18
Source File: AnvilHighlightHandler.java From TFC2 with GNU General Public License v3.0 | 4 votes |
@SubscribeEvent public void drawBlockHighlightEvent(DrawBlockHighlightEvent evt) { if(evt.getTarget().typeOfHit != RayTraceResult.Type.BLOCK) return; if(evt.getTarget().sideHit != EnumFacing.UP) return; World world = evt.getPlayer().world; if(world.getBlockState(evt.getTarget().getBlockPos()).getBlock() != TFCBlocks.Anvil) return; double posX = evt.getPlayer().lastTickPosX + (evt.getPlayer().posX - evt.getPlayer().lastTickPosX) * evt.getPartialTicks(); double posY = evt.getPlayer().lastTickPosY + (evt.getPlayer().posY - evt.getPlayer().lastTickPosY) * evt.getPartialTicks(); double posZ = evt.getPlayer().lastTickPosZ + (evt.getPlayer().posZ - evt.getPlayer().lastTickPosZ) * evt.getPartialTicks(); double hitX = Math.round((evt.getTarget().hitVec.xCoord - evt.getTarget().getBlockPos().getX())*100)/100.0d; double hitY = Math.round((evt.getTarget().hitVec.yCoord - evt.getTarget().getBlockPos().getY())*100)/100.0d; double hitZ = Math.round((evt.getTarget().hitVec.zCoord - evt.getTarget().getBlockPos().getZ())*100)/100.0d; int divX = (int) Math.floor(hitX * 8); int divY = (int) Math.floor(hitY * 8); int divZ = (int) Math.floor(hitZ * 8); //get the targeted sub block coords double subX = divX/8D; double subY = divY/8D; double subZ = divZ/8D; TileAnvil te = (TileAnvil) world.getTileEntity(evt.getTarget().getBlockPos()); EnumFacing facing = world.getBlockState(evt.getTarget().getBlockPos()).getValue(BlockAnvil.FACING); if(facing == EnumFacing.NORTH || facing == EnumFacing.SOUTH) { if(divX == 0 || divX == 7 || divZ < 2 || divZ > 5) return; divX -= 1; divZ -= 2; if(te.getStrikePoint(divX, divZ) == null) return; } if(facing == EnumFacing.EAST || facing == EnumFacing.WEST) { if(divZ == 0 || divZ == 7 || divX < 2 || divX > 5) return; divX -= 2; divZ -= 1; if(te.getStrikePoint(divZ, divX) == null) return; } //create the box size double minX = evt.getTarget().getBlockPos().getX() + subX; double minY = evt.getTarget().getBlockPos().getY() + subY; double minZ = evt.getTarget().getBlockPos().getZ() + subZ; double maxX = minX + 0.125; double maxY = minY + 0.07; double maxZ = minZ + 0.125; GlStateManager.enableBlend(); GlStateManager.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA); GlStateManager.disableCull(); GlStateManager.disableTexture2D(); //Draw the mini Box drawBox(new AxisAlignedBB(minX,minY,minZ,maxX,maxY,maxZ).expand(0.002F, 0.002F, 0.002F).offset(-posX, -posY, -posZ), new float[]{1,0.5f,0, 0.5f}); GlStateManager.enableTexture2D(); GlStateManager.enableCull(); GlStateManager.disableBlend(); }
Example 19
Source File: ShulkerViewer.java From ForgeHax with MIT License | 4 votes |
@Override public void drawScreen(int mouseX, int mouseY, float partialTicks) { final int DEPTH = 500; int x = posX; int y = posY; GlStateManager.enableTexture2D(); GlStateManager.disableLighting(); GlStateManager.color( 1.f, 1.f, 1.f, !isLocked() ? (tooltip_opacity.getAsFloat() / 255.f) : (locked_opacity.getAsFloat() / 255.f)); GlStateManager.enableBlend(); GlStateManager.tryBlendFuncSeparate( GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO); MC.getTextureManager().bindTexture(SHULKER_GUI_TEXTURE); // width 176 = width of container // height 16 = top of the gui // height 54 = gui item boxes // height 6 = bottom of the gui SurfaceHelper.drawTexturedRect(x, y, 0, 0, 176, 16, DEPTH); SurfaceHelper.drawTexturedRect(x, y + 16, 0, 16, 176, 54, DEPTH); SurfaceHelper.drawTexturedRect(x, y + 16 + 54, 0, 160, 176, 6, DEPTH); GlStateManager.disableDepth(); SurfaceHelper.drawText(parentShulker.getDisplayName(), x + 8, y + 6, Colors.BLACK.toBuffer()); GlStateManager.enableDepth(); RenderHelper.enableGUIStandardItemLighting(); GlStateManager.enableRescaleNormal(); GlStateManager.enableColorMaterial(); GlStateManager.enableLighting(); Slot hoveringOver = null; int rx = x + 8; int ry = y - 1; for (Slot slot : inventorySlots.inventorySlots) { if (slot.getHasStack()) { int px = rx + slot.xPos; int py = ry + slot.yPos; MC.getRenderItem().zLevel = DEPTH + 1; SurfaceHelper.drawItem(slot.getStack(), px, py); SurfaceHelper.drawItemOverlay(slot.getStack(), px, py); MC.getRenderItem().zLevel = 0.f; if (isPointInRegion(px, py, 16, 16, mouseX, mouseY)) { hoveringOver = slot; } } } GlStateManager.disableLighting(); if (hoveringOver != null) { // background of the gui GlStateManager.disableLighting(); GlStateManager.disableDepth(); GlStateManager.colorMask(true, true, true, false); this.drawGradientRect( rx + hoveringOver.xPos, ry + hoveringOver.yPos, rx + hoveringOver.xPos + 16, ry + hoveringOver.yPos + 16, -2130706433, -2130706433); GlStateManager.colorMask(true, true, true, true); // tool tip GlStateManager.color(1.f, 1.f, 1.f, 1.0f); GlStateManager.pushMatrix(); isModGeneratedToolTip = true; renderToolTip(hoveringOver.getStack(), mouseX + 8, mouseY + 8); isModGeneratedToolTip = false; GlStateManager.popMatrix(); GlStateManager.enableDepth(); } if (isPointInRegion(this.posX, this.posY, getWidth(), getHeight(), mouseX, mouseY)) { isMouseInShulkerGui = true; } GlStateManager.disableBlend(); GlStateManager.color(1.f, 1.f, 1.f, 1.0f); }
Example 20
Source File: BasicNodeTileEntityRenderer.java From Valkyrien-Skies with Apache License 2.0 | 4 votes |
private void renderWire(double x, double y, double z, double entity1x, double entity1y, double entity1z, double entity2x, double entity2y, double entity2z) { GlStateManager.enableAlpha(); GlStateManager.enableBlend(); float wireR = .6f; float wireG = .25f; float wireB = .02f; float wireAlpha = 1.0f; // Vec3d vec = new Vec3d(x,y,z); // if (vec.lengthSquared() < .01D) { // System.out.println("REE"); // } // y = .5D; Tessellator tessellator = Tessellator.getInstance(); BufferBuilder bufferbuilder = tessellator.getBuffer(); double d0 = 0;// this.interpolateValue(entity.prevRotationYaw, entity.rotationYaw, // partialTicks * 0.5F) * 0.01745329238474369D; double d1 = 0;// this.interpolateValue(entity.prevRotationPitch, entity.rotationPitch, // partialTicks * 0.5F) * 0.01745329238474369D; double d2 = Math.cos(d0); double d3 = Math.sin(d0); double d4 = Math.sin(d1); // if (entity instanceof EntityHanging) // { d4 = -1.0D; // } double fakeYaw = 0;// Math.PI / 6D; double d6 = entity1x; double d7 = entity1y; double d8 = entity1z; double d9 = fakeYaw; d2 = 0;// fakeWidth;; d3 = 0;// fakeWidth; double d10 = entity2x + d2; double d11 = entity2y; double d12 = entity2z + d3; x = x + d2; z = z + d3; double d13 = ((float) (d6 - d10)); double d14 = ((float) (d7 - d11)); double d15 = ((float) (d8 - d12)); GlStateManager.disableTexture2D(); GlStateManager.disableLighting(); GlStateManager.disableCull(); int i = 24; double d16 = 0.025D; bufferbuilder.begin(5, DefaultVertexFormats.POSITION_COLOR); for (int j = 0; j <= 24; ++j) { float f3 = j / 24.0F; bufferbuilder.pos(x + d13 * f3 + 0.0D, y + d14 * (f3 * f3 + f3) * 0.5D + ((24.0F - j) / 18.0F + 0.125F), z + d15 * f3).color(wireR, wireG, wireB, wireAlpha).endVertex(); bufferbuilder .pos(x + d13 * f3 + 0.025D, y + d14 * (f3 * f3 + f3) * 0.5D + ((24.0F - j) / 18.0F + 0.125F) + 0.025D, z + d15 * f3) .color(wireR, wireG, wireB, wireAlpha).endVertex(); } tessellator.draw(); bufferbuilder.begin(5, DefaultVertexFormats.POSITION_COLOR); for (int k = 0; k <= 24; ++k) { float f4 = 204F / 255F;// .282F;//0.5F; float f5 = 122F / 255F;// .176F;//0.4F; float f6 = 0;// 0.078F;//0.3F; // f4 *= 2.2F; // f5 *= 2.2F; // f6 *= 2.2F; if (k % 2 == 0) { f4 *= 0.7F; f5 *= 0.7F; f6 *= 0.7F; } float f7 = k / 24.0F; bufferbuilder.pos(x + d13 * f7 + 0.0D, y + d14 * (f7 * f7 + f7) * 0.5D + ((24.0F - k) / 18.0F + 0.125F) + 0.025D, z + d15 * f7) .color(wireR, wireG, wireB, wireAlpha).endVertex(); bufferbuilder.pos(x + d13 * f7 + 0.025D, y + d14 * (f7 * f7 + f7) * 0.5D + ((24.0F - k) / 18.0F + 0.125F), z + d15 * f7 + 0.025D).color(wireR, wireG, wireB, wireAlpha).endVertex(); } tessellator.draw(); GlStateManager.enableLighting(); GlStateManager.enableTexture2D(); GlStateManager.enableCull(); GlStateManager.disableAlpha(); GlStateManager.disableBlend(); }