Java Code Examples for net.minecraft.client.renderer.GlStateManager#disableLighting()

The following examples show how to use net.minecraft.client.renderer.GlStateManager#disableLighting() . 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: OverlayRenderer.java    From YouTubeModdingTutorial with MIT License 6 votes vote down vote up
@SubscribeEvent
public void renderGameOverlayEvent(RenderGameOverlayEvent event) {
    if (event.isCancelable() || event.getType() != RenderGameOverlayEvent.ElementType.EXPERIENCE) {
        return;
    }

    if (Minecraft.getMinecraft().player.getHeldItem(EnumHand.MAIN_HAND).getItem() != ModItems.itemWand) {
        return;
    }

    GlStateManager.disableLighting();

    FontRenderer fontRenderer = Minecraft.getMinecraft().fontRenderer;

    int x = 200;
    int y = 10;
    x = fontRenderer.drawString("Mana ", x, y, 0xffffffff);
    x = fontRenderer.drawString("" + mana, x, y, 0xffff0000);
    x = fontRenderer.drawString("  Influence ", x, y, 0xffffffff);
    x = fontRenderer.drawString("" + manaInfluence, x, y, 0xffff0000);
    y += 10;
    x = 200;
    x = fontRenderer.drawString("Player ", x, y, 0xffffffff);
    x = fontRenderer.drawString("" + (playerMana), x, y, 0xffff0000);
}
 
Example 2
Source File: BloodRenderLayer.java    From Wizardry with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void doRenderLayer(@Nonnull AbstractClientPlayer entity, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale) {
	if (Minecraft.getMinecraft().player == null || Minecraft.getMinecraft().world == null) return;

	IManaCapability cap = ManaCapabilityProvider.getCap(entity);
	if (cap != null) {
		EnumBloodType type = cap.getBloodType();
		if (type != null && type != EnumBloodType.NONE) {
			render.bindTexture(EnumBloodType.getResourceLocation(type));
			ClientUtilMethods.glColor(type.color);
			setModelVisibilities(entity);
			GlStateManager.enableBlendProfile(Profile.PLAYER_SKIN);

			GlStateManager.disableLighting();
			ShaderHelper.INSTANCE.useShader(Shaders.rawColor);

			render.getMainModel().render(entity, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale);

			GlStateManager.enableLighting();
			ShaderHelper.INSTANCE.releaseShader();

			GlStateManager.disableBlendProfile(Profile.PLAYER_SKIN);
			GlStateManager.color(1.0F, 1.0F, 1.0F);
		}
	}
}
 
Example 3
Source File: GuiComponentItemStackSpinner.java    From OpenModsLib with MIT License 6 votes vote down vote up
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 4
Source File: LayoutStyleMinecraft.java    From NotEnoughItems with MIT License 5 votes vote down vote up
@Override
public void drawButton(Button b, int mousex, int mousey) {
    GlStateManager.disableLighting();
    GlStateManager.color(1, 1, 1, 1);

    int tex;
    if ((b.state & 0x3) == 2) {
        tex = 0;
    } else if ((b.state & 0x4) == 0 && b.contains(mousex, mousey) ||//not a state button and mouseover
            (b.state & 0x3) == 1)//state active
    {
        tex = 2;
    } else {
        tex = 1;
    }
    LayoutManager.drawButtonBackground(b.x, b.y, b.w, b.h, true, tex);

    Rectangle4i icon = b.getRenderIcon();
    if (icon == null) {
        int colour = tex == 2 ? 0xffffa0 : tex == 0 ? 0x601010 : 0xe0e0e0;

        drawStringC(b.getRenderLabel(), b.x + b.w / 2, b.y + (b.h - 8) / 2, colour);
    } else {
        GlStateManager.color(1, 1, 1, 1);

        int iconx = b.x + (b.w - icon.w) / 2;
        int icony = b.y + (b.h - icon.h) / 2;
        LayoutManager.drawIcon(iconx, icony, icon);
    }
}
 
Example 5
Source File: SurfaceHelper.java    From ForgeHax with MIT License 5 votes vote down vote up
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 6
Source File: SurfaceBuilder.java    From ForgeHax with MIT License 5 votes vote down vote up
public static void enableItemRendering() {
  RenderHelper.enableGUIStandardItemLighting();
  GlStateManager.disableLighting();
  GlStateManager.enableRescaleNormal();
  GlStateManager.enableColorMaterial();
  GlStateManager.enableLighting();
}
 
Example 7
Source File: WorldProviderUnderWorld.java    From Wizardry with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public void render(float partialTicks, WorldClient world, Minecraft mc) {
	EntityPlayer p = Minecraft.getMinecraft().player;
	if (p != null) {
		if (p.getEntityWorld().provider instanceof WorldProviderUnderWorld) {
			ResourceLocation sides = new ResourceLocation(Wizardry.MODID, "textures/misc/underworld_sky.png");
			ResourceLocation top = new ResourceLocation(Wizardry.MODID, "textures/misc/underworld_sky_top.png");
			ResourceLocation bottom = new ResourceLocation(Wizardry.MODID, "textures/misc/underworld_sky_bottom.png");
			Minecraft.getMinecraft().renderEngine.bindTexture(sides);
			GlStateManager.pushMatrix();
			GlStateManager.disableCull();
			GlStateManager.disableFog();
			GlStateManager.disableLighting();

			GlStateManager.depthMask(false);
			Tessellator tessellator = Tessellator.getInstance();
			BufferBuilder vertexbuffer = tessellator.getBuffer();

			for (int i = 0; i < 6; ++i) {
				GlStateManager.pushMatrix();

				Minecraft.getMinecraft().renderEngine.bindTexture(bottom);
				if (i == 3) {
					Minecraft.getMinecraft().renderEngine.bindTexture(top);
					GlStateManager.rotate(180.0F, 1.0F, 0.0F, 0.0F);
				}
				if (i == 1) {
					Minecraft.getMinecraft().renderEngine.bindTexture(sides);
					GlStateManager.rotate(90.0F, 1.0F, 0.0F, 0.0F);
				}
				if (i == 2) {
					Minecraft.getMinecraft().renderEngine.bindTexture(sides);
					GlStateManager.rotate(-90.0F, 1.0F, 0.0F, 0.0F);
					GlStateManager.rotate(180.0F, 0.0F, 1.0F, 0.0F);
				}
				if (i == 4) {
					Minecraft.getMinecraft().renderEngine.bindTexture(sides);
					GlStateManager.rotate(90.0F, 0.0F, 0.0F, 1.0F);
					GlStateManager.rotate(270.0F, 0.0F, 1.0F, 0.0F);
				}
				if (i == 5) {
					Minecraft.getMinecraft().renderEngine.bindTexture(sides);
					GlStateManager.rotate(-90.0F, 0.0F, 0.0F, 1.0F);
					GlStateManager.rotate(-270.0F, 0.0F, 1.0F, 0.0F);
				}

				vertexbuffer.begin(7, DefaultVertexFormats.POSITION_TEX);
				vertexbuffer.pos(-100.0D, -100.0D, -100.0D).tex(0.0D, 0.0D).endVertex();
				vertexbuffer.pos(-100.0D, -100.0D, 100.0D).tex(0.0D, 1.0D).endVertex();
				vertexbuffer.pos(100.0D, -100.0D, 100.0D).tex(1.0D, 1.0D).endVertex();
				vertexbuffer.pos(100.0D, -100.0D, -100.0D).tex(1.0D, 0.0D).endVertex();
				tessellator.draw();
				GlStateManager.popMatrix();
			}

			GlStateManager.depthMask(true);
			GlStateManager.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA);
			GlStateManager.enableCull();
			GlStateManager.enableLighting();
			GlStateManager.disableAlpha();
			GlStateManager.enableFog();
			GlStateManager.disableBlend();
			GlStateManager.popMatrix();
		}
	}
}
 
Example 8
Source File: YeetHandler.java    From Hyperium with GNU Lesser General Public License v3.0 4 votes vote down vote up
@InvokeEvent
public void render(RenderEntitiesEvent event) {
    for (Yeet yeet : yeets) {
        RenderManager renderManager = Minecraft.getMinecraft().getRenderManager();
        FontRenderer fontrenderer = renderManager.getFontRenderer();
        float f = 1.6F;
        float f1 = 0.016666668F * f;
        GlStateManager.pushMatrix();
        EntityPlayerSP entity = Minecraft.getMinecraft().thePlayer;
        float partialTicks = event.getPartialTicks();

        double d0 = entity.lastTickPosX + (entity.posX - entity.lastTickPosX) * (double) partialTicks;
        double d1 = entity.lastTickPosY + (entity.posY - entity.lastTickPosY) * (double) partialTicks;
        double d2 = entity.lastTickPosZ + (entity.posZ - entity.lastTickPosZ) * (double) partialTicks;

        EntityPlayer sender = yeet.sender;
        if (sender == null) continue;
        double e0 = yeet.sender.lastTickPosX + (yeet.sender.posX - yeet.sender.lastTickPosX) * (double) partialTicks;
        double e1 = yeet.sender.lastTickPosY + (yeet.sender.posY - yeet.sender.lastTickPosY) * (double) partialTicks;
        double e2 = yeet.sender.lastTickPosZ + (yeet.sender.posZ - yeet.sender.lastTickPosZ) * (double) partialTicks;


        GlStateManager.translate(e0 - d0, e1 - d1, e2 - d2);
        GlStateManager.translate(0, 3, 0);

        GL11.glNormal3f(0.0F, 1.0F, 0.0F);
        GlStateManager.rotate(-renderManager.playerViewY, 0.0F, 1.0F, 0.0F);

        int xMultiplier = 1; // Nametag x rotations should flip in front-facing 3rd person

        if (Minecraft.getMinecraft() != null && Minecraft.getMinecraft().gameSettings != null && Minecraft.getMinecraft().gameSettings.thirdPersonView == 2) {
            xMultiplier = -1;
        }

        GlStateManager.rotate(renderManager.playerViewX * xMultiplier, 1.0F, 0.0F, 0.0F);
        GlStateManager.scale(-f1, -f1, f1);
        GlStateManager.disableLighting();
        GlStateManager.depthMask(false);
        GlStateManager.disableDepth();
        GlStateManager.enableBlend();
        GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ZERO);
        Tessellator tessellator = Tessellator.getInstance();
        WorldRenderer worldrenderer = tessellator.getWorldRenderer();
        int i = 0;

        String string = "YEET";
        int j = fontrenderer.getStringWidth(string) / 2;
        GlStateManager.disableTexture2D();
        GlStateManager.scale(4, 4, 4);
        worldrenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR);
        worldrenderer.pos(-j - 1, -1 + i, 0.0D).color(0.0F, 0.0F, 0.0F, 0.25F).endVertex();
        worldrenderer.pos(-j - 1, 8 + i, 0.0D).color(0.0F, 0.0F, 0.0F, 0.25F).endVertex();
        worldrenderer.pos(j + 1, 8 + i, 0.0D).color(0.0F, 0.0F, 0.0F, 0.25F).endVertex();
        worldrenderer.pos(j + 1, -1 + i, 0.0D).color(0.0F, 0.0F, 0.0F, 0.25F).endVertex();
        tessellator.draw();
        GlStateManager.enableTexture2D();

        fontrenderer.drawString(string, -j, 0, 16777215, true);
        GlStateManager.enableLighting();
        GlStateManager.disableBlend();
        GlStateManager.depthMask(true);
        GlStateManager.enableDepth();
        GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
        GlStateManager.popMatrix();
    }
}
 
Example 9
Source File: BlockInfo.java    From litematica with GNU Lesser General Public License v3.0 4 votes vote down vote up
public void render(int x, int y, int zLevel, Minecraft mc)
{
    if (this.state != null)
    {
        GlStateManager.pushMatrix();

        RenderUtils.drawOutlinedBox(x, y, this.totalWidth, this.totalHeight, 0xFF000000, GuiBase.COLOR_HORIZONTAL_BAR, zLevel);

        FontRenderer textRenderer = mc.fontRenderer;
        int x1 = x + 10;
        y += 4;

        textRenderer.drawString(this.title, x1, y, 0xFFFFFFFF);

        y += 12;

        GlStateManager.disableLighting();
        RenderUtils.enableGuiItemLighting();

        RenderUtils.drawRect(x1, y, 16, 16, 0x20FFFFFF, zLevel); // light background for the item

        float origZ = mc.getRenderItem().zLevel;
        mc.getRenderItem().zLevel = zLevel + 1;
        mc.getRenderItem().renderItemAndEffectIntoGUI(mc.player, this.stack, x1, y);
        mc.getRenderItem().renderItemOverlayIntoGUI(textRenderer, this.stack, x1, y, null);
        mc.getRenderItem().zLevel = origZ;

        //GlStateManager.disableBlend();
        RenderUtils.disableItemLighting();

        textRenderer.drawString(this.stackName, x1 + 20, y + 4, 0xFFFFFFFF);

        y += 20;
        textRenderer.drawString(this.blockRegistryname, x1, y, 0xFF4060FF);
        y += textRenderer.FONT_HEIGHT + 4;

        RenderUtils.renderText(x1, y, 0xFFB0B0B0, this.props);

        GlStateManager.popMatrix();
    }
}
 
Example 10
Source File: SurfaceHelper.java    From ForgeHax with MIT License 4 votes vote down vote up
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 11
Source File: GuiContainerLargeStacks.java    From enderutilities with GNU Lesser General Public License v3.0 4 votes vote down vote up
public void renderLargeStackItemOverlayIntoGUI(FontRenderer fontRenderer, ItemStack stack, int xPosition, int yPosition)
{
    if (stack.isEmpty())
    {
        return;
    }

    if (stack.getCount() != 1)
    {
        String str = EUStringUtils.getStackSizeString(stack, 4);

        if (stack.getCount() < 1)
        {
            str = TextFormatting.RED + str;
        }

        GlStateManager.disableLighting();
        GlStateManager.disableDepth();
        GlStateManager.disableBlend();

        GlStateManager.pushMatrix();
        GlStateManager.translate(xPosition, yPosition, 0.0d);
        GlStateManager.scale(0.5d, 0.5d, 0.5d);

        fontRenderer.drawStringWithShadow(str, (31 - fontRenderer.getStringWidth(str)), 23, 0xFFFFFF);

        GlStateManager.popMatrix();

        GlStateManager.enableLighting();
        GlStateManager.enableDepth();
    }

    if (stack.getItem().showDurabilityBar(stack))
    {
        double health = stack.getItem().getDurabilityForDisplay(stack);
        int j = (int)Math.round(13.0D - health * 13.0D);
        int i = (int)Math.round(255.0D - health * 255.0D);

        GlStateManager.disableLighting();
        GlStateManager.disableDepth();
        GlStateManager.disableTexture2D();
        GlStateManager.disableAlpha();
        GlStateManager.disableBlend();

        Tessellator tessellator = Tessellator.getInstance();
        BufferBuilder vertexBuffer = tessellator.getBuffer();

        this.drawQuad(vertexBuffer, xPosition + 2, yPosition + 13, 13, 2, 0, 0, 0, 255);
        this.drawQuad(vertexBuffer, xPosition + 2, yPosition + 13, 12, 1, (255 - i) / 4, 64, 0, 255);
        this.drawQuad(vertexBuffer, xPosition + 2, yPosition + 13, j, 1, 255 - i, i, 0, 255);

        GlStateManager.enableAlpha();
        GlStateManager.enableTexture2D();
        GlStateManager.enableLighting();
        GlStateManager.enableDepth();
    }
}
 
Example 12
Source File: TemplateRecipeHandler.java    From NotEnoughItems with MIT License 4 votes vote down vote up
public void drawForeground(int recipe) {
    GlStateManager.color(1, 1, 1, 1);
    GlStateManager.disableLighting();
    changeTexture(getGuiTexture());
    drawExtras(recipe);
}
 
Example 13
Source File: RendererBackpack.java    From WearableBackpacks with MIT License 4 votes vote down vote up
private static void renderEnchanted(IBackpack backpack, BlockModelRenderer renderer,
                                    float ticks, boolean renderStraps) {
	
	Minecraft mc = Minecraft.getMinecraft();
	float glintStrength = WearableBackpacks.CONFIG.cosmetic.enchantEffectOpacity.get().floatValue();
	if (glintStrength <= 0) return;
	float glintScale   = 1.5F;
	float animProgress = ticks / 10;
	
	int color = IntermodUtils.getRuneColor(backpack.getStack());
	float r = (color >> 16 & 0xFF) / 255.0F * glintStrength;
	float g = (color >>  8 & 0xFF) / 255.0F * glintStrength;
	float b = (color       & 0xFF) / 255.0F * glintStrength;
	
	mc.getTextureManager().bindTexture(ENCHANTED_ITEM_GLINT);
	mc.entityRenderer.setupFogColor(true);
	
	GlStateManager.disableLighting();
	GlStateManager.depthMask(false);
	GlStateManager.depthFunc(GL11.GL_EQUAL);
	GlStateManager.enableBlend();
	GlStateManager.blendFunc(GlStateManager.SourceFactor.SRC_COLOR, GlStateManager.DestFactor.ONE);
	
	for (int i = 0; i < 2; ++i) {
		GlStateManager.matrixMode(GL11.GL_TEXTURE);
		GlStateManager.loadIdentity();
		GlStateManager.scale(glintScale, glintScale, glintScale);
		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);
		renderModel(backpack, renderer, ticks, renderStraps, r, g, b, true);
	}
	
	GlStateManager.matrixMode(GL11.GL_TEXTURE);
	GlStateManager.loadIdentity();
	GlStateManager.matrixMode(GL11.GL_MODELVIEW);
	
	GlStateManager.blendFunc(GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
	GlStateManager.disableBlend();
	GlStateManager.depthFunc(GL11.GL_LEQUAL);
	GlStateManager.depthMask(true);
	GlStateManager.enableLighting();
	
	mc.entityRenderer.setupFogColor(false);
	
}
 
Example 14
Source File: WorldProviderTorikki.java    From Wizardry with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public void render(float partialTicks, WorldClient world, Minecraft mc) {
	EntityPlayer p = Minecraft.getMinecraft().player;
	if (p != null) {
		if (p.getEntityWorld().provider instanceof WorldProviderTorikki) {
			ResourceLocation img = new ResourceLocation(Wizardry.MODID, "textures/misc/torikki_sky.png");
			Minecraft.getMinecraft().renderEngine.bindTexture(img);
			GlStateManager.pushMatrix();
			GlStateManager.disableCull();
			GlStateManager.disableFog();
			GlStateManager.disableLighting();

			GlStateManager.depthMask(false);
			Tessellator tessellator = Tessellator.getInstance();
			BufferBuilder vertexbuffer = tessellator.getBuffer();

			for (int i = 0; i < 6; ++i) {
				GlStateManager.pushMatrix();

				Minecraft.getMinecraft().renderEngine.bindTexture(img);
				if (i == 3) {
					Minecraft.getMinecraft().renderEngine.bindTexture(img);
					GlStateManager.rotate(180.0F, 1.0F, 0.0F, 0.0F);
				}
				if (i == 1) {
					Minecraft.getMinecraft().renderEngine.bindTexture(img);
					GlStateManager.rotate(90.0F, 1.0F, 0.0F, 0.0F);
				}
				if (i == 2) {
					Minecraft.getMinecraft().renderEngine.bindTexture(img);
					GlStateManager.rotate(-90.0F, 1.0F, 0.0F, 0.0F);
					GlStateManager.rotate(180.0F, 0.0F, 1.0F, 0.0F);
				}
				if (i == 4) {
					Minecraft.getMinecraft().renderEngine.bindTexture(img);
					GlStateManager.rotate(90.0F, 0.0F, 0.0F, 1.0F);
					GlStateManager.rotate(270.0F, 0.0F, 1.0F, 0.0F);
				}
				if (i == 5) {
					Minecraft.getMinecraft().renderEngine.bindTexture(img);
					GlStateManager.rotate(-90.0F, 0.0F, 0.0F, 1.0F);
					GlStateManager.rotate(-270.0F, 0.0F, 1.0F, 0.0F);
				}

				vertexbuffer.begin(7, DefaultVertexFormats.POSITION_TEX);
				vertexbuffer.pos(-100.0D, -100.0D, -100.0D).tex(0.0D, 0.0D).endVertex();
				vertexbuffer.pos(-100.0D, -100.0D, 100.0D).tex(0.0D, 1.0D).endVertex();
				vertexbuffer.pos(100.0D, -100.0D, 100.0D).tex(1.0D, 1.0D).endVertex();
				vertexbuffer.pos(100.0D, -100.0D, -100.0D).tex(1.0D, 0.0D).endVertex();
				tessellator.draw();
				GlStateManager.popMatrix();
			}

			GlStateManager.depthMask(true);
			GlStateManager.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA);
			GlStateManager.enableCull();
			GlStateManager.enableLighting();
			GlStateManager.disableAlpha();
			GlStateManager.enableFog();
			GlStateManager.disableBlend();
			GlStateManager.popMatrix();
		}
	}
}
 
Example 15
Source File: RenderUtils.java    From enderutilities with GNU Lesser General Public License v3.0 4 votes vote down vote up
public static void renderEntityDebugBoundingBox(Entity entityIn, float partialTicks, boolean renderLook, boolean renderEyeHeight)
{
    Entity renderViewEntity = Minecraft.getMinecraft().getRenderViewEntity();
    double x = entityIn.lastTickPosX + (entityIn.posX - entityIn.lastTickPosX) * (double)partialTicks;
    double y = entityIn.lastTickPosY + (entityIn.posY - entityIn.lastTickPosY) * (double)partialTicks;
    double z = entityIn.lastTickPosZ + (entityIn.posZ - entityIn.lastTickPosZ) * (double)partialTicks;
    x -= renderViewEntity.lastTickPosX + (renderViewEntity.posX - renderViewEntity.lastTickPosX) * (double)partialTicks;
    y -= renderViewEntity.lastTickPosY + (renderViewEntity.posY - renderViewEntity.lastTickPosY) * (double)partialTicks;
    z -= renderViewEntity.lastTickPosZ + (renderViewEntity.posZ - renderViewEntity.lastTickPosZ) * (double)partialTicks;

    GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
    GlStateManager.depthMask(false);
    GlStateManager.disableTexture2D();
    GlStateManager.disableLighting();
    GlStateManager.disableCull();
    GlStateManager.disableBlend();
    GlStateManager.glLineWidth(1.0F);

    double entityRadius = entityIn.width / 2.0D;
    AxisAlignedBB bb = entityIn.getEntityBoundingBox();

    RenderGlobal.drawBoundingBox(bb.minX - entityIn.posX + x,
                                 bb.minY - entityIn.posY + y,
                                 bb.minZ - entityIn.posZ + z,
                                 bb.maxX - entityIn.posX + x,
                                 bb.maxY - entityIn.posY + y,
                                 bb.maxZ - entityIn.posZ + z,
                                 1.0F, 1.0F, 1.0F, 1.0F);

    if (renderEyeHeight && entityIn instanceof EntityLivingBase)
    {
        RenderGlobal.drawBoundingBox(x - entityRadius,
                                     y + entityIn.getEyeHeight() - 0.01D,
                                     z - entityRadius,
                                     x + entityRadius,
                                     y + entityIn.getEyeHeight() + 0.01D,
                                     z + entityRadius, 1.0F, 0.0F, 0.0F, 1.0F);
    }

    if (renderLook)
    {
        Tessellator tessellator = Tessellator.getInstance();
        BufferBuilder vertexbuffer = tessellator.getBuffer();
        Vec3d look = entityIn.getLook(partialTicks);
        vertexbuffer.begin(3, DefaultVertexFormats.POSITION_COLOR);
        vertexbuffer.pos(x, y + entityIn.getEyeHeight(), z).color(0, 0, 255, 255).endVertex();
        vertexbuffer.pos(x + look.x * 2.0D, y + entityIn.getEyeHeight() + look.y * 2.0D, z + look.z * 2.0D).color(0, 0, 255, 255).endVertex();
        tessellator.draw();
    }

    GlStateManager.enableTexture2D();
    GlStateManager.enableLighting();
    GlStateManager.enableCull();
    GlStateManager.disableBlend();
    GlStateManager.depthMask(true);
}
 
Example 16
Source File: FontUtils.java    From CodeChickenLib with GNU Lesser General Public License v2.1 4 votes vote down vote up
public static void drawItemQuantity(int x, int y, ItemStack item, String quantity, int mode)
{
    if(item == null || (quantity == null && item.stackSize <= 1))
        return;
    
    if(quantity == null)
    {
        switch(mode)
        {
            case 2:
                int q = item.stackSize;
                String postfix = "";
                for(int p = 0; p < 3 && q > 1000; p++)
                {
                    q/=1000;
                    postfix = prefixes[p];
                }
                quantity = Integer.toString(q)+postfix;
            break;
            case 1:
                quantity = "";
                if(item.stackSize/64 > 0)
                    quantity+=item.stackSize/64 + "s";
                if(item.stackSize%64 > 0)
                    quantity+=item.stackSize%64;
            break;
            default:
                quantity = Integer.toString(item.stackSize);
            break;
        }
    }
    
    double scale = quantity.length() > 2 ? 0.5 : 1;
    double sheight = 8*scale;
    double swidth = fontRenderer.getStringWidth(quantity)*scale;

    GlStateManager.disableLighting();
    GlStateManager.disableDepth();
    GlStateManager.pushMatrix();
        GlStateManager.translate(x + 16 - swidth, y + 16 - sheight, 0);
        GlStateManager.scale(scale, scale, 1);
        fontRenderer.drawStringWithShadow(quantity, 0, 0, 0xFFFFFF);
    GlStateManager.popMatrix();
    GlStateManager.enableLighting();
    GlStateManager.enableDepth();
}
 
Example 17
Source File: TileEntityPhysicsInfuserRenderer.java    From Valkyrien-Skies with Apache License 2.0 4 votes vote down vote up
@Override
public void render(TileEntityPhysicsInfuser tileentity, double x, double y, double z,
    float partialTick,
    int destroyStage, float alpha) {

    this.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
    GlStateManager.pushMatrix();
    GlStateManager.disableLighting();

    GlStateManager.translate(x, y, z);
    GlStateManager.disableAlpha();
    GlStateManager.disableBlend();
    GlStateManager.pushMatrix();

    int brightness = tileentity.getWorld()
        .getCombinedLight(tileentity.getPos(), 0);

    GlStateManager.translate(.5, 0, .5);
    double keyframe = 1;

    IBlockState physicsInfuserState = ValkyrienSkiesMod.INSTANCE.physicsInfuser
        .getStateFromMeta(tileentity.getBlockMetadata());
    EnumFacing enumfacing = physicsInfuserState.getValue(BlockPhysicsInfuser.FACING);
    int coreBrightness =
        physicsInfuserState.getValue(BlockPhysicsInfuser.INFUSER_LIGHT_ON) ? 15728864
            : brightness;
    float physicsInfuserRotation = -enumfacing.getHorizontalAngle() + 180;
    GlStateManager.rotate(physicsInfuserRotation, 0, 1, 0);

    GlStateManager.translate(-.5, 0, -.5);

    // First translate the model one block to the right
    GlStateManager.translate(-1, 0, 0);
    GlStateManager.scale(2, 2, 2);
    GibsAnimationRegistry.getAnimation("physics_infuser_empty")
        .renderAnimation(keyframe, brightness);

    IAtomAnimation cores_animation = GibsAnimationRegistry
        .getAnimation("physics_infuser_cores");
    // Render only the cores that exist within the physics infuser's inventory.
    IItemHandler handler = tileentity
        .getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null);

    for (TileEntityPhysicsInfuser.EnumInfuserCore infuserCore : TileEntityPhysicsInfuser.EnumInfuserCore
        .values()) {
        if (!handler.getStackInSlot(infuserCore.coreSlotIndex).isEmpty) {
            GlStateManager.pushMatrix();
            GlStateManager
                .translate(0, tileentity.getCoreVerticalOffset(infuserCore, partialTick), 0);
            cores_animation
                .renderAnimationNode(infuserCore.coreModelName, keyframe, coreBrightness);
            GlStateManager.popMatrix();
        }
    }

    GlStateManager.popMatrix();
    GlStateManager.popMatrix();
    GlStateManager.enableLighting();
    GlStateManager.resetColor();
}
 
Example 18
Source File: PropellerEngineTileEntityRenderer.java    From Valkyrien-Skies with Apache License 2.0 4 votes vote down vote up
@Override
public void render(TileEntityPropellerEngine tileentity, double x, double y, double z,
    float partialTick,
    int destroyStage, float alpha) {
    IBlockState state = tileentity.getWorld().getBlockState(tileentity.getPos());
    if (state.getBlock() instanceof BlockAirshipEngine) {
        EnumFacing facing = state.getValue(BlockAirshipEngine.FACING);

        IBlockState engineRenderState = getRenderState(state);
        IBlockState propellerRenderState = ValkyrienSkiesControl.INSTANCE.vsControlBlocks.shipWheel
            .getStateFromMeta(14);

        this.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
        GlStateManager.pushMatrix();
        GlStateManager.disableLighting();
        Tessellator tessellator = Tessellator.getInstance();
        BufferBuilder BufferBuilder = tessellator.getBuffer();

        double oldX = BufferBuilder.xOffset;
        double oldY = BufferBuilder.yOffset;
        double oldZ = BufferBuilder.zOffset;

        BufferBuilder.setTranslation(0, 0, 0);
        GL11.glTranslated(x, y, z);
        GlStateManager.disableAlpha();
        GlStateManager.disableBlend();

        int brightness = tileentity.getWorld().getCombinedLight(tileentity.getPos(), 0);

        // GL11.glScaled(1.2D, 1.2D, 1.2D);

        GL11.glTranslated(0.5D, 0.5D, 0.5D);

        switch (facing) {
            case UP:
                GL11.glRotated(-90, 1, 0, 0);
                break;
            case DOWN:
                GL11.glRotated(90, 1, 0, 0);
                break;
            case NORTH:
                GL11.glRotated(180, 0, 1, 0);
                break;
            case EAST:
                GL11.glRotated(90, 0, 1, 0);
                break;
            case SOUTH:
                GL11.glRotated(0, 0, 1, 0);
                break;
            case WEST:
                GL11.glRotated(270, 0, 1, 0);
                break;

        }

        GL11.glTranslated(-0.5D, -0.5D, -0.5D);

        FastBlockModelRenderer.renderBlockModel(tessellator, tileentity.getWorld(),
            engineRenderState, brightness);

        GL11.glPushMatrix();

        GL11.glTranslated(0.5D, 0.214D, 0.5D);
        GL11.glRotated(tileentity.getPropellerAngle(partialTick), 0, 0, 1);
        GL11.glScaled(1.5D, 1.5D, 1);
        GL11.glTranslated(-0.5D, -0.214D, -0.5D);

        FastBlockModelRenderer.renderBlockModel(tessellator, tileentity.getWorld(),
            propellerRenderState, brightness);

        GL11.glPopMatrix();

        GL11.glPopMatrix();

        BufferBuilder.setTranslation(oldX, oldY, oldZ);
    }
}
 
Example 19
Source File: WorldOverlayRenderer.java    From NotEnoughItems with MIT License 4 votes vote down vote up
private static void renderChunkBounds(Entity entity) {
    if (chunkOverlay == 0) {
        return;
    }

    GlStateManager.disableTexture2D();
    GlStateManager.enableBlend();
    GlStateManager.blendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    GlStateManager.disableLighting();
    glLineWidth(1.5F);
    glBegin(GL_LINES);

    for (int cx = -4; cx <= 4; cx++) {
        for (int cz = -4; cz <= 4; cz++) {
            double x1 = (entity.chunkCoordX + cx) << 4;
            double z1 = (entity.chunkCoordZ + cz) << 4;
            double x2 = x1 + 16;
            double z2 = z1 + 16;

            double dy = 128;
            double y1 = Math.floor(entity.posY - dy / 2);
            double y2 = y1 + dy;
            if (y1 < 0) {
                y1 = 0;
                y2 = dy;
            }

            if (y1 > entity.world.getHeight()) {
                y2 = entity.world.getHeight();
                y1 = y2 - dy;
            }

            double dist = Math.pow(1.5, -(cx * cx + cz * cz));

            GlStateManager.color(0.9F, 0, 0, (float) dist);
            if (cx >= 0 && cz >= 0) {
                glVertex3d(x2, y1, z2);
                glVertex3d(x2, y2, z2);
            }
            if (cx >= 0 && cz <= 0) {
                glVertex3d(x2, y1, z1);
                glVertex3d(x2, y2, z1);
            }
            if (cx <= 0 && cz >= 0) {
                glVertex3d(x1, y1, z2);
                glVertex3d(x1, y2, z2);
            }
            if (cx <= 0 && cz <= 0) {
                glVertex3d(x1, y1, z1);
                glVertex3d(x1, y2, z1);
            }

            if (chunkOverlay == 2 && cx == 0 && cz == 0) {
                dy = 32;
                y1 = Math.floor(entity.posY - dy / 2);
                y2 = y1 + dy;
                if (y1 < 0) {
                    y1 = 0;
                    y2 = dy;
                }

                if (y1 > entity.world.getHeight()) {
                    y2 = entity.world.getHeight();
                    y1 = y2 - dy;
                }

                GlStateManager.color(0, 0.9F, 0, 0.4F);
                for (double y = (int) y1; y <= y2; y++) {
                    glVertex3d(x2, y, z1);
                    glVertex3d(x2, y, z2);
                    glVertex3d(x1, y, z1);
                    glVertex3d(x1, y, z2);
                    glVertex3d(x1, y, z2);
                    glVertex3d(x2, y, z2);
                    glVertex3d(x1, y, z1);
                    glVertex3d(x2, y, z1);
                }
                for (double h = 1; h <= 15; h++) {
                    glVertex3d(x1 + h, y1, z1);
                    glVertex3d(x1 + h, y2, z1);
                    glVertex3d(x1 + h, y1, z2);
                    glVertex3d(x1 + h, y2, z2);
                    glVertex3d(x1, y1, z1 + h);
                    glVertex3d(x1, y2, z1 + h);
                    glVertex3d(x2, y1, z1 + h);
                    glVertex3d(x2, y2, z1 + h);
                }
            }
        }
    }

    glEnd();
    GlStateManager.enableLighting();
    GlStateManager.disableBlend();
    GlStateManager.enableTexture2D();
}
 
Example 20
Source File: WorldOverlayRenderer.java    From NotEnoughItems with MIT License 4 votes vote down vote up
private static void renderMobSpawnOverlay(Entity entity) {
    if (mobOverlay == 0) {
        return;
    }

    boolean cms = Loader.instance().isModLoaded("customspawner");

    GlStateManager.disableTexture2D();
    GlStateManager.disableLighting();
    glLineWidth(1.5F);
    glBegin(GL_LINES);

    GlStateManager.color(1, 0, 0);

    World world = entity.world;
    int x1 = (int) entity.posX;
    int z1 = (int) entity.posZ;
    int y1 = (int) MathHelper.clip(entity.posY, 16, world.getHeight() - 16);

    for (int x = x1 - 16; x <= x1 + 16; x++) {
        for (int z = z1 - 16; z <= z1 + 16; z++) {
            BlockPos pos = new BlockPos(x, y1, z);
            Chunk chunk = world.getChunkFromBlockCoords(pos);
            Biome biome = world.getBiome(pos);
            if ((!cms && biome.getSpawnableList(EnumCreatureType.MONSTER).isEmpty()) || biome.getSpawningChance() <= 0) {
                continue;
            }

            for (int y = y1 - 16; y < y1 + 16; y++) {
                int spawnMode = getSpawnMode(chunk, x, y, z);
                if (spawnMode == 0) {
                    continue;
                }

                if (spawnMode == 1) {
                    GlStateManager.color(1, 1, 0);
                } else {
                    GlStateManager.color(1, 0, 0);
                }

                glVertex3d(x, y + 0.004, z);
                glVertex3d(x + 1, y + 0.004, z + 1);
                glVertex3d(x + 1, y + 0.004, z);
                glVertex3d(x, y + 0.004, z + 1);
            }
        }
    }

    glEnd();
    GlStateManager.enableLighting();
    GlStateManager.enableTexture2D();
}