-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Remove spectator players' cameras when teleporting #13478
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1317,7 +1317,23 @@ protected boolean teleport0(Location location, org.bukkit.event.player.PlayerTel | |
| return false; | ||
| } | ||
|
|
||
| return super.teleport0(location, cause, flags); | ||
| // Paper start - stop spectating other entities on teleport | ||
| // return super.teleport0(location, cause, flags); | ||
| // Attempt to set the camera first | ||
| Entity camera = this.getHandle().getCamera(); | ||
| this.getHandle().setCamera(null); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It looks like in most cases (except one) where camera is reset it uses setCamera(self), so you may want to setCamera(this.getHandle()) |
||
| if (camera != this.getHandle() && camera == this.getHandle().getCamera()) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If an event changes the camera to a different new entity the teleport will still be broken, not sure but I think for any spectated entity you should cancel the teleport
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i think this can just be replaced with the this.getHandle().setCamera(this.getHandle());
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good point, I'll change that to check for any entity.
Would that not still change the camera even if the teleport is cancelled?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually, how can the event change the camera? PlayerStopSpectatingEntityEvent is immutable, except for being cancellable. I'll update the check regardless but I don't think it will meaningfully change the behaviour
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
In teory but maybe the cancel state already manage that, like say you can test that behaviour but i dont find issue in cancel with the setCamera called
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ref: Doc94@0661918
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This breaks for me:
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
that two then also happen using teleport command and mess with events too no? for the PlayerTeleportEvent make sense because first dismount/cancel-spect and then teleport then i feel its expected
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh that's a very good point actually, I hadn't considered that. I don't think that behaviour makes much sense regardless of where it's coming from - potentially another paper bug? ServerPlayer#teleportTo has a
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hmm im calling the expert in teleportations thing here... @Owen1212055 |
||
| // If the camera hasn't changed, it was likely cancelled by an event, so stop the teleport | ||
| return false; | ||
| } | ||
|
Comment on lines
+1322
to
+1325
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This kind of prompts additional conversation, but we may want to instead just have some kind of boolean on the set camera to ignore the canceling of those events. As there is a lot of places where this can occur and I don't really think we handle this logic at all (and instead just allow them to be teleported back a tick later or whatever) |
||
|
|
||
| boolean teleported = super.teleport0(location, cause, flags); | ||
| if (!teleported) { | ||
| // If the teleport doesn't go through, restore the original camera | ||
| this.getHandle().setCamera(camera); | ||
| } | ||
| return teleported; | ||
| // Paper end - stop spectating other entities on teleport | ||
| } | ||
|
|
||
| @Override | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.