Java Code Examples for net.minecraft.client.renderer.GlStateManager#alphaFunc()
The following examples show how to use
net.minecraft.client.renderer.GlStateManager#alphaFunc() .
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: GuiComponentItemStackSpinner.java From OpenModsLib with MIT License | 6 votes |
private void renderItem(ItemStack itemStack) { parent.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); final RenderItem itemRenderer = parent.getItemRenderer(); final ItemModelMesher itemModelMesher = itemRenderer.getItemModelMesher(); final IBakedModel model = itemModelMesher.getItemModel(stack); GlStateManager.disableLighting(); GlStateManager.enableRescaleNormal(); GlStateManager.alphaFunc(GL11.GL_GREATER, 0.1F); GlStateManager.enableBlend(); GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0); GlStateManager.pushMatrix(); itemRenderer.renderItem(stack, model); GlStateManager.cullFace(CullFace.BACK); GlStateManager.popMatrix(); GlStateManager.disableRescaleNormal(); GlStateManager.disableBlend(); GlStateManager.enableLighting(); }
Example 2
Source File: LitematicaRenderer.java From litematica with GNU Lesser General Public License v3.0 | 5 votes |
public void renderSchematicOverlay() { boolean invert = Hotkeys.INVERT_OVERLAY_RENDER_STATE.getKeybind().isKeybindHeld(); if (Configs.Visuals.ENABLE_SCHEMATIC_OVERLAY.getBooleanValue() != invert) { boolean renderThrough = Configs.Visuals.SCHEMATIC_OVERLAY_RENDER_THROUGH.getBooleanValue() || Hotkeys.RENDER_OVERLAY_THROUGH_BLOCKS.getKeybind().isKeybindHeld(); float lineWidth = (float) (renderThrough ? Configs.Visuals.SCHEMATIC_OVERLAY_OUTLINE_WIDTH_THROUGH.getDoubleValue() : Configs.Visuals.SCHEMATIC_OVERLAY_OUTLINE_WIDTH.getDoubleValue()); GlStateManager.pushMatrix(); GlStateManager.disableTexture2D(); GlStateManager.disableCull(); GlStateManager.alphaFunc(GL11.GL_GREATER, 0.001F); GlStateManager.enablePolygonOffset(); GlStateManager.doPolygonOffset(-0.4f, -0.8f); fi.dy.masa.malilib.render.RenderUtils.setupBlend(); GlStateManager.glLineWidth(lineWidth); fi.dy.masa.malilib.render.RenderUtils.color(1f, 1f, 1f, 1f); OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240, 240); if (renderThrough) { GlStateManager.disableDepth(); } this.getWorldRenderer().renderBlockOverlays(); GlStateManager.enableDepth(); GlStateManager.doPolygonOffset(0f, 0f); GlStateManager.disablePolygonOffset(); GlStateManager.enableTexture2D(); GlStateManager.popMatrix(); } }
Example 3
Source File: SurfaceHelper.java From ForgeHax with MIT License | 5 votes |
private static void renderItemModelIntoGUI( ItemStack stack, double x, double y, IBakedModel bakedmodel, double scale) { GlStateManager.pushMatrix(); MC.getTextureManager().bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); MC.getTextureManager() .getTexture(TextureMap.LOCATION_BLOCKS_TEXTURE) .setBlurMipmap(false, false); GlStateManager.enableRescaleNormal(); GlStateManager.enableAlpha(); GlStateManager.alphaFunc(516, 0.1F); GlStateManager.enableBlend(); GlStateManager.blendFunc( GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA); GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); GlStateManager.translate(x, y, 100.0F + MC.getRenderItem().zLevel); GlStateManager.translate(8.0F, 8.0F, 0.0F); GlStateManager.scale(1.0F, -1.0F, 1.0F); GlStateManager.scale(scale, scale, scale); if (bakedmodel.isGui3d()) { GlStateManager.enableLighting(); } else { GlStateManager.disableLighting(); } bakedmodel = net.minecraftforge.client.ForgeHooksClient.handleCameraTransforms( bakedmodel, ItemCameraTransforms.TransformType.GUI, false); MC.getRenderItem().renderItem(stack, bakedmodel); GlStateManager.disableAlpha(); GlStateManager.disableRescaleNormal(); GlStateManager.disableLighting(); GlStateManager.popMatrix(); MC.getTextureManager().bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); MC.getTextureManager().getTexture(TextureMap.LOCATION_BLOCKS_TEXTURE).restoreLastBlurMipmap(); }
Example 4
Source File: EntryValueEffectOpacity.java From WearableBackpacks with MIT License | 5 votes |
private static void renderEffect(int x, int y, int width, int height, float opacity) { if (opacity <= 0) return; Minecraft mc = Minecraft.getMinecraft(); float animProgress = Minecraft.getSystemTime() / 400.0F; int color = 0xFF8040CC; float r = (color >> 16 & 0xFF) / 255.0F; float g = (color >> 8 & 0xFF) / 255.0F; float b = (color & 0xFF) / 255.0F; GlStateManager.color(r, g, b, opacity * 0.6F); mc.getTextureManager().bindTexture(ENCHANTED_ITEM_GLINT); GlStateManager.enableBlend(); GlStateManager.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE); GlStateManager.enableAlpha(); GlStateManager.alphaFunc(GL11.GL_ALWAYS, 0.0F); for (int i = 0; i < 2; ++i) { GlStateManager.matrixMode(GL11.GL_TEXTURE); GlStateManager.loadIdentity(); GlStateManager.rotate(30.0F - i * 60.0F, 0.0F, 0.0F, 1.0F); GlStateManager.translate(0.0F, animProgress * (0.001F + i * 0.003F) * 20.0F, 0.0F); GlStateManager.matrixMode(GL11.GL_MODELVIEW); GuiUtils.drawTexturedModalRect(x, y, 0, 0, width, height, 0); } GlStateManager.matrixMode(GL11.GL_TEXTURE); GlStateManager.loadIdentity(); GlStateManager.matrixMode(GL11.GL_MODELVIEW); GlStateManager.alphaFunc(GL11.GL_GREATER, 0.1F); GlStateManager.disableAlpha(); GlStateManager.blendFunc(GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO); GlStateManager.disableBlend(); }
Example 5
Source File: RenderHelper.java From HoloInventory with MIT License | 5 votes |
public static void start() { GlStateManager.pushMatrix(); GlStateManager.pushAttrib(); GlStateManager.enableRescaleNormal(); GlStateManager.enableAlpha(); GlStateManager.alphaFunc(516, 0.1F); GlStateManager.enableBlend(); GlStateManager.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA); GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); }
Example 6
Source File: WrapperGlStateManager.java From ClientBase with MIT License | 4 votes |
public static void alphaFunc(int var0, float var1) { GlStateManager.alphaFunc(var0, var1); }
Example 7
Source File: HyperiumRendererLivingEntity.java From Hyperium with GNU Lesser General Public License v3.0 | 4 votes |
public void renderName(T entity, double x, double y, double z, RenderManager renderManager) { if (((IMixinRendererLivingEntity<T>) parent).callCanRenderName(entity)) { double d0 = entity.getDistanceSqToEntity(renderManager.livingPlayer); float f = entity.isSneaking() ? 32.0F : 64.0F; if (d0 < (double) (f * f)) { String s = entity.getDisplayName().getFormattedText(); GlStateManager.alphaFunc(GL11.GL_GREATER, 0.1F); if (entity.isSneaking() && (Settings.SHOW_OWN_NAME || !entity.equals(Minecraft.getMinecraft().thePlayer))) { FontRenderer fontrenderer = renderManager.getFontRenderer(); GlStateManager.pushMatrix(); float offset = Utils.INSTANCE.calculateDeadmauEarsOffset(entity); GlStateManager.translate((float) x, (float) y + offset + entity.height + 0.5F - (entity.isChild() ? entity.height / 2.0F : 0.0F), (float) z); GL11.glNormal3f(0.0F, 1.0F, 0.0F); GlStateManager.rotate(-renderManager.playerViewY, 0.0F, 1.0F, 0.0F); GlStateManager.rotate(renderManager.playerViewX, 1.0F, 0.0F, 0.0F); GlStateManager.scale(-0.02666667F, -0.02666667F, 0.02666667F); GlStateManager.translate(0.0F, 9.374999F, 0.0F); GlStateManager.disableLighting(); GlStateManager.depthMask(false); GlStateManager.enableBlend(); GlStateManager.disableTexture2D(); GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ZERO); int i = fontrenderer.getStringWidth(s) / 2; Tessellator tessellator = Tessellator.getInstance(); WorldRenderer worldrenderer = tessellator.getWorldRenderer(); worldrenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR); worldrenderer.pos(-i - 1, -1.0D, 0.0D).color(0.0F, 0.0F, 0.0F, 0.25F).endVertex(); worldrenderer.pos(-i - 1, 8.0D, 0.0D).color(0.0F, 0.0F, 0.0F, 0.25F).endVertex(); worldrenderer.pos(i + 1, 8.0D, 0.0D).color(0.0F, 0.0F, 0.0F, 0.25F).endVertex(); worldrenderer.pos(i + 1, -1.0D, 0.0D).color(0.0F, 0.0F, 0.0F, 0.25F).endVertex(); tessellator.draw(); GlStateManager.enableTexture2D(); GlStateManager.depthMask(true); fontrenderer.drawString(s, -fontrenderer.getStringWidth(s) / 2, 0, 553648127); GlStateManager.enableLighting(); GlStateManager.disableBlend(); GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); GlStateManager.popMatrix(); } else { ((IMixinRender<T>) parent).callRenderOffsetLivingLabel(entity, x, y - (entity.isChild() ? (double) (entity.height / 2.0F) : 0.0D), z, s, 0.02666667F, d0); } } } }
Example 8
Source File: StructureManager.java From Wizardry with GNU Lesser General Public License v3.0 | 4 votes |
/** * Will not draw the structure if it is not already baked. Resource reloading will re-bake if required. * * @param alpha The transparency of the rendered structure. * @param location The ResourceLocation of the structure to look up. */ @SideOnly(Side.CLIENT) public void draw(ResourceLocation location, float alpha) { HashMap<Integer, int[]> cache = vboCache.get(location); if (cache == null || cache.isEmpty()) { bake(location); return; } GlStateManager.pushMatrix(); GlStateManager.enableBlend(); GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GlStateManager.enablePolygonOffset(); GlStateManager.doPolygonOffset(1f, -0.05f); // GlStateManager.disableDepth(); int alphaFunc = GL11.glGetInteger(GL11.GL_ALPHA_TEST_FUNC); float alphaRef = GL11.glGetFloat(GL11.GL_ALPHA_TEST_REF); GlStateManager.alphaFunc(GL11.GL_ALWAYS, 1); Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); Tessellator tes = Tessellator.getInstance(); BufferBuilder buffer = tes.getBuffer(); for (int layerID : cache.keySet()) { buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK); buffer.addVertexData(cache.get(layerID)); for (int i = 0; i < buffer.getVertexCount(); i++) { buffer.putColorRGBA(buffer.getColorIndex(i), 255, 255, 255, (int) (alpha * 255)); } tes.draw(); } GlStateManager.alphaFunc(alphaFunc, alphaRef); // GlStateManager.enableDepth(); GlStateManager.disablePolygonOffset(); GlStateManager.color(1F, 1F, 1F, 1F); GlStateManager.popMatrix(); }
Example 9
Source File: ParticleRenderer.java From Logistics-Pipes-2 with MIT License | 4 votes |
public void renderParticles(EntityPlayer aPlayer, float pTicks) { float f = ActiveRenderInfo.getRotationX(); float f1 = ActiveRenderInfo.getRotationZ(); float f2 = ActiveRenderInfo.getRotationYZ(); float f3 = ActiveRenderInfo.getRotationXY(); float f4 = ActiveRenderInfo.getRotationXZ(); EntityPlayer player = Minecraft.getMinecraft().player; if(player!=null) { Particle.interpPosX = player.lastTickPosX + (player.posX - player.lastTickPosX) * pTicks; Particle.interpPosY = player.lastTickPosY + (player.posY - player.lastTickPosY) * pTicks; Particle.interpPosZ = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * pTicks; Particle.cameraViewDir = player.getLook(pTicks); GlStateManager.enableAlpha(); GlStateManager.enableBlend(); GlStateManager.alphaFunc(516, 0.003921569F); GlStateManager.disableCull(); GlStateManager.depthMask(false); Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); Tessellator tess = Tessellator.getInstance(); VertexBuffer buffer = tess.getBuffer(); GlStateManager.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA); buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.PARTICLE_POSITION_TEX_COLOR_LMAP); for(int i = 0; i < particles.size(); i ++) { if(!((ILP2Particle) particles.get(i)).isAdditive()) { particles.get(i).renderParticle(buffer, player, pTicks, f, f4, f1, f2, f3); } } tess.draw(); GlStateManager.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE); buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.PARTICLE_POSITION_TEX_COLOR_LMAP); for(int i = 0; i < particles.size(); i ++) { if(((ILP2Particle) particles.get(i)).isAdditive()) { particles.get(i).renderParticle(buffer, player, pTicks, f, f4, f1, f2, f3); } } tess.draw(); GlStateManager.enableCull(); GlStateManager.depthMask(true); GlStateManager.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA); GlStateManager.disableBlend(); GlStateManager.alphaFunc(516, 0.1F); } }
Example 10
Source File: TileEntityRendererEnergyBridge.java From enderutilities with GNU Lesser General Public License v3.0 | 4 votes |
public void renderBeamVertical(double x, double y, double z, double yMin, double yMax, double radius, double rot, double flowSpeed, boolean powered) { Tessellator tessellator = Tessellator.getInstance(); BufferBuilder vertexBuffer = tessellator.getBuffer(); double tx1 = 0.0d, tx2 = 0.0d; double tz1 = 0.0d, tz2 = 0.0d; double angle = 0.0d; double vScale = yMax - yMin; double v1 = -rot * flowSpeed; double v2 = (vScale * 2.0d) + v1; int r_i = (powered ? 160 : 255); int g_i = (powered ? 255 : 160); int b_i = (powered ? 230 : 160); int r_o = (powered ? 210 : 255); int g_o = (powered ? 255 : 160); int b_o = (powered ? 230 : 160); GlStateManager.alphaFunc(GL11.GL_GREATER, 0.1F); GlStateManager.pushMatrix(); GlStateManager.translate(x, y, z); this.bindTexture(TEXTURE); GlStateManager.disableFog(); GlStateManager.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, 10497); GlStateManager.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, 10497); GlStateManager.disableLighting(); GlStateManager.disableCull(); GlStateManager.disableBlend(); GlStateManager.depthMask(true); GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO); // Beam (inner part) vertexBuffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_COLOR); for (int i = 0; i < 8; ++i) { tx1 = Math.sin(rot + angle) * radius; tz1 = Math.cos(rot + angle) * radius; angle += Math.PI / 4.0d; tx2 = Math.sin(rot + angle) * radius; tz2 = Math.cos(rot + angle) * radius; vertexBuffer.pos(tx1, yMin, tz1).tex(0.125, v1).color(r_i, g_i, b_i, 200).endVertex(); vertexBuffer.pos(tx1, yMax, tz1).tex(0.125, v2).color(r_i, g_i, b_i, 200).endVertex(); vertexBuffer.pos(tx2, yMax, tz2).tex(0.875, v2).color(r_i, g_i, b_i, 200).endVertex(); vertexBuffer.pos(tx2, yMin, tz2).tex(0.875, v1).color(r_i, g_i, b_i, 200).endVertex(); } tessellator.draw(); // Glow (outer part) GlStateManager.enableBlend(); GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO); GlStateManager.depthMask(false); v1 = -rot * flowSpeed * 3.0d; v2 = (vScale * 2.0d) + v1; radius *= 2.0d; rot = Math.PI / 8.0d; vertexBuffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_COLOR); for (int i = 0; i < 8; ++i) { tx1 = Math.sin(rot + angle) * radius; tz1 = Math.cos(rot + angle) * radius; angle += Math.PI / 4.0d; tx2 = Math.sin(rot + angle) * radius; tz2 = Math.cos(rot + angle) * radius; vertexBuffer.pos(tx1, yMin, tz1).tex(0.125, v1).color(r_o, g_o, b_o, 80).endVertex(); vertexBuffer.pos(tx1, yMax, tz1).tex(0.125, v2).color(r_o, g_o, b_o, 80).endVertex(); vertexBuffer.pos(tx2, yMax, tz2).tex(0.875, v2).color(r_o, g_o, b_o, 80).endVertex(); vertexBuffer.pos(tx2, yMin, tz2).tex(0.875, v1).color(r_o, g_o, b_o, 80).endVertex(); } tessellator.draw(); GlStateManager.enableLighting(); GlStateManager.enableTexture2D(); GlStateManager.depthMask(true); GlStateManager.enableFog(); GlStateManager.popMatrix(); }
Example 11
Source File: RenderEventHandler.java From enderutilities with GNU Lesser General Public License v3.0 | 4 votes |
protected void renderLabel(String text, double x, double y, double z, float angleH, float angleV) { boolean flag = false; // sneaking FontRenderer fontrenderer = this.mc.fontRenderer; GlStateManager.alphaFunc(GL11.GL_GREATER, 0.1F); GlStateManager.pushMatrix(); GlStateManager.translate(x, y, z); GlStateManager.glNormal3f(0.0F, 1.0F, 0.0F); GlStateManager.rotate(-angleH, 0.0F, 1.0F, 0.0F); GlStateManager.rotate(-angleV, 1.0F, 0.0F, 0.0F); GlStateManager.scale(-0.025F, -0.025F, 0.025F); GlStateManager.disableLighting(); GlStateManager.depthMask(false); GlStateManager.disableDepth(); GlStateManager.enableBlend(); GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO); GlStateManager.disableTexture2D(); Tessellator tessellator = Tessellator.getInstance(); BufferBuilder vertexbuffer = tessellator.getBuffer(); int strLenHalved = fontrenderer.getStringWidth(text) / 2; vertexbuffer.begin(7, DefaultVertexFormats.POSITION_COLOR); vertexbuffer.pos(-strLenHalved - 1, -1, 0.0D).color(0.0F, 0.0F, 0.0F, 0.25F).endVertex(); vertexbuffer.pos(-strLenHalved - 1, 8, 0.0D).color(0.0F, 0.0F, 0.0F, 0.25F).endVertex(); vertexbuffer.pos( strLenHalved + 1, 8, 0.0D).color(0.0F, 0.0F, 0.0F, 0.25F).endVertex(); vertexbuffer.pos( strLenHalved + 1, -1, 0.0D).color(0.0F, 0.0F, 0.0F, 0.25F).endVertex(); tessellator.draw(); GlStateManager.enableTexture2D(); fontrenderer.drawString(text, -strLenHalved, 0, 0x20FFFFFF); GlStateManager.enableDepth(); GlStateManager.depthMask(true); fontrenderer.drawString(text, -strLenHalved, 0, flag ? 0x20FFFFFF : 0xFFFFFFFF); GlStateManager.disableBlend(); GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); GlStateManager.popMatrix(); }