-
-
Notifications
You must be signed in to change notification settings - Fork 348
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Teleport pets with player #7400
base: master
Are you sure you want to change the base?
Conversation
not sure this is something wanted in towny or if it will cause any issues, possible considerations are checking if the location is safe for pets or adding a config node or something just lmk and i will change things |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whether pets are teleported & the radius should have config options at least
* | ||
* @param player The player to get the pets of | ||
*/ | ||
public static List<Entity> getPets(Player player) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public static List<Entity> getPets(Player player) { | |
public static Collection<Entity> getPets(Player player) { | |
AnimalTamer tamer = tameable.getOwner(); | ||
if (tamer == null) continue; | ||
|
||
if (!(entity instanceof Sittable sittable)) continue; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about non sittable pets? When #6865 is merged the types of entities that are teleported could be made configurable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what pets are non-sittable that also follow you like a dog or cat
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or do you mean for adding things like horses, camels etc.
if that's the case i could change it to check if they are currently riding something
for (Entity entity : player.getNearbyEntities(16, 16, 16)) { | ||
if (!(entity instanceof Tameable tameable)) continue; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for (Entity entity : player.getNearbyEntities(16, 16, 16)) { | |
if (!(entity instanceof Tameable tameable)) continue; | |
for (Tameable tameable : player.getLocation().getNearbyEntitiesByType(Tameable.class, 16)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this method doesn't seem to exist
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was looking at the paper javadocs, but the same method exists on World on spigot
* @param entities Entities to teleport | ||
* @param cause What caused the teleport | ||
*/ | ||
public static void teleportEntities(Location loc, List<Entity> entities, TeleportCause cause) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public static void teleportEntities(Location loc, List<Entity> entities, TeleportCause cause) { | |
public static void teleportEntities(Location loc, Iterable<Entity> entities, TeleportCause cause) { |
List<Entity> pets = SpawnUtil.getPets(player); | ||
pets.add(player); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be better to call it entities since the player is added to it (and is not a pet)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Came here to say this.
not sure how i should specifically implement this, it would be easiest to just get all nearby tamed entities owned by the player and tp them but that could be a bit unnatural if we want to build in the ability to teleport "pets" that are rideable like horses and stuff since rideables that are nearby and not being ridden by the player would also be teleported under that simple implementation most servers would probably limit it to just sittables like wolves, cats, parrots etc. but it would be possible to split it into to two settings like teleport sittables and teleport vehicle with their own lists or something along those lines |
This is how I would imagine it would work:
I am guessing that animals which are following you that aren't sitting, cats, dogs, parrots currently sometimes don't teleport with the player? I would have thought when you moved they would teleport with you. I know that we eject the player off of any horse if they're currently riding for some esoteric reason that's lost to time. |
since the chunk becomes unloaded as the player leaves, unless another player is remaining to load those chunks and trigger a tp to the pet owner's new location they will stay there i've had pets on earthmc that i've completely forgotten about tp to me from the middle of nowhere presumably because some random new player loaded those chunks while i happened to be online |
Description:
When teleporting, pets can get left behind and lost forever if in unloaded chunks. This PR now additionally teleports any non-sitting tamed pets owned by and nearby the player on teleport.
There is also a refactor to have one unified
teleportEntities
method rather than usingPaperLib.teleportAsync
multiple times to make it a bit more maintainable now that we are teleporting many things.New Nodes/Commands/ConfigOptions:
N/A
Relevant Towny Issue ticket:
N/A
By making this pull request, I represent that I have the right to waive copyright and related rights to my contribution, and agree that all copyright and related rights in my contributions are waived, and I acknowledge that the TownyAdvanced organization has the copyright to use and modify my contribution under the Towny License for perpetuity.