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 everyone,

 

I have a mod where the player can morph into entities that he "owns". He can call upon them whenever and all that. i do have an issue however in multiplayer. The models seem to "jitter" when a second player logs in and sees the morphed player (his new model shows up) but it jitters which is odd. I was wondering if there is any way to smooth out this jitter.

 

here is my event

 

@SubscribeEvent
public void onRenderPlayerPre(RenderPlayerEvent.Pre pre) {

	BattlePlayerProperties bpp = BattlePlayerProperties.get(pre.entityPlayer); // Client Side Player
	if (bpp == null) {
		return;
	}

	if(bpp.isMorphed()) {
		pre.setCanceled(true); // this stops the player from rendering
		EntityPlayer thePlayer = Minecraft.getMinecraft().thePlayer;
		float modelYOffset;
		if(pre.entityPlayer.equals(thePlayer)){
		modelYOffset = -1.625F;
		} else{
		modelYOffset = 0F;
		}
		int modelId = bpp.getModelId();	//default is -1 which is steve model
		double x = pre.entityPlayer.posX - thePlayer.posX;
		double y = pre.entityPlayer.posY - thePlayer.posY;
		double z = pre.entityPlayer.posZ - thePlayer.posZ;


		Render renderPlayerModel = PlayerRenderingRegistry.getRendererByModelId(modelId);
		renderPlayerMode.doRender(pre.entityPlayer, x, y + modelYOffset, z, 0F, 0.0625F);
	}
}

 

it seems the issue has to do with the x, y, and z x coordinates that I calculate so that the new model renders in the correct spot for the player. Any ideas how to fix the jitter? it only seems to happen when the second player sees the morphed player and this second player moves around  while the morphed player is stationary. I think it may also be happening when the morphed player moves around but it isn't as noticeable I don't think.

  • Author

I solved it, this is the math and yes its sucky

//Actual entity position equation is actualPos = lastTickPos + (currentTicPos - lastTickPos) * partialTicks - Thanks to diesieben07 for this
//But you have to calculate the lastTicPos and currentTicPos based on the past/present positions of the two players to put the model in the right spot

double x = (pre.entityPlayer.prevPosX - thePlayer.prevPosX) + ((pre.entityPlayer.posX - thePlayer.posX) - (pre.entityPlayer.prevPosX - thePlayer.prevPosX))*pre.partialRenderTick;
double y = (pre.entityPlayer.prevPosY - thePlayer.prevPosY) + ((pre.entityPlayer.posY - thePlayer.posY) - (pre.entityPlayer.prevPosY - thePlayer.prevPosY))*pre.partialRenderTick;
double z = (pre.entityPlayer.prevPosZ - thePlayer.prevPosZ) + ((pre.entityPlayer.posZ - thePlayer.posZ) - (pre.entityPlayer.prevPosZ - thePlayer.prevPosZ))*pre.partialRenderTick;

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.