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

The following examples show how to use net.minecraft.client.renderer.GlStateManager#rotate() . 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: 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 2
Source File: RenderCyberlimbHand.java    From Cyberware with MIT License 6 votes vote down vote up
private void renderMapFirstPersonSide(float p_187465_1_, EnumHandSide p_187465_2_, float p_187465_3_, ItemStack p_187465_4_)
{
	float f = p_187465_2_ == EnumHandSide.RIGHT ? 1.0F : -1.0F;
	GlStateManager.translate(f * 0.125F, -0.125F, 0.0F);

	if (!this.mc.thePlayer.isInvisible())
	{
		GlStateManager.pushMatrix();
		GlStateManager.rotate(f * 10.0F, 0.0F, 0.0F, 1.0F);
		this.renderArmFirstPerson(p_187465_1_, p_187465_3_, p_187465_2_);
		GlStateManager.popMatrix();
	}

	GlStateManager.pushMatrix();
	GlStateManager.translate(f * 0.51F, -0.08F + p_187465_1_ * -1.2F, -0.75F);
	float f1 = MathHelper.sqrt_float(p_187465_3_);
	float f2 = MathHelper.sin(f1 * (float)Math.PI);
	float f3 = -0.5F * f2;
	float f4 = 0.4F * MathHelper.sin(f1 * ((float)Math.PI * 2F));
	float f5 = -0.3F * MathHelper.sin(p_187465_3_ * (float)Math.PI);
	GlStateManager.translate(f * f3, f4 - 0.3F * f2, f5);
	GlStateManager.rotate(f2 * -45.0F, 1.0F, 0.0F, 0.0F);
	GlStateManager.rotate(f * f2 * -30.0F, 0.0F, 1.0F, 0.0F);
	this.renderMapFirstPerson(p_187465_4_);
	GlStateManager.popMatrix();
}
 
Example 3
Source File: PlayerDisplay.java    From Hyperium with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void draw(int x, double y, boolean config) {
    GlStateManager.pushMatrix();
    GlStateManager.color(1, 1, 1);

    GlStateManager.translate(x, y, 0);
    RenderHelper.enableStandardItemLighting();
    GlStateManager.enableAlpha();

    GlStateManager.shadeModel(GL11.GL_FLAT);
    GlStateManager.enableAlpha();
    GlStateManager.enableDepth();

    GlStateManager.rotate(30, 0, 1.0F, 0);
    GuiInventory.drawEntityOnScreen(0, 100, 50, 0, 0, Minecraft.getMinecraft().thePlayer);
    GlStateManager.depthFunc(GL11.GL_LEQUAL);
    GlStateManager.resetColor();
    GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
    GlStateManager.disableDepth();
    GlStateManager.popMatrix();
}
 
Example 4
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 5
Source File: RenderCyberlimbHand.java    From Cyberware with MIT License 6 votes vote down vote up
private void renderArm(EnumHandSide p_187455_1_)
{
	this.mc.getTextureManager().bindTexture(this.mc.thePlayer.getLocationSkin());
	Render<AbstractClientPlayer> render = getEntityRenderObject(this.mc.thePlayer, p_187455_1_);
	RenderPlayer renderplayer = (RenderPlayer)render;
	GlStateManager.pushMatrix();
	float f = p_187455_1_ == EnumHandSide.RIGHT ? 1.0F : -1.0F;
	GlStateManager.rotate(92.0F, 0.0F, 1.0F, 0.0F);
	GlStateManager.rotate(45.0F, 1.0F, 0.0F, 0.0F);
	GlStateManager.rotate(f * -41.0F, 0.0F, 0.0F, 1.0F);
	GlStateManager.translate(f * 0.3F, -1.1F, 0.45F);

	if (p_187455_1_ == EnumHandSide.RIGHT)
	{
		renderplayer.renderRightArm(this.mc.thePlayer);
	}
	else
	{
		renderplayer.renderLeftArm(this.mc.thePlayer);
	}

	GlStateManager.popMatrix();
}
 
Example 6
Source File: RenderAltar.java    From CommunityMod with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
public void render(TileEntityAltar te, double x, double y, double z, float partialTicks, int destroyStage, float alpha) {
	ItemStack stack = te.getStack();
	if (!stack.isEmpty()) {
		GlStateManager.enableRescaleNormal();
		GlStateManager.pushMatrix();
		GlStateManager.translate(x + 0.5, y + 0.85, z + 0.5);
		GlStateManager.rotate(te.getWorld().getTotalWorldTime() * 4, 0, 1, 0);
		
		Minecraft.getMinecraft().getRenderItem().renderItem(stack, ItemCameraTransforms.TransformType.GROUND);
		
		GlStateManager.popMatrix();
		GlStateManager.disableRescaleNormal();
		
		if (te.altarAnimation != null) {
			switch (te.altarAnimation) {
				case SHOCKWAVE:
					this.renderShockwave(te.animationProgress, te.altarAnimation.animationLength(), x, y, z);
					break;
				default: break;
			}
		}
	}
}
 
Example 7
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 8
Source File: RenderCyberlimbHand.java    From Cyberware with MIT License 5 votes vote down vote up
private void renderArmFirstPerson(float p_187456_1_, float p_187456_2_, EnumHandSide p_187456_3_)
{
	boolean flag = p_187456_3_ != EnumHandSide.LEFT;
	float f = flag ? 1.0F : -1.0F;
	float f1 = MathHelper.sqrt_float(p_187456_2_);
	float f2 = -0.3F * MathHelper.sin(f1 * (float)Math.PI);
	float f3 = 0.4F * MathHelper.sin(f1 * ((float)Math.PI * 2F));
	float f4 = -0.4F * MathHelper.sin(p_187456_2_ * (float)Math.PI);
	GlStateManager.translate(f * (f2 + 0.64000005F), f3 + -0.6F + p_187456_1_ * -0.6F, f4 + -0.71999997F);
	GlStateManager.rotate(f * 45.0F, 0.0F, 1.0F, 0.0F);
	float f5 = MathHelper.sin(p_187456_2_ * p_187456_2_ * (float)Math.PI);
	float f6 = MathHelper.sin(f1 * (float)Math.PI);
	GlStateManager.rotate(f * f6 * 70.0F, 0.0F, 1.0F, 0.0F);
	GlStateManager.rotate(f * f5 * -20.0F, 0.0F, 0.0F, 1.0F);
	AbstractClientPlayer abstractclientplayer = this.mc.thePlayer;
	this.mc.getTextureManager().bindTexture(abstractclientplayer.getLocationSkin());
	GlStateManager.translate(f * -1.0F, 3.6F, 3.5F);
	GlStateManager.rotate(f * 120.0F, 0.0F, 0.0F, 1.0F);
	GlStateManager.rotate(200.0F, 1.0F, 0.0F, 0.0F);
	GlStateManager.rotate(f * -135.0F, 0.0F, 1.0F, 0.0F);
	GlStateManager.translate(f * 5.6F, 0.0F, 0.0F);
	RenderPlayer renderplayer = getEntityRenderObject(this.mc.thePlayer, p_187456_3_);
	GlStateManager.disableCull();

	if (flag)
	{
		renderplayer.renderRightArm(abstractclientplayer);
	}
	else
	{
		renderplayer.renderLeftArm(abstractclientplayer);
	}

	GlStateManager.enableCull();
}
 
Example 9
Source File: EntryValueEffectOpacity.java    From WearableBackpacks with MIT License 5 votes vote down vote up
private static void renderEffect(int x, int y, int width, int height, float opacity) {
	if (opacity <= 0) return;
	Minecraft mc = Minecraft.getMinecraft();
	float animProgress = Minecraft.getSystemTime() / 400.0F;
	
	int color = 0xFF8040CC;
	float r = (color >> 16 & 0xFF) / 255.0F;
	float g = (color >> 8 & 0xFF) / 255.0F;
	float b = (color & 0xFF) / 255.0F;
	GlStateManager.color(r, g, b, opacity * 0.6F);
	
	mc.getTextureManager().bindTexture(ENCHANTED_ITEM_GLINT);
	
	GlStateManager.enableBlend();
	GlStateManager.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE);
	GlStateManager.enableAlpha();
	GlStateManager.alphaFunc(GL11.GL_ALWAYS, 0.0F);
	
	for (int i = 0; i < 2; ++i) {
		GlStateManager.matrixMode(GL11.GL_TEXTURE);
		GlStateManager.loadIdentity();
		GlStateManager.rotate(30.0F - i * 60.0F, 0.0F, 0.0F, 1.0F);
		GlStateManager.translate(0.0F, animProgress * (0.001F + i * 0.003F) * 20.0F, 0.0F);
		GlStateManager.matrixMode(GL11.GL_MODELVIEW);
		GuiUtils.drawTexturedModalRect(x, y, 0, 0, width, height, 0);
	}
	
	GlStateManager.matrixMode(GL11.GL_TEXTURE);
	GlStateManager.loadIdentity();
	GlStateManager.matrixMode(GL11.GL_MODELVIEW);
	
	GlStateManager.alphaFunc(GL11.GL_GREATER, 0.1F);
	GlStateManager.disableAlpha();
	GlStateManager.blendFunc(GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
	GlStateManager.disableBlend();
}
 
Example 10
Source File: RenderCodex.java    From Wizardry with GNU Lesser General Public License v3.0 5 votes vote down vote up
private static void transformFirstPerson(EnumHandSide p_187453_1_, float p_187453_2_) {
	int i = p_187453_1_ == EnumHandSide.RIGHT ? 1 : -1;
	// Botania - added
	GlStateManager.translate(p_187453_1_ == EnumHandSide.RIGHT ? 0.2F : 0.52F, -0.125F, p_187453_1_ == EnumHandSide.RIGHT ? 0.6F : 0.25F);
	GlStateManager.rotate(p_187453_1_ == EnumHandSide.RIGHT ? 60F : 120F, 0F, 1F, 0F);
	GlStateManager.rotate(30F, 0F, 0F, -1F);
	// End add
	float f = MathHelper.sin(p_187453_2_ * p_187453_2_ * (float) Math.PI);
	GlStateManager.rotate(i * (45.0F + f * -20.0F), 0.0F, 1.0F, 0.0F);
	float f1 = MathHelper.sin(MathHelper.sqrt(p_187453_2_) * (float) Math.PI);
	GlStateManager.rotate(i * f1 * -20.0F, 0.0F, 0.0F, 1.0F);
	GlStateManager.rotate(f1 * -80.0F, 1.0F, 0.0F, 0.0F);
	GlStateManager.rotate(i * -45.0F, 0.0F, 1.0F, 0.0F);
}
 
Example 11
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 12
Source File: RenderCyberlimbHand.java    From Cyberware with MIT License 5 votes vote down vote up
private void transformFirstPerson(EnumHandSide p_187453_1_, float p_187453_2_)
{
	int i = p_187453_1_ == EnumHandSide.RIGHT ? 1 : -1;
	float f = MathHelper.sin(p_187453_2_ * p_187453_2_ * (float)Math.PI);
	GlStateManager.rotate((float)i * (45.0F + f * -20.0F), 0.0F, 1.0F, 0.0F);
	float f1 = MathHelper.sin(MathHelper.sqrt_float(p_187453_2_) * (float)Math.PI);
	GlStateManager.rotate((float)i * f1 * -20.0F, 0.0F, 0.0F, 1.0F);
	GlStateManager.rotate(f1 * -80.0F, 1.0F, 0.0F, 0.0F);
	GlStateManager.rotate((float)i * -45.0F, 0.0F, 1.0F, 0.0F);
}
 
Example 13
Source File: MixinEntityRenderer.java    From Valkyrien-Skies with Apache License 2.0 5 votes vote down vote up
@Redirect(
    method = "Lnet/minecraft/client/renderer/EntityRenderer;orientCamera(F)V",
    at = @At(
        value = "INVOKE",
        target = "Lnet/minecraft/client/renderer/GlStateManager;translate(FFF)V",
        ordinal = 4
    ))
private void rotateCameraAndFixFinalTranslate(float x, float y, float z, float partialTicks) {
    if (this.mountData != null
        && this.mountData.getMountedShip().getShipRenderer().getSmoothRotationQuat(partialTicks)
        != null) {
        Quaternion orientationQuat = this.mountData.getMountedShip()
            .getShipRenderer()
            .getSmoothRotationQuat(partialTicks);

        double[] radians = orientationQuat.toRadians();

        float moddedPitch = (float) Math.toDegrees(radians[0]);
        float moddedYaw = (float) Math.toDegrees(radians[1]);
        float moddedRoll = (float) Math.toDegrees(radians[2]);

        GlStateManager.rotate(-moddedRoll, 0.0F, 0.0F, 1.0F);
        GlStateManager.rotate(-moddedYaw, 0.0F, 1.0F, 0.0F);
        GlStateManager.rotate(-moddedPitch, 1.0F, 0.0F, 0.0F);
    }

    //reset
    this.mountData = null;

    GlStateManager.translate(x - this.eyeVector.X, y - this.eyeVector.Y, z - this.eyeVector.Z);
}
 
Example 14
Source File: TileCraftingPlateRenderer.java    From Wizardry with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public void render(float partialTicks, int destroyStage, float alpha) {
	ArrayList<BlockPos> errors = new ArrayList<>(((IStructure) tile.getBlockType()).testStructure(tile.getWorld(), tile.getPos()));
	errors.sort(Vec3i::compareTo);

	ItemStack input = tile.getInput();
	if (input.isEmpty()) {
		input = tile.getOutput();
		if (input.isEmpty()) {
			input = ItemStack.EMPTY;
		}
	}

	ICraftingPlateRecipe recipeForItem = CraftingPlateRecipeManager.getRecipe(tile.getWorld(), tile.getPos(), input);
	if (recipeForItem != null) recipeForItem.renderInput(tile.getWorld(), tile.getPos(), input, partialTicks);

	if (!errors.isEmpty() && tile.revealStructure && tile.getBlockType() instanceof IStructure) {
		ModStructures.structureManager.draw(ModStructures.CRAFTING_PLATE, (float) (Math.sin(ClientTickHandler.getTicks() / 10.0) + 1) / 10.0f + 0.3f);
	}

	if (!errors.isEmpty()) {
		for (BlockPos error : errors) {
			StructureErrorRenderer.addError(error);
		}
		return;
	} else if (tile.getWorld().isAirBlock(tile.getPos().offset(EnumFacing.UP)) && !CraftingPlateRecipeManager.doesRecipeExist(tile.getWorld(), tile.getPos(), input) && RandUtil.nextInt(4) == 0) {
		LibParticles.CRAFTING_ALTAR_IDLE(tile.getWorld(), new Vec3d(tile.getPos()).add(0.5, 0.7, 0.5));
	}

	// render each item at its current position
	final int mapSize = hoveringStacks.size();
	for (HoveringStack hoveringStack : hoveringStacks.values()) {

		if (!hoveringStack.stack.isEmpty()) {

			{
				GlStateManager.pushMatrix();
				GlStateManager.translate(0.5 + hoveringStack.location.x, 1 + hoveringStack.location.y, 0.5 + hoveringStack.location.z);
				GlStateManager.scale(0.3, 0.3, 0.3);
				GlStateManager.rotate((hoveringStack.randX + ClientTickHandler.getTicks()), 0, 1, 0);
				GlStateManager.rotate((hoveringStack.randY + ClientTickHandler.getTicks()), 1, 0, 0);
				GlStateManager.rotate((hoveringStack.randZ + ClientTickHandler.getTicks()), 0, 0, 1);

				GlStateManager.enableLighting();
				RenderHelper.disableStandardItemLighting();
				Minecraft.getMinecraft().getRenderItem().renderItem(hoveringStack.stack, TransformType.NONE);
				RenderHelper.enableStandardItemLighting();
				GlStateManager.popMatrix();
			}

			if (tile.suckingCooldown <= 0) {
				if (RandUtil.nextInt(mapSize / 2) == 0) {
					LibParticles.CLUSTER_DRAPE(
							tile.getWorld(),
							hoveringStack.location.add(new Vec3d(tile.getPos())).add(0.5, 0.5, 0.5));
				}
			} else {
				if (RandUtil.nextInt(mapSize) == 0) {
					LibParticles.CRAFTING_ALTAR_CLUSTER_SUCTION(
							tile.getWorld(),
							new Vec3d(tile.getPos()).add(0.5, 0.75, 0.5),
							new InterpBezier3D(hoveringStack.location, new Vec3d(0, 0, 0)));
				}
			}
		}
	}
}
 
Example 15
Source File: RenderCyberlimbHand.java    From Cyberware with MIT License 4 votes vote down vote up
public void renderItemInFirstPerson(AbstractClientPlayer p_187457_1_, float p_187457_2_, float p_187457_3_, EnumHand p_187457_4_, float p_187457_5_, @Nullable ItemStack p_187457_6_, float p_187457_7_)
{
	boolean flag = p_187457_4_ == EnumHand.MAIN_HAND;
	EnumHandSide enumhandside = flag ? p_187457_1_.getPrimaryHand() : p_187457_1_.getPrimaryHand().opposite();
	GlStateManager.pushMatrix();

	if (p_187457_6_ == null)
	{
		if (flag && !p_187457_1_.isInvisible())
		{
			
			this.renderArmFirstPerson(p_187457_7_, p_187457_5_, enumhandside);
		}
	}
	else if (p_187457_6_.getItem() instanceof net.minecraft.item.ItemMap)
	{
		if (flag && itemStackOffHand == null)
		{
			this.renderMapFirstPerson(p_187457_3_, p_187457_7_, p_187457_5_);
		}
		else
		{
			this.renderMapFirstPersonSide(p_187457_7_, enumhandside, p_187457_5_, p_187457_6_);
		}
	}
	else
	{
		boolean flag1 = enumhandside == EnumHandSide.RIGHT;

		if (p_187457_1_.isHandActive() && p_187457_1_.getItemInUseCount() > 0 && p_187457_1_.getActiveHand() == p_187457_4_)
		{
			int j = flag1 ? 1 : -1;

			switch (p_187457_6_.getItemUseAction())
			{
				case NONE:
					this.transformSideFirstPerson(enumhandside, p_187457_7_);
					break;
				case EAT:
				case DRINK:
					this.transformEatFirstPerson(p_187457_2_, enumhandside, p_187457_6_);
					this.transformSideFirstPerson(enumhandside, p_187457_7_);
					break;
				case BLOCK:
					this.transformSideFirstPerson(enumhandside, p_187457_7_);
					break;
				case BOW:
					this.transformSideFirstPerson(enumhandside, p_187457_7_);
					GlStateManager.translate((float)j * -0.2785682F, 0.18344387F, 0.15731531F);
					GlStateManager.rotate(-13.935F, 1.0F, 0.0F, 0.0F);
					GlStateManager.rotate((float)j * 35.3F, 0.0F, 1.0F, 0.0F);
					GlStateManager.rotate((float)j * -9.785F, 0.0F, 0.0F, 1.0F);
					float f5 = (float)p_187457_6_.getMaxItemUseDuration() - ((float)this.mc.thePlayer.getItemInUseCount() - p_187457_2_ + 1.0F);
					float f6 = f5 / 20.0F;
					f6 = (f6 * f6 + f6 * 2.0F) / 3.0F;

					if (f6 > 1.0F)
					{
						f6 = 1.0F;
					}

					if (f6 > 0.1F)
					{
						float f7 = MathHelper.sin((f5 - 0.1F) * 1.3F);
						float f3 = f6 - 0.1F;
						float f4 = f7 * f3;
						GlStateManager.translate(f4 * 0.0F, f4 * 0.004F, f4 * 0.0F);
					}

					GlStateManager.translate(f6 * 0.0F, f6 * 0.0F, f6 * 0.04F);
					GlStateManager.scale(1.0F, 1.0F, 1.0F + f6 * 0.2F);
					GlStateManager.rotate((float)j * 45.0F, 0.0F, -1.0F, 0.0F);
			}
		}
		else
		{
			float f = -0.4F * MathHelper.sin(MathHelper.sqrt_float(p_187457_5_) * (float)Math.PI);
			float f1 = 0.2F * MathHelper.sin(MathHelper.sqrt_float(p_187457_5_) * ((float)Math.PI * 2F));
			float f2 = -0.2F * MathHelper.sin(p_187457_5_ * (float)Math.PI);
			int i = flag1 ? 1 : -1;
			GlStateManager.translate((float)i * f, f1, f2);
			this.transformSideFirstPerson(enumhandside, p_187457_7_);
			this.transformFirstPerson(enumhandside, p_187457_5_);
		}

		this.renderItemSide(p_187457_1_, p_187457_6_, flag1 ? ItemCameraTransforms.TransformType.FIRST_PERSON_RIGHT_HAND : ItemCameraTransforms.TransformType.FIRST_PERSON_LEFT_HAND, !flag1);
	}

	GlStateManager.popMatrix();
}
 
Example 16
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 17
Source File: RendererBackpack.java    From WearableBackpacks with MIT License 4 votes vote down vote up
public void doRenderLayer(EntityLivingBase entity, float limbSwing, float limbSwingAmount,
                          float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale) {
	
	IBackpack backpack;
	RenderOptions renderOptions;
	if (_overrideBackpack != null) {
		backpack = _overrideBackpack;
		renderOptions = _overrideRenderOptions;
	} else {
		backpack = BackpackHelper.getBackpack(entity);
		BackpackEntityEntry entry = BackpackRegistry.getEntityEntry(entity.getClass());
		renderOptions = (entry != null) ? entry.renderOptions : null;
	}
	if ((backpack == null) || (renderOptions == null)) return;
	
	GlStateManager.pushMatrix();
	
	if (entity.isChild()) {
		GlStateManager.scale(0.5F, 0.5F, 0.5F);
		GlStateManager.translate(0.0F, 24.0F * scale, 0.0F);
	}
	
	ModelBase modelBase = this.livingEntityRenderer.getMainModel();
	if (modelBase instanceof ModelBiped) {
		ModelRenderer bipedBody = ((ModelBiped) modelBase).bipedBody;
		
		if (entity.isSneaking()) {
			// FIXME: Can be sneaking while flying with the elytra, then backpack is misaligned..?
			GlStateManager.translate(0.0F, 0.2F, 0.0F);
		}
		
		bipedBody.postRender(scale);
	} else {
		// Fallback to the custom way of transforming the backpack.
		// Make backpack swing with body as players swing their arms.
		float swingProgress = entity.getSwingProgress(partialTicks);
		float swingAngle = MathHelper.sin(MathHelper.sqrt(swingProgress) * ((float)Math.PI * 2.0F)) * 0.2F;
		if ((entity.swingingHand == EnumHand.OFF_HAND) ^
		    (entity.getPrimaryHand() == EnumHandSide.LEFT)) swingAngle *= -1;
		if (swingAngle != 0) GlStateManager.rotate((float)Math.toDegrees(swingAngle), 0.0F, 1.0F, 0.0F);
		
		// Rotate backpack if entity is sneaking.
		if (entity.isSneaking()) {
			// FIXME: Can be sneaking while flying with the elytra, then backpack is misaligned..?
			GlStateManager.translate(0.0F, 0.2F, 0.0F);
			GlStateManager.rotate(90.0F / (float)Math.PI, 1.0F, 0.0F, 0.0F);
		}
	}
	
	GlStateManager.scale(renderOptions.scale, renderOptions.scale, renderOptions.scale);
	GlStateManager.translate(8.0F * scale, renderOptions.y * scale, renderOptions.z * scale);
	GlStateManager.rotate(180.0F, 0.0F, 0.0F, 1.0F);
	GlStateManager.rotate((float)renderOptions.rotate, 1.0F, 0.0F, 0.0F);
	GlStateManager.translate(0, ProxyClient.MODEL_BACKPACK_BOX.maxY * scale * -16,
	                            ProxyClient.MODEL_BACKPACK_BOX.minZ * scale * -16);
	
	renderBackpack(backpack, entity.ticksExisted + partialTicks, false);
	
	GlStateManager.popMatrix();
	
}
 
Example 18
Source File: TextureHelper.java    From malmo with MIT License 4 votes vote down vote up
public void render(float partialTicks, WorldClient world, Minecraft mc)
{
    // Adapted from the End sky renderer - just fill with solid colour.
    GlStateManager.disableFog();
    GlStateManager.disableAlpha();
    GlStateManager.disableBlend();
    RenderHelper.disableStandardItemLighting();
    GlStateManager.depthMask(false);
    GlStateManager.disableTexture2D();
    Tessellator tessellator = Tessellator.getInstance();
    VertexBuffer vertexbuffer = tessellator.getBuffer();

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

        if (i == 1)
        {
            GlStateManager.rotate(90.0F, 1.0F, 0.0F, 0.0F);
        }

        if (i == 2)
        {
            GlStateManager.rotate(-90.0F, 1.0F, 0.0F, 0.0F);
        }

        if (i == 3)
        {
            GlStateManager.rotate(180.0F, 1.0F, 0.0F, 0.0F);
        }

        if (i == 4)
        {
            GlStateManager.rotate(90.0F, 0.0F, 0.0F, 1.0F);
        }

        if (i == 5)
        {
            GlStateManager.rotate(-90.0F, 0.0F, 0.0F, 1.0F);
        }

        vertexbuffer.begin(7, DefaultVertexFormats.POSITION_COLOR);
        vertexbuffer.pos(-100.0D, -100.0D, -100.0D).color(this.r, this.g, this.b, 255).endVertex();
        vertexbuffer.pos(-100.0D, -100.0D, 100.0D).color(this.r, this.g, this.b, 255).endVertex();
        vertexbuffer.pos(100.0D, -100.0D, 100.0D).color(this.r, this.g, this.b, 255).endVertex();
        vertexbuffer.pos(100.0D, -100.0D, -100.0D).color(this.r, this.g, this.b, 255).endVertex();
        tessellator.draw();
        GlStateManager.popMatrix();
    }

    GlStateManager.depthMask(true);
    GlStateManager.enableTexture2D();
    GlStateManager.enableAlpha();
}
 
Example 19
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 20
Source File: TESRBarrel.java    From enderutilities with GNU Lesser General Public License v3.0 4 votes vote down vote up
private void renderLockIcon(double x, double y, double z, double offsetX, double offsetY,
        EnumFacing side, EnumFacing barrelFront, ResourceLocation texture)
{
    GlStateManager.pushMatrix();
    GlStateManager.translate(x, y, z);

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

    GlStateManager.rotate(180, 0, 0, 1);
    GlStateManager.translate(offsetX, offsetY, -0.001);
    GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);

    GlStateManager.enableRescaleNormal();
    GlStateManager.disableLighting();

    this.mc.getTextureManager().bindTexture(texture);
    Tessellator tessellator = Tessellator.getInstance();
    BufferBuilder buffer = tessellator.getBuffer();

    buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX);

    buffer.pos(   0,    0, 0).tex(0, 0).endVertex();
    buffer.pos(   0, 0.15, 0).tex(0, 1).endVertex();
    buffer.pos(0.15, 0.15, 0).tex(1, 1).endVertex();
    buffer.pos(0.15,    0, 0).tex(1, 0).endVertex();

    tessellator.draw();

    GlStateManager.disableRescaleNormal();
    GlStateManager.enableLighting();

    GlStateManager.popMatrix();
}