fixed respawn event (player returning from end to overworld)

This commit is contained in:
Pierre Kisters 2020-08-16 03:22:37 +02:00
parent ae40a6f47e
commit 284def319a
4 changed files with 20 additions and 12 deletions

View File

@ -22,8 +22,8 @@ public class PlayerManagerMixin {
PlayerEvents.PLAYER_LOGGED_OUT.invoker().onPlayerLoggedOut(player);
}
@Inject(method = "respawnPlayer", at = @At("TAIL"))
@Inject(method = "respawnPlayer", at = @At("RETURN"))
public void respawnPlayer(ServerPlayerEntity player, boolean alive, CallbackInfoReturnable<ServerPlayerEntity> info) {
PlayerEvents.PLAYER_RESPAWN.invoker().onPlayerRespawn(player);
PlayerEvents.PLAYER_RESPAWN.invoker().onPlayerRespawn(info.getReturnValue());
}
}

View File

@ -12,15 +12,19 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(ServerPlayerEntity.class)
public class ServerPlayerEntityMixin {
@Inject(method = "teleport", at = @At("TAIL"))
@Inject(method = "teleport", at = @At("RETURN"))
public void teleport(ServerWorld targetWorld, double x, double y, double z, float yaw, float pitch, CallbackInfo info) {
ServerPlayerEntity player = (ServerPlayerEntity) (Object) this;
PlayerEvents.PLAYER_CHANGED_DIMENSION.invoker().onPlayerChangedDimension(player);
if (targetWorld != player.world) {
PlayerEvents.PLAYER_CHANGED_DIMENSION.invoker().onPlayerChangedDimension(player);
}
}
@Inject(method = "changeDimension", at = @At("TAIL"))
@Inject(method = "changeDimension", at = @At("RETURN"))
public void changeDimension(ServerWorld destination, CallbackInfoReturnable<Entity> info) {
ServerPlayerEntity player = (ServerPlayerEntity) (Object) this;
PlayerEvents.PLAYER_CHANGED_DIMENSION.invoker().onPlayerChangedDimension(player);
if (!player.removed) {
PlayerEvents.PLAYER_CHANGED_DIMENSION.invoker().onPlayerChangedDimension(player);
}
}
}

View File

@ -22,8 +22,8 @@ public class PlayerManagerMixin {
PlayerEvents.PLAYER_LOGGED_OUT.invoker().onPlayerLoggedOut(player);
}
@Inject(method = "respawnPlayer", at = @At("TAIL"))
@Inject(method = "respawnPlayer", at = @At("RETURN"))
public void respawnPlayer(ServerPlayerEntity player, boolean alive, CallbackInfoReturnable<ServerPlayerEntity> info) {
PlayerEvents.PLAYER_RESPAWN.invoker().onPlayerRespawn(player);
PlayerEvents.PLAYER_RESPAWN.invoker().onPlayerRespawn(info.getReturnValue());
}
}

View File

@ -12,15 +12,19 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(ServerPlayerEntity.class)
public class ServerPlayerEntityMixin {
@Inject(method = "teleport", at = @At("TAIL"))
@Inject(method = "teleport", at = @At("RETURN"))
public void teleport(ServerWorld targetWorld, double x, double y, double z, float yaw, float pitch, CallbackInfo info) {
ServerPlayerEntity player = (ServerPlayerEntity) (Object) this;
PlayerEvents.PLAYER_CHANGED_DIMENSION.invoker().onPlayerChangedDimension(player);
if (targetWorld != player.world) {
PlayerEvents.PLAYER_CHANGED_DIMENSION.invoker().onPlayerChangedDimension(player);
}
}
@Inject(method = "moveToWorld", at = @At("TAIL"))
@Inject(method = "moveToWorld", at = @At("RETURN"))
public void moveToWorld(ServerWorld destination, CallbackInfoReturnable<Entity> info) {
ServerPlayerEntity player = (ServerPlayerEntity) (Object) this;
PlayerEvents.PLAYER_CHANGED_DIMENSION.invoker().onPlayerChangedDimension(player);
if (!player.removed) {
PlayerEvents.PLAYER_CHANGED_DIMENSION.invoker().onPlayerChangedDimension(player);
}
}
}