diff --git a/src/main/java/xyz/nucleoid/plasmid/game/player/LocalPlayerOffer.java b/src/main/java/xyz/nucleoid/plasmid/game/player/LocalPlayerOffer.java index 8ad58bcd..059043e8 100644 --- a/src/main/java/xyz/nucleoid/plasmid/game/player/LocalPlayerOffer.java +++ b/src/main/java/xyz/nucleoid/plasmid/game/player/LocalPlayerOffer.java @@ -18,8 +18,8 @@ public GameProfile profile() { } @Override - public PlayerOfferResult.Accept accept(ServerWorld world, Vec3d position) { - return new Accept(world, position); + public PlayerOfferResult.Accept accept(ServerWorld world, Vec3d position, float yaw, float pitch) { + return new Accept(world, position, yaw, pitch); } @Override @@ -30,12 +30,16 @@ public PlayerOfferResult.Reject reject(Text reason) { public static class Accept implements PlayerOfferResult.Accept { private final ServerWorld world; private final Vec3d position; + private final float yaw; + private final float pitch; private final List> thenRun = new ArrayList<>(); - Accept(ServerWorld world, Vec3d position) { + Accept(ServerWorld world, Vec3d position, float yaw, float pitch) { this.world = world; this.position = position; + this.yaw = yaw; + this.pitch = pitch; } @Override @@ -46,7 +50,7 @@ public Accept thenRun(Consumer consumer) { public ServerWorld applyJoin(ServerPlayerEntity player) { player.changeGameMode(GameMode.SURVIVAL); - player.refreshPositionAndAngles(this.position.x, this.position.y, this.position.z, 0.0F, 0.0F); + player.refreshPositionAndAngles(this.position.x, this.position.y, this.position.z, this.yaw, this.pitch); for (Consumer consumer : this.thenRun) { consumer.accept(player); diff --git a/src/main/java/xyz/nucleoid/plasmid/game/player/PlayerOffer.java b/src/main/java/xyz/nucleoid/plasmid/game/player/PlayerOffer.java index 685df714..bd697897 100644 --- a/src/main/java/xyz/nucleoid/plasmid/game/player/PlayerOffer.java +++ b/src/main/java/xyz/nucleoid/plasmid/game/player/PlayerOffer.java @@ -10,6 +10,7 @@ import xyz.nucleoid.plasmid.game.event.GamePlayerEvents; import java.util.UUID; +import java.util.function.Consumer; /** * Represents a request for a {@link ServerPlayerEntity} to join a {@link GameSpace}. @@ -48,10 +49,27 @@ default String playerName() { * * @param world the world that the player should be teleported to when accepted * @param position the position that the player should be teleported to when accepted + * @param yaw the 'yaw' angle that the player should be teleported to when accepted + * @param pitch the 'pitch' angle that the player should be teleported to when accepted * @return an "accept" offer result - * @see PlayerOfferResult.Accept#thenRun(java.util.function.Consumer) + * @see PlayerOfferResult.Accept#thenRun(Consumer) */ - PlayerOfferResult.Accept accept(ServerWorld world, Vec3d position); + PlayerOfferResult.Accept accept(ServerWorld world, Vec3d position, float yaw, float pitch); + + /** + * Returns an offer result that accepts this player offer and allows the player into this {@link GameSpace}. + *

+ * This function does not do anything on its own, but its result must be returned within a + * {@link GamePlayerEvents#OFFER} listener. + * + * @param world the world that the player should be teleported to when accepted + * @param position the position that the player should be teleported to when accepted + * @return an "accept" offer result + * @see PlayerOfferResult.Accept#thenRun(Consumer) + */ + default PlayerOfferResult.Accept accept(ServerWorld world, Vec3d position) { + return this.accept(world, position, 0.0f, 0.0f); + } /** * Returns an offer result that rejects this player offer and does not allow the player into this {@link GameSpace}.