Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

Hi,

Why does the model not rotate with the player? I did exactly as the vanilla code does (called all the functions it does with exact replicated code). It renders fine but it does not rotate properly with the player. Any solutions to this? Also, is the RenderHandEvent broken? It gets called when in third person - we already have the RenderPlayerEvent for that. Anyway, here's the working rendering code:

@SideOnly(Side.CLIENT)
public class RenderEntityPlayer 
{

@SubscribeEvent
public void renderHandEvent(RenderHandEvent event)
{
	this.renderArmInFirstPerson(event.partialTicks);
}

public void renderArmInFirstPerson(float floatOne)
{
	try
	{
		EntityPlayerSP entityplayersp = Minecraft.getMinecraft().thePlayer;
		ItemRenderer itemrenderer = Minecraft.getMinecraft().entityRenderer.itemRenderer;
		Field fi1 = ItemRenderer.class.getDeclaredField("equippedProgress");
		Field fi2 = ItemRenderer.class.getDeclaredField("prevEquippedProgress");
		fi1.setAccessible(true);
		fi2.setAccessible(true);
		float equippedProgress = fi1.getFloat(itemrenderer);
		float prevEquippedProgress = fi2.getFloat(itemrenderer);
		float f1 = 1.0F - (prevEquippedProgress + (equippedProgress - prevEquippedProgress) * floatOne);
		float f2 = entityplayersp.getSwingProgress(floatOne);
		float f3 = entityplayersp.prevRotationPitch + (entityplayersp.rotationPitch - entityplayersp.prevRotationPitch) * floatOne;
		float f4 = entityplayersp.prevRotationYaw + (entityplayersp.rotationYaw - entityplayersp.prevRotationYaw) * floatOne;
		this.functionOne(f3, f4);
		this.functionTwo(entityplayersp);
		this.functionThree(entityplayersp, floatOne);
		GlStateManager.enableRescaleNormal();
		GlStateManager.pushMatrix();
		if(!entityplayersp.isInvisible())
		{
			this.renderArm(entityplayersp, f1, f2);
		}
		GlStateManager.popMatrix();
		GlStateManager.disableRescaleNormal();
		RenderHelper.disableStandardItemLighting();
	}
	catch(Exception exception)
	{
		exception.printStackTrace();
	}
}

public void functionOne(float floatOne, float floatTwo)
{
	GlStateManager.pushMatrix();
	GlStateManager.rotate(floatOne, 1.0F, 0.0F, 0.0F);
	GlStateManager.rotate(floatTwo, 0.0F, 1.0F, 0.0F);
	RenderHelper.enableStandardItemLighting();
	GlStateManager.popMatrix();
}

public void functionTwo(AbstractClientPlayer abstractClientPlayer)
{
	int i = Minecraft.getMinecraft().theWorld.getCombinedLight(new BlockPos(abstractClientPlayer.posX, abstractClientPlayer.posY + (double)abstractClientPlayer.getEyeHeight(), abstractClientPlayer.posZ), 0);
	float f1 = (float)(i & 65535);
	float f2 = (float)(i >> 16);
	OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, f1, f2);
}

public void functionThree(EntityPlayerSP entityplayersp, float floatOne)
{
	float f1 = entityplayersp.prevRenderArmPitch + (entityplayersp.renderArmPitch - entityplayersp.prevRenderArmPitch) * floatOne;
	float f2 = entityplayersp.prevRenderArmYaw + (entityplayersp.renderArmYaw - entityplayersp.prevRenderArmYaw) * floatOne;
	GlStateManager.rotate((entityplayersp.rotationPitch - f1) * 0.1F, 1.0F, 0.0F, 0.0F);
	GlStateManager.rotate((entityplayersp.rotationYaw - f2) * 0.1F, 0.0F, 1.0F, 0.0F);
}

public void renderArm(AbstractClientPlayer abstractClientPlayer, float floatOne, float floatTwo)
{
	float f1 = -0.3F * MathHelper.sin(MathHelper.sqrt_float(floatTwo) * (float) Math.PI);
	float f2 = 0.4F * MathHelper.sin(MathHelper.sqrt_float(floatTwo) * (float) Math.PI * 2.0F);
	float f3 = -0.4F * MathHelper.sin(floatTwo * (float) Math.PI);
	float f4 = MathHelper.sin(floatTwo * floatTwo * (float) Math.PI);
	float f5 = MathHelper.sin(MathHelper.sqrt_float(floatTwo) * (float) Math.PI);
	Minecraft.getMinecraft().getTextureManager().bindTexture(abstractClientPlayer.getLocationSkin());
	RenderPlayer renderplayer = (RenderPlayer) Minecraft.getMinecraft().getRenderManager().getEntityRenderObject(Minecraft.getMinecraft().thePlayer);
	renderplayer.func_177138_b(abstractClientPlayer);
	GlStateManager.translate(f1, f2, f3);
	GlStateManager.translate(0.64000005F, -0.6F, -0.71999997F);
	GlStateManager.translate(0.0F, floatOne * -0.6F, 0.0F);
	GlStateManager.rotate(45.0F, 0.0F, 1.0F, 0.0F);
	GlStateManager.rotate(f5 * 70.0F, 0.0F, 1.0F, 0.0F);
	GlStateManager.rotate(f4 * -20.0F, 0.0F, 0.0F, 1.0F);
	GlStateManager.translate(-1.0F, 3.6F, 3.5F);
	GlStateManager.rotate(120.0F, 0.0F, 0.0F, 1.0F);
	GlStateManager.rotate(200.0F, 1.0F, 0.0F, 0.0F);
	GlStateManager.rotate(-135.0F, 0.0F, 1.0F, 0.0F);
	GlStateManager.scale(1.0F, 1.0F, 1.0F);
	GlStateManager.translate(5.6F, 0.0F, 0.0F);
}

}

Development of Plugins [2012 - 2014] Development of Mods [2012 - Current]

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.