9
0
mirror of https://github.com/Xiao-MoMi/craft-engine.git synced 2025-12-28 19:39:11 +00:00

修复座椅行为玩家朝向不正常

This commit is contained in:
jhqwqmc
2025-11-08 05:53:50 +08:00
parent e00035adf5
commit a5151767bb
2 changed files with 14 additions and 2 deletions

View File

@@ -59,11 +59,23 @@ public class SeatBlockEntity extends BlockEntity implements SeatOwner {
}
for (Seat<SeatBlockEntity> seat : this.seats) {
if (!seat.isOccupied()) {
if (seat.spawnSeat(player, new WorldPosition(super.world.world(), super.pos.x() + 0.5, super.pos.y(), super.pos.z() + 0.5, 0, 180 - yRot))) {
if (seat.spawnSeat(player, new WorldPosition(super.world.world(), super.pos.x() + 0.5, super.pos.y(), super.pos.z() + 0.5, 180 - yRot, getYRot()))) {
return true;
}
}
}
return false;
}
private float getYRot() {
Property<?> facing = super.blockState.owner().value().getProperty("facing");
if (facing == null || facing.valueClass() != HorizontalDirection.class) return 0;
HorizontalDirection direction = (HorizontalDirection) super.blockState.get(facing);
return switch (direction) {
case NORTH -> 0;
case SOUTH -> 180;
case WEST -> 270;
case EAST -> 90;
};
}
}

View File

@@ -28,7 +28,7 @@ import org.jetbrains.annotations.NotNull;
import java.io.IOException;
public class BukkitSeatManager implements SeatManager {
public class BukkitSeatManager implements SeatManager, Listener {
private static BukkitSeatManager instance;
public static final NamespacedKey SEAT_KEY = KeyUtils.toNamespacedKey(SeatManager.SEAT_KEY);
public static final NamespacedKey SEAT_EXTRA_DATA_KEY = KeyUtils.toNamespacedKey(SeatManager.SEAT_EXTRA_DATA_KEY);