Jump to content

Some sort of syncing issue? (Resolved)


Koi

Recommended Posts

Hi there! I am making a mob that summons an entity on spawn. I rotate this entity around the mob every tick. To do this, I wrote this function that is called from aiStep().

Entity shield_0; // this is summoned onSpawn
	
private void rotateShields() // this is called every tick from aiStep
{
    rotation_0 = rotate(rotation_0, 5f);
    rotation_1 = rotation_0 + 90.0f;

    if (this.shield_0 != null)
    {
        double shieldX = this.getX() + Math.cos(Math.toRadians(rotation_0)) * 2;
        double shieldZ = this.getZ() + Math.sin(Math.toRadians(rotation_0)) * 2;
        this.shield_0.setPos(shieldX, this.getY() + 2, shieldZ);
        this.shield_0.setYRot((rotation_0 - 90.0f));
    }
}
    
private float rotation_0;
float rotate(float rot, float timePerLoop)
{
    timePerLoop = 360.0f / (20 * timePerLoop);

    if (rot < 360)
        rot += timePerLoop;

    else { rot = 0; }

    return rot;
}

For some reason, the rotation of the entity works just fine while the y-pos of the entity slowly falls down until it hits the ground and jumps back up to where it is supposed to go.

I even did a "System.out.println(this.shield_0.getY());" and that prints out the correct y-value at a stable rate while the actual entity position in-game is wonky.

This strange behavior is leading me to believe that there is some weird syncing issue, but I have no idea how to solve it or why it's happening.

Edited by Koi
I figured it out
Link to comment
Share on other sites

  • Koi changed the title to Some sort of syncing issue? (Resolved)

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.



×
×
  • Create New...

Important Information

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