Jump to content

Recommended Posts

Posted

Hello, I have a tile that 'sucks' in nearby items, however, the motion of the items are super choppy, and seemed off-sycned. Is this a networking issue? If so how would I fix this?

 

and here is the code applying the motion:

Spoiler

        List<EntityItem> nearbyItems = this.world.getEntitiesWithinAABB(EntityItem.class, new AxisAlignedBB(
                this.getPos().getX()-10, this.getPos().getY()-10, this.getPos().getZ()-10,
                this.getPos().getX()+10, this.getPos().getY()+10, this.getPos().getZ()+10
        ));
        if(nearbyItems.size() <= 0) return;

        for(EntityItem item : nearbyItems){
            double moveFactor = 0.035d;
            item.motionX += (this.getPos().getX() - item.getPosition().getX()) * moveFactor;
            item.motionY += (this.getPos().getY() - item.getPosition().getY()) * moveFactor;
            item.motionZ += (this.getPos().getZ() - item.getPosition().getZ()) * moveFactor;
            item.move(MoverType.SELF, item.motionX, item.motionY, item.motionZ);

        }

 

 

 

Posted
2 hours ago, unassigned said:

item.move(MoverType.SELF, item.motionX, item.motionY, item.motionZ);

Don't call Entity#move, since the item is going to move on it's own each tick based on the motion values it has.Your movement is choppy because the item is moved twice per tick.

Apart from that I don't know if there are solutions to the position desync that occurs, especially when collisions happen. 

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.