Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[1.9.4] Smooth transitions when looking around


Recommended Posts

Hello, I know 1.9.4 is fairly old version, but I figured not much has changed since then regarding the tick/render mechanics, so answers for current version should apply as well.


I am working on something that controls player's yaw/pitch and I bumped into following problem:

* I do most work when onPlayerTick() occurs - which basically means to calculate next pitch/yaw correction, add it to Minecraft.getMinecraft().thePlayer.rotation(Yaw|Pitch) and move on to next iteration.

* My computer has steady 60 FPS, there are 20 ticks per second, the pitch/yaw rotation updates do not look smooth, because I am only allowed to change it once per 3 frames rendered.

* I know it is possible to make it look smooth, because it looks smooth when I control the yaw/pitch with my mouse when playing. 

* This video illustrates my problem.


I did some Googling and found out, that I might be able to use partialTicks and subscribing to drawScreen() method, so I tried onFrame method, which does following:

// Helper variables 
static float previousYaw = 0;
static float previousPitch = 0;
static float desiredNextYaw = 0;
static float desiredNextPitch = 0;
static float desiredYaw;
static float desiredPitch;

public static void onFrame(float partialTicks)
	Minecraft.getMinecraft().thePlayer.rotationPitch = (desiredNextPitch - previousPitch) * partialTicks + previousPitch;
	Minecraft.getMinecraft().thePlayer.rotationYaw = (desiredNextYaw - previousYaw) * partialTicks + previousYaw;


Then I subscribe this to GuiScreenEvent.DrawScreenEvent event like this:

public void drawScreen(GuiScreenEvent.DrawScreenEvent event)
	// Help with smoothing transitions between yaws/pitches
	if (this.currentTask.taskName.equals("DawdleAroundTask"))


And finally, I still, every onPlayerTick occurrence, during ClientTickEvent.Phase.START, run method of the DawdleAroundTask.runTick() which looks like this (yaw/pitch corrections are unimportant and therefore I removed them to provide minimal readable sample):

// Mimicking pre-tick-phase
Minecraft.getMinecraft().thePlayer.rotationYaw = desiredNextYaw;
Minecraft.getMinecraft().thePlayer.rotationPitch = desiredNextPitch;
// /Mimicking pre-tick-phase


// Mimicking post-tick-phase
desiredYaw += getRandom()[0];
desiredPitch += getRandom()[1];

// Corrections
desiredNextPitch = previousPitch - pitchDistance;
// Mimicking post-tick-phase


When I run this now, it still looks like it is updating only every third frame/once per tick, which is not nearly enough. How do I make it look smoothly? I would like it to look as if I am controlling the mouse and the game smoothly turns player around when I move the mouse. Is it possible that I am using wrong events? 


I am sorry for rather a long post, but I feel like that just reading the text part describing what events and what methods I use, could tell enough to you, ultra smart people around here, on what I am doing wrong. I always come here to beg for help as a last resort and I seriously admire the level of understanding and insight into it that you guys here have. Looking forward to your replies!

Edited by DeadPix
Added coma so the second bullet-point in list makes more sense. + wording + shortified unnecessary code
Link to comment
Share on other sites

I'm not sure the draw screen event is really the best one. It should probably work, but I'd try something like the RenderWorldLastEvent. In any case make sure you confirm that it is firing at the refresh rate.


The other possible issue is client versus server side. The server has nothing running at the client refresh rate so it can only make decisions at the tick rate, and furthemored any change in pitch and yaw initiated by the server can at best happen at the intervals that it can send packets to the client. 


So maybe you're already doing this, but I think what you have to do is change the pitch and yaw in an event like RenderWorldLastEvent. 


I would start with a simpler implementation to debug this. What happens if you simply add 1 to yaw in the render event? Forget all the randomness, the desired target and the partial ticks. Just see if you can get smooth steady transition with simply adding 1. 

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Link to comment
Share on other sites

I’m pretty sleep deprived right now, and I don’t know if this is what your looking for but I had a similar issue (I was using xyz instead of pitch/yaw). I wrote a method that gets the coordinates to render at very exactly. 


Have a a look at the entityPos variable in



and the method that creates it (getEntityRenderPos) at



The object (“Position”) it returns is pretty self explanatory. A double accuracy point in 3D space

About Me


My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

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.

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.


  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.