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

The following examples show how to use net.minecraft.client.renderer.GlStateManager#disableRescaleNormal() . 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: RenderSeedAnalyzer.java    From AgriCraft with MIT License 6 votes vote down vote up
private void renderSeed(TileEntitySeedAnalyzer te, double x, double y, double z) {
    if (te != null && te.hasSpecimen()) {
        // Save Settings
        GlStateManager.pushAttrib();
        GlStateManager.pushMatrix();

        // Translate to the location of our tile entity
        GlStateManager.translate(x, y, z);
        GlStateManager.disableRescaleNormal();

        // Render Seed Item
        renderItemStack(te.getSpecimen(), 0.5, 0.5, 0.5, 0.75, true);

        // Restore Settings
        GlStateManager.popMatrix();
        GlStateManager.popAttrib();
    }
}
 
Example 2
Source File: GuiSurgery.java    From Cyberware with MIT License 6 votes vote down vote up
public void renderModel(ModelBase model, float x, float y, float scale, float rotation)
{
	GlStateManager.enableColorMaterial();
	GlStateManager.pushMatrix();
	GlStateManager.translate(x, y, 120F);
	GlStateManager.scale(-scale, scale, scale);
	GlStateManager.rotate(180.0F, 0.0F, 0.0F, 1.0F);
	GlStateManager.rotate(10.0F, 1.0F, 0.0F, 0.0F);
	GlStateManager.rotate(rotation, 0.0F, 1.0F, 0.0F);
	RenderHelper.enableStandardItemLighting();
	float f1 = 0.7F;
	GlStateManager.glLightModel(2899, RenderHelper.setColorBuffer(f1, f1, f1, 1.0F));
	model.render(null, 0, 0, 0, 0, 0, .0625f);
	GlStateManager.popMatrix();
	RenderHelper.disableStandardItemLighting();
	GlStateManager.disableRescaleNormal();
	OpenGlHelper.setActiveTexture(OpenGlHelper.lightmapTexUnit);
	GlStateManager.disableTexture2D();
	OpenGlHelper.setActiveTexture(OpenGlHelper.defaultTexUnit);
	GlStateManager.enableTexture2D();

}
 
Example 3
Source File: RenderHelper.java    From HoloInventory with MIT License 6 votes vote down vote up
public static void renderStack(RenderItem ri, ItemStack stack, int cols, int col, int rows, int row)
{
    GlStateManager.pushMatrix();
    GlStateManager.pushAttrib();
    GlStateManager.translate(0.4f * (cols / 2.0 - col) - 0.2f, 0.4f * (rows / 2.0 - row), 0);
    GlStateManager.pushMatrix();
    GlStateManager.rotate((float) (360.0 * (double) (System.currentTimeMillis() & 0x3FFFL) / (double) 0x3FFFL), 0, 1, 0);
    GlStateManager.scale(0.45, 0.45, 0.45);

    ri.renderItem(stack, ItemCameraTransforms.TransformType.FIXED);

    if (stack.hasEffect())
    {
        GlStateManager.disableAlpha();
        GlStateManager.disableRescaleNormal();
        GlStateManager.disableLighting();
    }
    GlStateManager.popMatrix();

    GlStateManager.popAttrib();
    GlStateManager.popMatrix();
}
 
Example 4
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 5
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 6
Source File: RenderPeripheral.java    From AgriCraft with MIT License 6 votes vote down vote up
private void renderSeed(TileEntitySeedAnalyzer te, double x, double y, double z) {
    if (te != null && te.hasSpecimen()) {
        // Save Settings
        GlStateManager.pushAttrib();
        GlStateManager.pushMatrix();

        // Translate to the location of our tile entity
        GlStateManager.translate(x, y, z);
        GlStateManager.disableRescaleNormal();

        // Render Seed Item
        renderItemStack(te.getSpecimen(), 0.5, 0.5, 0.5, 0.75, true);

        // Restore Settings
        GlStateManager.popMatrix();
        GlStateManager.popAttrib();
    }
}
 
Example 7
Source File: GuiSurgery.java    From Cyberware with MIT License 6 votes vote down vote up
public void renderEntity(Entity entity, float x, float y, float scale, float rotation)
{
	GlStateManager.enableColorMaterial();
	GlStateManager.pushMatrix();
	GlStateManager.translate(x, y, 50.0F);
	GlStateManager.scale(-scale, scale, scale);
	GlStateManager.rotate(180.0F, 0.0F, 0.0F, 1.0F);
	GlStateManager.rotate(rotation, 0.0F, 1.0F, 0.0F);
	RenderHelper.enableStandardItemLighting();
	Minecraft.getMinecraft().getRenderManager().playerViewY = 180.0F;
	Minecraft.getMinecraft().getRenderManager().doRenderEntity(entity, 0.0D, 0.0D, 0.0D, 0.0F, 1.0F, false);
	GlStateManager.popMatrix();
	RenderHelper.disableStandardItemLighting();
	GlStateManager.disableRescaleNormal();
	OpenGlHelper.setActiveTexture(OpenGlHelper.lightmapTexUnit);
	GlStateManager.disableTexture2D();
	OpenGlHelper.setActiveTexture(OpenGlHelper.defaultTexUnit);
	GlStateManager.enableTexture2D();
}
 
Example 8
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 9
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 10
Source File: GuiInventoryExpandedCrafting.java    From Cyberware with MIT License 5 votes vote down vote up
public static void drawEntityOnScreen(int posX, int posY, int scale, float mouseX, float mouseY, EntityLivingBase ent)
{
	GlStateManager.enableColorMaterial();
	GlStateManager.pushMatrix();
	GlStateManager.translate((float)posX, (float)posY, 50.0F);
	GlStateManager.scale((float)(-scale), (float)scale, (float)scale);
	GlStateManager.rotate(180.0F, 0.0F, 0.0F, 1.0F);
	float f = ent.renderYawOffset;
	float f1 = ent.rotationYaw;
	float f2 = ent.rotationPitch;
	float f3 = ent.prevRotationYawHead;
	float f4 = ent.rotationYawHead;
	GlStateManager.rotate(135.0F, 0.0F, 1.0F, 0.0F);
	RenderHelper.enableStandardItemLighting();
	GlStateManager.rotate(-135.0F, 0.0F, 1.0F, 0.0F);
	GlStateManager.rotate(-((float)Math.atan((double)(mouseY / 40.0F))) * 20.0F, 1.0F, 0.0F, 0.0F);
	ent.renderYawOffset = (float)Math.atan((double)(mouseX / 40.0F)) * 20.0F;
	ent.rotationYaw = (float)Math.atan((double)(mouseX / 40.0F)) * 40.0F;
	ent.rotationPitch = -((float)Math.atan((double)(mouseY / 40.0F))) * 20.0F;
	ent.rotationYawHead = ent.rotationYaw;
	ent.prevRotationYawHead = ent.rotationYaw;
	GlStateManager.translate(0.0F, 0.0F, 0.0F);
	RenderManager rendermanager = Minecraft.getMinecraft().getRenderManager();
	rendermanager.setPlayerViewY(180.0F);
	rendermanager.setRenderShadow(false);
	rendermanager.doRenderEntity(ent, 0.0D, 0.0D, 0.0D, 0.0F, 1.0F, false);
	rendermanager.setRenderShadow(true);
	ent.renderYawOffset = f;
	ent.rotationYaw = f1;
	ent.rotationPitch = f2;
	ent.prevRotationYawHead = f3;
	ent.rotationYawHead = f4;
	GlStateManager.popMatrix();
	RenderHelper.disableStandardItemLighting();
	GlStateManager.disableRescaleNormal();
	GlStateManager.setActiveTexture(OpenGlHelper.lightmapTexUnit);
	GlStateManager.disableTexture2D();
	GlStateManager.setActiveTexture(OpenGlHelper.defaultTexUnit);
}
 
Example 11
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 12
Source File: TileOrbHolderRenderer.java    From Wizardry with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public void render(TileOrbHolder te, double x, double y, double z, float partialTicks, int destroyStage, float alpha) {
	if (te.containsCell()) {

		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.disableRescaleNormal();

		float sin = (float) Math.sin((ClientTickHandler.getTicks() + partialTicks + te.getPos().hashCode()) / 10.0);

		boolean gravitating = false;
		// Hover towards block
		if (te.containsCell()) {
			BlockPos.MutableBlockPos pos = new BlockPos.MutableBlockPos(te.getPos());
			for (int i = -6; i < 6; i++)
				for (int j = -6; j < 6; j++)
					for (int k = -6; k < 6; k++) {
						pos.setPos(te.getPos().getX() + i, te.getPos().getY() + j, te.getPos().getZ() + k);
						Block block = te.getWorld().getBlockState(pos).getBlock();

						if (te.containsCell() && block == ModBlocks.MANA_BATTERY) {
							gravitating = true;
							Vec3d direction = new Vec3d(te.getPos()).subtract(new Vec3d(pos)).normalize();
							GlStateManager.translate(sin * direction.x / 5.0, sin * direction.y / 5.0, sin * direction.z / 5.0);
							break;
						}
					}
		}


		if (!gravitating) GlStateManager.translate(0, sin / 10.0, 0);

		GlStateManager.rotate((ClientTickHandler.getTicks() + partialTicks) * 4.0f, 0, 1, 0);

		GlStateManager.translate(0, 0.6, 0);
		GlStateManager.rotate(45f, 1, 0, 1);

		{
			GlStateManager.disableCull();
			GlStateManager.enableLighting();
			GlStateManager.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA);
			GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
			RenderHelper.disableStandardItemLighting();

			if (te.containsCell()) {
				Color c = new Color(1f, 1f, 1f, (float) (ManaManager.getMana(te.getWizardryCap()) / ManaManager.getMaxMana(te.getWizardryCap())));
				Minecraft.getMinecraft().getTextureManager().bindTexture(manaOrb);
				renderCube(0.13, c);
				Minecraft.getMinecraft().getTextureManager().bindTexture(glassOrb);
				renderCube(0.135, new Color(1, 1, 1, 0.8f));
			}
			GlStateManager.disableRescaleNormal();
		}

		GlStateManager.disableBlend();
		GlStateManager.popMatrix();
	}
}
 
Example 13
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 14
Source File: WrapperGlStateManager.java    From ClientBase with MIT License 4 votes vote down vote up
public static void disableRescaleNormal() {
    GlStateManager.disableRescaleNormal();
}
 
Example 15
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 16
Source File: GuiEntityRender.java    From WearableBackpacks with MIT License 4 votes vote down vote up
@Override
public void draw(int mouseX, int mouseY, float partialTicks) {
	int w = getWidth();
	int h = getHeight();
	
	enableBlendAlphaStuffs();
	setRenderColorARGB(_colorBackground); drawRect(1, 1, w - 2, h - 2);
	setRenderColorARGB(_colorBorder);     drawOutline(0, 0, w, h);
	disableBlendAlphaStuffs();
	
	Entity entity = getEntity();
	if (entity == null) return;
	
	AxisAlignedBB bbox = entity.getRenderBoundingBox();
	float entityWidth  = (float)(bbox.maxX - bbox.minX);
	float entityHeight = (float)(bbox.maxY - bbox.minY);
	float scale = Math.min((w - RESERVED_SPACE) / entityWidth,
	                       (h - RESERVED_SPACE) / entityHeight) * _zoom;
	float yaw   = _yawDefault + _yaw;
	float pitch = _pitchDefault + _pitch;
	
	getContext().pushScissor(this, 1, 1, w - 2, h - 2);
	
	if (entity.getEntityWorld() == null)
		entity.setWorld(DummyWorld.INSTANCE);
	if (getMC().player == null) {
		World world = entity.getEntityWorld();
		if (!(world instanceof DummyWorld)) return;
		getMC().player = ((DummyWorld)world).player;
		getMC().player.setWorld(world);
	}
	
	setRenderColorARGB(Color.WHITE);
	GlStateManager.enableDepth();
	// From GuiInventory.drawEntityOnScreen
	GlStateManager.enableColorMaterial();
	GlStateManager.pushMatrix();
	GlStateManager.translate(w * _centerX, h * _centerY, 100.0F);
	GlStateManager.scale(-scale, scale, scale);
	GlStateManager.rotate(180.0F, 0.0F, 0.0F, 1.0F);
	GlStateManager.rotate(pitch, 1.0F, 0.0F, 0.0F);
	GlStateManager.translate(0.0F, -(entityHeight / 2), 0.0F);
	GlStateManager.rotate(yaw, 0.0F, 1.0F, 0.0F);
	
	RenderHelper.enableStandardItemLighting();
	
	RenderManager rendermanager = Minecraft.getMinecraft().getRenderManager();
	rendermanager.setPlayerViewY(180.0F);
	rendermanager.setRenderShadow(false);
	rendermanager.renderEntity(entity, 0.0D, 0.0D, 0.0D, 0.0F, 1.0F, false);
	rendermanager.setRenderShadow(true);
	
	GlStateManager.popMatrix();
	RenderHelper.disableStandardItemLighting();
	GlStateManager.disableRescaleNormal();
	GlStateManager.setActiveTexture(OpenGlHelper.lightmapTexUnit);
	GlStateManager.disableTexture2D();
	GlStateManager.setActiveTexture(OpenGlHelper.defaultTexUnit);
	
	GlStateManager.disableDepth();
	if (getMC().player instanceof DummyPlayerSP)
		getMC().player = null;
	getContext().popScissor();
}
 
Example 17
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 18
Source File: RenderTileEntityStoneMortar.java    From Sakura_mod with MIT License 4 votes vote down vote up
@Override
public void render(TileEntityStoneMortar te, double x, double y, double z, float partialTicks, int destroyStage, float alpha) {
    GlStateManager.enableDepth();
    GlStateManager.depthFunc(515);
    GlStateManager.depthMask(true);
    GlStateManager.disableCull();

    if (destroyStage >= 0) {
        this.bindTexture(DESTROY_STAGES[destroyStage]);
        GlStateManager.matrixMode(5890);
        GlStateManager.pushMatrix();
        GlStateManager.scale(4.0F, 4.0F, 1.0F);
        GlStateManager.translate(0.0625F, 0.0625F, 0.0625F);
        GlStateManager.matrixMode(5888);
    } else {
        this.bindTexture(TEXTURES);
    }

    GlStateManager.pushMatrix();
    GlStateManager.enableRescaleNormal();

    if (destroyStage < 0) {
        GlStateManager.color(1.0F, 1.0F, 1.0F, alpha);
    }

    GlStateManager.translate((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F);
    GlStateManager.scale(1.0F, -1.0F, -1.0F);
    GlStateManager.translate(0.0F, 1.0F, 0.0F);
    GlStateManager.scale(0.9995F, 0.9995F, 0.9995F);
    GlStateManager.translate(0.0F, -1.0F, 0.0F);

    this.model.block1.render(0.0625F);

    if(te.getUpdateTag().getInteger("processTimer")!=0){
        float rot = te.getWorld().getTotalWorldTime() % 360;
        rot = rot * 2;
        GlStateManager.rotate(rot, 0.0F, 1.0F, 0.0F);
    }

    this.model.block2.render(0.0625F);
    this.model.handle.render(0.0625F);
    GlStateManager.enableCull();
    GlStateManager.disableRescaleNormal();
    GlStateManager.popMatrix();
    GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);

    if (destroyStage >= 0) {
        GlStateManager.matrixMode(5890);
        GlStateManager.popMatrix();
        GlStateManager.matrixMode(5888);
    }
}
 
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: RenderFukumame.java    From TofuCraftReload with MIT License 4 votes vote down vote up
/**
 * Renders the desired {@code T} type Entity.
 */
public void doRender(EntityFukumame 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.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.disableRescaleNormal();
    GlStateManager.enableLighting();
    GlStateManager.popMatrix();
    super.doRender(entity, x, y, z, entityYaw, partialTicks);
}