Jump to content

Updating an entity's position with the world server


The_Basset_Hound

Recommended Posts

Hello,


I'm trying to create a vacuum item that pulls item entities around the player in when they are left clicking. So far I have it working, but adding the velocity to the item entity only seems to be working on the client side (item entities will go towards the player but not into the player's inventory, and when the player is near them they teleport back to where they had been before using the vacuum). That's the issue as I understand it, but it might be something else entirely. I have done nothing with server/client interaction so if that is the issue I don't know what to do. If anyone has a link to a tutorial or a mod that behaves like this, or can provide me an explanation of their own, I would very much appreciate it.

 

Link to the vacuum item in question

 

 

Thanks,

Basset

Link to comment
Share on other sites

I think I solved my issue. I took the onUpdate method and made it a player tick event listener, then checked to see whether or not the attack key was held down and whether or not the event.player was holding the item, and if both of those are true, pull items in. My issue was probably with me using player.getWorld() instead of player.world.

 

the new ItemVacpack (tick event listener is at bottom of file)

 

i would still like to know more about the issue, though. What is the difference between Entity.getWorld() and Entity.world?

Edited by The_Basset_Hound
Link to comment
Share on other sites

3 hours ago, The_Basset_Hound said:

What is the difference between Entity.getWorld() and Entity.world?

None, they return the same object.

 

3 hours ago, The_Basset_Hound said:

I took the onUpdate method and made it a player tick event listener, then checked to see whether or not the attack key was held down

You can't do this since key presses are a client-only thing. It works on the physical client but it will crash the physical server. Also you are reaching across logical sides which is never good.

 

 

Link to comment
Share on other sites

14 hours ago, V0idWa1k3r said:

None, they return the same object.

 

You can't do this since key presses are a client-only thing. It works on the physical client but it will crash the physical server. Also you are reaching across logical sides which is never good.

 

 

Okay, you've told me what I'm doing wrong, but I'm still not sure how to make it right. What technique do I use to do this correctly?

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.