Jump to content

[1.8] Render Issue


EverythingGames

Recommended Posts

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]

Link to comment
Share on other sites

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...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

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