-
Notifications
You must be signed in to change notification settings - Fork 10
Open
Labels
Description
Current scenario
entity.setLocation(Location)is used to update the location and send the proper SpawnPackets and EntityRemovePackets.- Location for players is set in the constructor, to prevent
setLocation()to be triggered - Locations for monsters is set through the constructor,
setLocation()is invoked to immidiately spawn monsters to it's surroundings entity.spawn()is used to invoke setLocation with the current location provided through the constructor, to spawn players.
Conclusion
This is nasty. It's really confusing and causes entities to spawn too soon or to late, throwing NullPointerExceptions or making the client crash.
Suggested implementation
- Remove
setLocation(), it's ambigious and should be never used. - Set the initial coordinates for an entity through it's constructor, but don't spawn it yet!
- Use the
walk,jumpandteleport(windscroll/portal) methods to spawn and move entities. These methods should remove the moving identity from players that resist only in the old view, send an entity spawn packet to the clients only in the new view, and optionally propagate a walk or jump packet. - Use the
spawn()(=teleport(CurrentLocation)) method to spawn entities initially and append them to the array of entities within the map (remove it from the old map as well)