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

The following examples show how to use net.minecraft.client.renderer.GlStateManager#enableRescaleNormal() . 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: GuiItemIconDumper.java    From NotEnoughItems with MIT License 6 votes vote down vote up
private void drawItems() {
    Dimension d = GuiDraw.getDisplayRes();

    GlStateManager.matrixMode(GL11.GL_PROJECTION);
    GlStateManager.loadIdentity();
    GlStateManager.ortho(0, d.width * 16D / iconSize, d.height * 16D / iconSize, 0, 1000, 3000);
    GlStateManager.matrixMode(GL11.GL_MODELVIEW);
    GlStateManager.clearColor(0, 0, 0, 0);
    GlStateManager.clear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);

    int rows = d.height / boxSize;
    int cols = d.width / boxSize;
    int fit = rows * cols;

    RenderHelper.enableGUIStandardItemLighting();
    GlStateManager.enableRescaleNormal();
    GlStateManager.color(1, 1, 1, 1);

    for (int i = 0; drawIndex < ItemPanel.items.size() && i < fit; drawIndex++, i++) {
        int x = i % cols * 18;
        int y = i / cols * 18;
        GuiHelper.drawItem(x + 1, y + 1, ItemPanel.items.get(drawIndex));
    }

    GL11.glFlush();
}
 
Example 2
Source File: GuiItemIconDumper.java    From NotEnoughItems with MIT License 6 votes vote down vote up
private void drawItems() {
    Dimension d = GuiDraw.displayRes();

    GlStateManager.matrixMode(GL11.GL_PROJECTION);
    GlStateManager.loadIdentity();
    GlStateManager.ortho(0, d.width*16D/iconSize, d.height*16D/iconSize, 0, 1000, 3000);
    GlStateManager.matrixMode(GL11.GL_MODELVIEW);
    GlStateManager.clearColor(0, 0, 0, 0);
    GlStateManager.clear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);

    int rows = d.height / boxSize;
    int cols = d.width / boxSize;
    int fit = rows*cols;

    RenderHelper.enableGUIStandardItemLighting();
    GlStateManager.enableRescaleNormal();
    GlStateManager.color(1, 1, 1, 1);

    for(int i = 0; drawIndex < ItemPanel.items.size() && i < fit; drawIndex++, i++) {
        int x = i%cols * 18;
        int y = i/cols * 18;
        GuiContainerManager.drawItem(x+1, y+1, ItemPanel.items.get(drawIndex));
    }

    GL11.glFlush();
}
 
Example 3
Source File: RenderEntityEnderPearl.java    From enderutilities with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void doRender(EntityEnderPearlReusable entity, double x, double y, double z, float entityYaw, float partialTicks)
{
    GlStateManager.pushMatrix();
    GlStateManager.translate((float)x, (float)y, (float)z);
    GlStateManager.enableRescaleNormal();
    GlStateManager.rotate(-this.renderManager.playerViewY, 0.0f, 1.0f, 0.0f);
    GlStateManager.rotate(this.renderManager.playerViewX, 1.0f, 0.0f, 0.0f);
    this.bindTexture(this.getEntityTexture(entity));

    this.renderItem.renderItem(this.getItemStack(entity), ItemCameraTransforms.TransformType.GROUND);

    GlStateManager.disableRescaleNormal();
    GlStateManager.popMatrix();
    super.doRender(entity, x, y, z, entityYaw, partialTicks);
}
 
Example 4
Source File: Widget.java    From GregTech with GNU Lesser General Public License v3.0 6 votes vote down vote up
@SideOnly(Side.CLIENT)
protected static void drawItemStack(ItemStack itemStack, int x, int y, @Nullable String altTxt) {
    GlStateManager.pushMatrix();
    GlStateManager.translate(0.0F, 0.0F, 32.0F);
    GlStateManager.color(1F, 1F, 1F, 1F);
    GlStateManager.enableRescaleNormal();
    GlStateManager.enableLighting();
    RenderHelper.enableGUIStandardItemLighting();
    OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240.0f, 240.0f);
    Minecraft mc = Minecraft.getMinecraft();
    RenderItem itemRender = mc.getRenderItem();
    itemRender.renderItemAndEffectIntoGUI(itemStack, x, y);
    itemRender.renderItemOverlayIntoGUI(mc.fontRenderer, itemStack, x, y, altTxt);
    GlStateManager.disableRescaleNormal();
    GlStateManager.disableLighting();
    GlStateManager.color(1F, 1F, 1F, 1F);
    GlStateManager.popMatrix();
    GlStateManager.enableBlend();
    GlStateManager.disableDepth();
}
 
Example 5
Source File: SurfaceHelper.java    From ForgeHax with MIT License 6 votes vote down vote up
public static void drawItemWithOverlay(ItemStack item, double x, double y, double scale) {
  GlStateManager.pushMatrix();
  RenderHelper.enableGUIStandardItemLighting();
  GlStateManager.disableLighting();
  GlStateManager.enableRescaleNormal();
  GlStateManager.enableColorMaterial();
  GlStateManager.enableLighting();
  MC.getRenderItem().zLevel = 100.f;
  renderItemAndEffectIntoGUI(getLocalPlayer(), item, x, y, 16.D);
  renderItemOverlayIntoGUI(MC.fontRenderer, item, x, y, null, scale);
  MC.getRenderItem().zLevel = 0.f;
  GlStateManager.popMatrix();
  GlStateManager.disableLighting();
  GlStateManager.enableDepth();
  GlStateManager.color(1.f, 1.f, 1.f, 1.f);
}
 
Example 6
Source File: LayerGnomeHeldBlock.java    From CommunityMod with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void doRenderLayer(GnomeType entitylivingbaseIn, float limbSwing,
		float limbSwingAmount, float partialTicks, float ageInTicks,
		float netHeadYaw, float headPitch, float scale)
{
       IBlockState iblockstate = entitylivingbaseIn.getCarried();

       if (iblockstate != null)
       {
           BlockRendererDispatcher blockrendererdispatcher = Minecraft.getMinecraft().getBlockRendererDispatcher();
           GlStateManager.enableRescaleNormal();
           GlStateManager.pushMatrix();
           GlStateManager.translate(0.25F, 1.125F, -0.25F);
           //GlStateManager.translate(0.0F, 0.6875F, -0.75F);
           GlStateManager.rotate(20.0F, 1.0F, 0.0F, 0.0F);
           //GlStateManager.rotate(45.0F, 0.0F, 1.0F, 0.0F);
           //GlStateManager.translate(0.25F, 0.1875F, 0.25F);
           GlStateManager.scale(-0.5F, -0.5F, 0.5F);
           int i = entitylivingbaseIn.getBrightnessForRender();
           int j = i % 65536;
           int k = i / 65536;
           OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float)j, (float)k);
           GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
           this.render.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
           blockrendererdispatcher.renderBlockBrightness(iblockstate, 1.0F);
           GlStateManager.popMatrix();
           GlStateManager.disableRescaleNormal();
       }
}
 
Example 7
Source File: RenderEntityThrownItem.java    From Production-Line with MIT License 5 votes vote down vote up
/**
 * Renders the desired {@code T} type Entity.
 */
@Override
public void doRender(T entity, double x, double y, double z, float entityYaw, float partialTicks) {
    GlStateManager.pushMatrix();
    GlStateManager.translate((float) x, (float) y, (float) z);
    GlStateManager.enableRescaleNormal();
    GlStateManager.rotate(-this.renderManager.playerViewY, 0.0F, 1.0F, 0.0F);
    GlStateManager.rotate((float) (this.renderManager.options.thirdPersonView == 2 ? -1 : 1) * this.renderManager.playerViewX, 1.0F, 0.0F, 0.0F);
    GlStateManager.rotate(180.0F, 0.0F, 1.0F, 0.0F);
    this.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);

    if (this.renderOutlines) {
        GlStateManager.enableColorMaterial();
        GlStateManager.enableOutlineMode(this.getTeamColor(entity));
    }

    this.itemRenderer.renderItem(this.getStackToRender(entity), ItemCameraTransforms.TransformType.GROUND);

    if (this.renderOutlines) {
        GlStateManager.disableOutlineMode();
        GlStateManager.disableColorMaterial();
    }

    GlStateManager.disableRescaleNormal();
    GlStateManager.popMatrix();
    super.doRender(entity, x, y, z, entityYaw, partialTicks);
}
 
Example 8
Source File: RenderListener.java    From SkyblockAddons with MIT License 5 votes vote down vote up
private void renderItem(ItemStack item, float x, float y) {
    GlStateManager.enableRescaleNormal();
    RenderHelper.enableGUIStandardItemLighting();
    GlStateManager.enableDepth();

    GlStateManager.pushMatrix();
    GlStateManager.translate(x, y, 0);
    Minecraft.getMinecraft().getRenderItem().renderItemIntoGUI(item, 0, 0);
    GlStateManager.popMatrix();

    GlStateManager.disableDepth();
    RenderHelper.disableStandardItemLighting();
    GlStateManager.disableRescaleNormal();
}
 
Example 9
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 10
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 11
Source File: TileManaMagnetRenderer.java    From Wizardry with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void render(TileManaMagnet te, double x, double y, double z, float partialTicks, int destroyStage, float alpha) {
	if (te.manaOrb != null) {
		GlStateManager.pushMatrix();
		GlStateManager.enableBlend();
		GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);

		GlStateManager.translate(x + 0.5, y + 0.5, z + 0.5);
		GlStateManager.translate(0, MathHelper.sin(ClientTickHandler.getTicks()) / 2.0, 0);
		GlStateManager.disableRescaleNormal();
		{
			GlStateManager.enableRescaleNormal();
			GlStateManager.disableCull();
			GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
			GlStateManager.enableLighting();
			GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
			RenderHelper.disableStandardItemLighting();

			Minecraft.getMinecraft().getTextureManager().bindTexture(manaPearlCubeTexture);
			TileOrbHolderRenderer.renderCube(0.1, Color.WHITE);

			GlStateManager.disableRescaleNormal();
		}

		GlStateManager.disableBlend();
		GlStateManager.popMatrix();
	}
}
 
Example 12
Source File: TESRBarrel.java    From enderutilities with GNU Lesser General Public License v3.0 4 votes vote down vote up
protected void renderStack(ItemStack stack, double posX, double posY, double posZ, EnumFacing side, EnumFacing barrelFront)
{
    GlStateManager.pushMatrix();
    GlStateManager.translate(posX, posY, posZ);

    if (side == EnumFacing.UP || side == EnumFacing.DOWN)
    {
        GlStateManager.rotate(MODEL_ROT_SIDE_Y[barrelFront.getIndex()], 0, 1, 0);
        GlStateManager.rotate(-90f * side.getYOffset(), 1, 0, 0);
    }
    else
    {
        GlStateManager.rotate(MODEL_ROT_SIDE_Y[side.getIndex()], 0, 1, 0);
    }

    //GlStateManager.translate(-0.25, 0.2, 0); // This offset is currently added to the renderItemIntoGUI arguments
    GlStateManager.scale(0.55f, 0.55f, 1);

    if (this.renderItem.shouldRenderItemIn3D(stack))
    {
        GlStateManager.scale(1 / 16f, -1 / 16f, 0.0001);
    }
    else
    {
        GlStateManager.scale(1 / 16f, -1 / 16f, 0.01);
        GlStateManager.translate(0, 0, -100);
    }

    // The following rendering stuff within this method has been taken from Storage Drawers by jaquadro, found here:
    // https://github.com/jaquadro/StorageDrawers/blob/e5719be6d64f757a1b58c25e8ca5bc64074c6b9e/src/com/jaquadro/minecraft/storagedrawers/client/renderer/TileEntityDrawersRenderer.java#L180

    // At the time GL_LIGHT* are configured, the coordinates are transformed by the modelview
    // matrix. The transformations used in `RenderHelper.enableGUIStandardItemLighting` are
    // suitable for the orthographic projection used by GUI windows, but they are just a little
    // bit off when rendering a block in 3D and squishing it flat. An additional term is added
    // to account for slightly different shading on the half-size "icons" in 1x2 and 2x2
    // drawers due to the extreme angles caused by flattening the block (as noted below).

    GlStateManager.pushMatrix();
    GlStateManager.scale(2.6f, 2.6f, 1);
    GlStateManager.rotate(171.6f, 0.0F, 1.0F, 0.0F);
    GlStateManager.rotate(84.9f, 1.0F, 0.0F, 0.0F);
    RenderHelper.enableStandardItemLighting();
    GlStateManager.popMatrix();

    // TileEntitySkullRenderer alters both of these options on, but does not restore them.
    GlStateManager.enableCull();
    // This extra enable toggle is to fix a render glitch with items in Item Frames on screen,
    // and then hovering over a stack in an inventory... Rendering... always lovely...
    GlStateManager.enableRescaleNormal();
    GlStateManager.disableRescaleNormal();

    // GL_POLYGON_OFFSET is used to offset flat icons toward the viewer (-Z) in screen space,
    // so they always appear on top of the drawer's front space.
    GlStateManager.enablePolygonOffset();
    GlStateManager.doPolygonOffset(-1, -1);

    // DIRTY HACK: Fool GlStateManager into thinking GL_RESCALE_NORMAL is enabled, but disable
    // it using popAttrib This prevents RenderItem from enabling it again.
    //
    // Normals are transformed by the inverse of the modelview and projection matrices that
    // excludes the translate terms. When put through the extreme Z scale used to flatten the
    // block, this makes them point away from the drawer face at a very sharp angle. These
    // normals are no longer unit scale (normalized), and normalizing them via
    // GL_RESCALE_NORMAL causes a loss of precision that results in the normals pointing
    // directly away from the face, which is visible as the block faces having identical
    // (dark) shading.

    GlStateManager.pushAttrib();
    GlStateManager.enableRescaleNormal();
    GlStateManager.popAttrib();

    this.renderItem.renderItemIntoGUI(stack, -8, -7);

    GlStateManager.disableBlend(); // Clean up after RenderItem
    GlStateManager.enableAlpha();  // Restore world render state after RenderItem
    GlStateManager.disablePolygonOffset();

    GlStateManager.popMatrix();
}
 
Example 13
Source File: EssentialsMissingHandlerClient.java    From Cyberware with MIT License 4 votes vote down vote up
private void renderItemInFirstPerson(float partialTicks)
{
	ItemRenderer ir = mc.getItemRenderer();
	AbstractClientPlayer abstractclientplayer = mc.thePlayer;
	float f = abstractclientplayer.getSwingProgress(partialTicks);
	EnumHand enumhand = (EnumHand)Objects.firstNonNull(abstractclientplayer.swingingHand, EnumHand.MAIN_HAND);
	float f1 = abstractclientplayer.prevRotationPitch + (abstractclientplayer.rotationPitch - abstractclientplayer.prevRotationPitch) * partialTicks;
	float f2 = abstractclientplayer.prevRotationYaw + (abstractclientplayer.rotationYaw - abstractclientplayer.prevRotationYaw) * partialTicks;
	boolean flag = true;
	boolean flag1 = true;

	if (abstractclientplayer.isHandActive())
	{
		ItemStack itemstack = abstractclientplayer.getActiveItemStack();

		if (itemstack != null && itemstack.getItem() == Items.BOW) //Forge: Data watcher can desync and cause this to NPE...
		{
			EnumHand enumhand1 = abstractclientplayer.getActiveHand();
			flag = enumhand1 == EnumHand.MAIN_HAND;
			flag1 = !flag;
		}
	}

	rotateArroundXAndY(f1, f2);
	setLightmap();
	rotateArm(partialTicks);
	GlStateManager.enableRescaleNormal();

	ItemStack itemStackMainHand = ReflectionHelper.getPrivateValue(ItemRenderer.class, ir, 3);
	ItemStack itemStackOffHand = ReflectionHelper.getPrivateValue(ItemRenderer.class, ir, 4);
	float equippedProgressMainHand = ReflectionHelper.getPrivateValue(ItemRenderer.class, ir, 5);
	float prevEquippedProgressMainHand = ReflectionHelper.getPrivateValue(ItemRenderer.class, ir, 6);
	float equippedProgressOffHand = ReflectionHelper.getPrivateValue(ItemRenderer.class, ir, 7);
	float prevEquippedProgressOffHand = ReflectionHelper.getPrivateValue(ItemRenderer.class, ir, 8);

	RenderCyberlimbHand.INSTANCE.itemStackMainHand = itemStackMainHand;
	RenderCyberlimbHand.INSTANCE.itemStackOffHand = itemStackOffHand;

	if (flag && !missingSecondArm)
	{
		float f3 = enumhand == EnumHand.MAIN_HAND ? f : 0.0F;
		float f5 = 1.0F - (prevEquippedProgressMainHand + (equippedProgressMainHand - prevEquippedProgressMainHand) * partialTicks);
		RenderCyberlimbHand.INSTANCE.leftRobot = hasRoboLeft;
		RenderCyberlimbHand.INSTANCE.rightRobot = hasRoboRight;
		RenderCyberlimbHand.INSTANCE.renderItemInFirstPerson(abstractclientplayer, partialTicks, f1, EnumHand.MAIN_HAND, f3, itemStackMainHand, f5);
	}

	if (flag1 && !missingArm)
	{
		float f4 = enumhand == EnumHand.OFF_HAND ? f : 0.0F;
		float f6 = 1.0F - (prevEquippedProgressOffHand + (equippedProgressOffHand - prevEquippedProgressOffHand) * partialTicks);
		RenderCyberlimbHand.INSTANCE.leftRobot = hasRoboLeft;
		RenderCyberlimbHand.INSTANCE.rightRobot = hasRoboRight;
		RenderCyberlimbHand.INSTANCE.renderItemInFirstPerson(abstractclientplayer, partialTicks, f1, EnumHand.OFF_HAND, f4, itemStackOffHand, f6);
	}

	GlStateManager.disableRescaleNormal();
	RenderHelper.disableStandardItemLighting();
}
 
Example 14
Source File: MixinItemRenderer.java    From LiquidBounce with GNU General Public License v3.0 4 votes vote down vote up
/**
 * @author CCBlueX
 */
@Overwrite
public void renderItemInFirstPerson(float partialTicks) {
    float f = 1.0F - (this.prevEquippedProgress + (this.equippedProgress - this.prevEquippedProgress) * partialTicks);
    AbstractClientPlayer abstractclientplayer = this.mc.thePlayer;
    float f1 = abstractclientplayer.getSwingProgress(partialTicks);
    float f2 = abstractclientplayer.prevRotationPitch + (abstractclientplayer.rotationPitch - abstractclientplayer.prevRotationPitch) * partialTicks;
    float f3 = abstractclientplayer.prevRotationYaw + (abstractclientplayer.rotationYaw - abstractclientplayer.prevRotationYaw) * partialTicks;
    this.rotateArroundXAndY(f2, f3);
    this.setLightMapFromPlayer(abstractclientplayer);
    this.rotateWithPlayerRotations((EntityPlayerSP) abstractclientplayer, partialTicks);
    GlStateManager.enableRescaleNormal();
    GlStateManager.pushMatrix();

    if(this.itemToRender != null) {
        final KillAura killAura = (KillAura) LiquidBounce.moduleManager.getModule(KillAura.class);

        if(this.itemToRender.getItem() instanceof net.minecraft.item.ItemMap) {
            this.renderItemMap(abstractclientplayer, f2, f, f1);
        } else if (abstractclientplayer.getItemInUseCount() > 0 || (itemToRender.getItem() instanceof ItemSword && killAura.getBlockingStatus())) {
            EnumAction enumaction = killAura.getBlockingStatus() ? EnumAction.BLOCK : this.itemToRender.getItemUseAction();

            switch(enumaction) {
                case NONE:
                    this.transformFirstPersonItem(f, 0.0F);
                    break;
                case EAT:
                case DRINK:
                    this.performDrinking(abstractclientplayer, partialTicks);
                    this.transformFirstPersonItem(f, f1);
                    break;
                case BLOCK:
                    this.transformFirstPersonItem(f + 0.1F, f1);
                    this.doBlockTransformations();
                    GlStateManager.translate(-0.5F, 0.2F, 0.0F);
                    break;
                case BOW:
                    this.transformFirstPersonItem(f, f1);
                    this.doBowTransformations(partialTicks, abstractclientplayer);
            }
        }else{
            if (!LiquidBounce.moduleManager.getModule(SwingAnimation.class).getState())
                this.doItemUsedTransformations(f1);
            this.transformFirstPersonItem(f, f1);
        }

        this.renderItem(abstractclientplayer, this.itemToRender, ItemCameraTransforms.TransformType.FIRST_PERSON);
    }else if(!abstractclientplayer.isInvisible()) {
        this.renderPlayerArm(abstractclientplayer, f, f1);
    }

    GlStateManager.popMatrix();
    GlStateManager.disableRescaleNormal();
    RenderHelper.disableStandardItemLighting();
}
 
Example 15
Source File: ComponentGui.java    From OpenModsLib with MIT License 4 votes vote down vote up
protected void restoreRenderState() {
	GlStateManager.enableRescaleNormal();
	GlStateManager.enableLighting();
	GlStateManager.enableDepth();
	RenderHelper.enableStandardItemLighting();
}
 
Example 16
Source File: ModularUIGui.java    From GregTech with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
    this.hoveredSlot = null;
    drawDefaultBackground();

    GlStateManager.disableRescaleNormal();
    RenderHelper.disableStandardItemLighting();
    GlStateManager.disableLighting();
    GlStateManager.disableDepth();

    drawGuiContainerBackgroundLayer(partialTicks, mouseX, mouseY);

    RenderHelper.enableGUIStandardItemLighting();
    GlStateManager.pushMatrix();
    GlStateManager.translate(guiLeft, guiTop, 0.0F);
    GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
    GlStateManager.enableRescaleNormal();

    OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240.0F, 240.0F);
    GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);

    for (int i = 0; i < this.inventorySlots.inventorySlots.size(); ++i) {
        Slot slot = this.inventorySlots.inventorySlots.get(i);
        if (slot.isEnabled()) {
            this.drawSlotContents(slot);
        }
        if (isPointInRegion(slot.xPos, slot.yPos, 16, 16, mouseX, mouseY) && slot.isEnabled()) {
            renderSlotOverlay(slot);
            setHoveredSlot(slot);
        }
    }

    RenderHelper.disableStandardItemLighting();
    GlStateManager.popMatrix();

    drawGuiContainerForegroundLayer(mouseX, mouseY);

    GlStateManager.pushMatrix();
    GlStateManager.translate(guiLeft, guiTop, 0.0F);
    RenderHelper.enableGUIStandardItemLighting();

    MinecraftForge.EVENT_BUS.post(new GuiContainerEvent.DrawForeground(this, mouseX, mouseY));

    GlStateManager.enableDepth();
    renderItemStackOnMouse(mouseX, mouseY);
    renderReturningItemStack();

    GlStateManager.popMatrix();
    GlStateManager.enableLighting();
    RenderHelper.enableStandardItemLighting();

    renderHoveredToolTip(mouseX, mouseY);
}
 
Example 17
Source File: WrapperGlStateManager.java    From ClientBase with MIT License 4 votes vote down vote up
public static void enableRescaleNormal() {
    GlStateManager.enableRescaleNormal();
}
 
Example 18
Source File: RenderCodex.java    From Wizardry with GNU Lesser General Public License v3.0 4 votes vote down vote up
public void renderItemStack(ItemStack stack) {
	GlStateManager.enableAlpha();
	GlStateManager.enableBlend();
	GlStateManager.enableRescaleNormal();

	GlStateManager.pushMatrix();

	RenderItem itemRender = Minecraft.getMinecraft().getRenderItem();
	itemRender.renderItemAndEffectIntoGUI(stack, 0, 0);

	GlStateManager.translate(0, 0, 150);

	FontRenderer font = stack.getItem().getFontRenderer(stack);
	if (font == null) font = Minecraft.getMinecraft().fontRenderer;

	if (font != null && stack.getCount() != 1) {
		GlStateManager.translate(0, 0, 5);
		GlStateManager.disableLighting();
		GlStateManager.disableBlend();
		font.drawStringWithShadow(stack.getCount() + "",
				17F - font.getStringWidth(stack.getCount() + ""),
				9F,
				0xFFFFFF);
		GlStateManager.enableDepth();
		GlStateManager.enableBlend();
		GlStateManager.translate(0, 0, -5);
	}

	if (stack.getItem().showDurabilityBar(stack)) {
		GlStateManager.disableLighting();
		GlStateManager.disableTexture2D();
		GlStateManager.disableAlpha();
		GlStateManager.disableBlend();
		Tessellator tessellator = Tessellator.getInstance();
		BufferBuilder bufferbuilder = tessellator.getBuffer();
		double health = stack.getItem().getDurabilityForDisplay(stack);
		int rgbfordisplay = stack.getItem().getRGBDurabilityForDisplay(stack);
		int i = Math.round(13.0F - (float) health * 13.0F);
		draw(bufferbuilder, 2, 13, 13, 2, 0, 0, 0, 255);
		draw(bufferbuilder, 2, 13, i, 1, rgbfordisplay >> 16 & 255, rgbfordisplay >> 8 & 255, rgbfordisplay & 255, 255);
		GlStateManager.enableBlend();
		GlStateManager.enableAlpha();
		GlStateManager.enableTexture2D();
		GlStateManager.enableLighting();
	}


	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.disableTexture2D();
		Tessellator tessellator1 = Tessellator.getInstance();
		BufferBuilder bufferbuilder1 = tessellator1.getBuffer();
		this.draw(bufferbuilder1, 0, MathHelper.floor(16.0F * (1.0F - f3)), 16, MathHelper.ceil(16.0F * f3), 255, 255, 255, 127);
		GlStateManager.enableTexture2D();
		GlStateManager.enableLighting();
	}

	GlStateManager.popMatrix();

	GlStateManager.enableLighting();
	GlStateManager.enableAlpha();
	GlStateManager.enableBlend();
	GlStateManager.disableRescaleNormal();
}
 
Example 19
Source File: RenderBeam.java    From TofuCraftReload with MIT License 4 votes vote down vote up
/**
 * Renders the desired {@code T} type Entity.
 */
public void doRender(EntityBeam entity, double x, double y, double z, float entityYaw, float partialTicks) {
    this.bindEntityTexture(entity);
    GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
    GlStateManager.pushMatrix();
    GlStateManager.disableLighting();
    GlStateManager.translate((float) x, (float) y, (float) z);
    GlStateManager.rotate(entity.prevRotationYaw + (entity.rotationYaw - entity.prevRotationYaw) * partialTicks - 90.0F, 0.0F, 1.0F, 0.0F);
    GlStateManager.rotate(entity.prevRotationPitch + (entity.rotationPitch - entity.prevRotationPitch) * partialTicks, 0.0F, 0.0F, 1.0F);
    Tessellator tessellator = Tessellator.getInstance();
    BufferBuilder bufferbuilder = tessellator.getBuffer();

    GlStateManager.enableRescaleNormal();

    GlStateManager.rotate(45.0F, 1.0F, 0.0F, 0.0F);
    GlStateManager.scale(0.05625F, 0.05625F, 0.05625F);
    GlStateManager.translate(-4.0F, 0.0F, 0.0F);

    if (this.renderOutlines) {
        GlStateManager.enableColorMaterial();
        GlStateManager.enableOutlineMode(this.getTeamColor(entity));
    }
    GlStateManager.enableBlend();
    GlStateManager.disableAlpha();
    GlStateManager.blendFunc(GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ONE);
    GlStateManager.depthMask(true);

    GlStateManager.glNormal3f(0.05625F, 0.0F, 0.0F);
    bufferbuilder.begin(7, DefaultVertexFormats.POSITION_TEX);
    bufferbuilder.pos(-7.0D, -2.0D, -2.0D).tex(0.0D, 0.15625D).endVertex();
    bufferbuilder.pos(-7.0D, -2.0D, 2.0D).tex(0.15625D, 0.15625D).endVertex();
    bufferbuilder.pos(-7.0D, 2.0D, 2.0D).tex(0.15625D, 0.3125D).endVertex();
    bufferbuilder.pos(-7.0D, 2.0D, -2.0D).tex(0.0D, 0.3125D).endVertex();
    tessellator.draw();
    GlStateManager.glNormal3f(-0.05625F, 0.0F, 0.0F);
    bufferbuilder.begin(7, DefaultVertexFormats.POSITION_TEX);
    bufferbuilder.pos(-7.0D, 2.0D, -2.0D).tex(0.0D, 0.15625D).endVertex();
    bufferbuilder.pos(-7.0D, 2.0D, 2.0D).tex(0.15625D, 0.15625D).endVertex();
    bufferbuilder.pos(-7.0D, -2.0D, 2.0D).tex(0.15625D, 0.3125D).endVertex();
    bufferbuilder.pos(-7.0D, -2.0D, -2.0D).tex(0.0D, 0.3125D).endVertex();
    tessellator.draw();

    for (int j = 0; j < 4; ++j) {
        GlStateManager.rotate(90.0F, 1.0F, 0.0F, 0.0F);
        GlStateManager.glNormal3f(0.0F, 0.0F, 0.05625F);
        bufferbuilder.begin(7, DefaultVertexFormats.POSITION_TEX);
        bufferbuilder.pos(-8.0D, -2.0D, 0.0D).tex(0.0D, 0.0D).endVertex();
        bufferbuilder.pos(8.0D, -2.0D, 0.0D).tex(0.5D, 0.0D).endVertex();
        bufferbuilder.pos(8.0D, 2.0D, 0.0D).tex(0.5D, 0.15625D).endVertex();
        bufferbuilder.pos(-8.0D, 2.0D, 0.0D).tex(0.0D, 0.15625D).endVertex();
        tessellator.draw();
    }

    if (this.renderOutlines) {
        GlStateManager.disableOutlineMode();
        GlStateManager.disableColorMaterial();
    }
    GlStateManager.disableBlend();
    GlStateManager.enableAlpha();
    GlStateManager.disableRescaleNormal();
    GlStateManager.enableLighting();
    GlStateManager.popMatrix();
    super.doRender(entity, x, y, z, entityYaw, partialTicks);
}
 
Example 20
Source File: ShulkerViewer.java    From ForgeHax with MIT License 4 votes vote down vote up
@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);
}