-
-
Notifications
You must be signed in to change notification settings - Fork 211
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
Fix MoveEntityEvent.Teleport isn't fired when a player uses the spectator-menu to teleport #2239
Fix MoveEntityEvent.Teleport isn't fired when a player uses the spectator-menu to teleport #2239
Conversation
…tor menu to teleport fix #2099
this.player.setSpectatingEntity(this.player); | ||
this.player.dismountRidingEntity(); | ||
// Sponge start - handle MoveEntityEvent.Teleport | ||
double x = entity.posX; |
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.
If all that is being done is based on the player, and entity, you should be able to reduce this to a single cancellable injection:
@Inject(
method = "handleSpectate",
at = @At(
value = "FIELD",
target = "Lnet/minecraft/entity/Entity;world:Lnet/minecraft/world/World;",
ordinal = 0
),
locals = LocalCapture.CAPTURE_FAILHARD,
cancellable = true
)
private void onSpectateTeleportForSponge(CPacketSpectate packetIn, CallbackInfo ci, Entity spectatingEntity) {
double x = spectatingEntity.posX;
double y = spectatingEntity.posY;
double z = spectatingEntity.posZ;
float yaw = spectatingEntity.rotationYaw;
float pitch = spectatingEntity.rotationPitch;
MoveEntityEvent.Teleport event = EntityUtil.handleDisplaceEntityTeleportEvent(this.player, x, y, z, yaw, pitch);
if (event.isCancelled()) {
ci.cancel();
}
}
Also, make sure your javadoc includes @author
and the date, and the version of Minecraft targeted.
I've tested this injection in development and this is the result:
Change to cancellable injection. |
src/main/java/org/spongepowered/common/mixin/core/network/MixinNetHandlerPlayServer.java
Outdated
Show resolved
Hide resolved
Because I don't want to use @Inject three times, I use @overwrite
I also have a question. |
@karayuumac Thanks for your contribution. You seem to have reverted your changes with this commit ce629ae.
As far as I can see you don't need to. It's already handled in |
Thank you for asking my question. I understood.
OK. I'll try to change to cancellable injection. |
I checked my code and I think cancellable injection can't be used in this case. Is it possible to implement this by injection? |
Thanks for the contribution! It is possible to implement it all without overwriting the method, it just gets a little messy. Superseded by 620cc8a |
fix #2099