From a5151767bbb2fbcc2c8c6b77d0562b1bd9520c8f Mon Sep 17 00:00:00 2001 From: jhqwqmc Date: Sat, 8 Nov 2025 05:53:50 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=BA=A7=E6=A4=85?= =?UTF-8?q?=E8=A1=8C=E4=B8=BA=E7=8E=A9=E5=AE=B6=E6=9C=9D=E5=90=91=E4=B8=8D?= =?UTF-8?q?=E6=AD=A3=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bukkit/block/entity/SeatBlockEntity.java | 14 +++++++++++++- .../bukkit/entity/seat/BukkitSeatManager.java | 2 +- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/bukkit/src/main/java/net/momirealms/craftengine/bukkit/block/entity/SeatBlockEntity.java b/bukkit/src/main/java/net/momirealms/craftengine/bukkit/block/entity/SeatBlockEntity.java index 360e58f38..8b520e63a 100644 --- a/bukkit/src/main/java/net/momirealms/craftengine/bukkit/block/entity/SeatBlockEntity.java +++ b/bukkit/src/main/java/net/momirealms/craftengine/bukkit/block/entity/SeatBlockEntity.java @@ -59,11 +59,23 @@ public class SeatBlockEntity extends BlockEntity implements SeatOwner { } for (Seat 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; + }; + } } diff --git a/bukkit/src/main/java/net/momirealms/craftengine/bukkit/entity/seat/BukkitSeatManager.java b/bukkit/src/main/java/net/momirealms/craftengine/bukkit/entity/seat/BukkitSeatManager.java index 9e45aa593..2e52d5564 100644 --- a/bukkit/src/main/java/net/momirealms/craftengine/bukkit/entity/seat/BukkitSeatManager.java +++ b/bukkit/src/main/java/net/momirealms/craftengine/bukkit/entity/seat/BukkitSeatManager.java @@ -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); From b9cee377d8d383752d70170c239009c410307e1a Mon Sep 17 00:00:00 2001 From: jhqwqmc Date: Sat, 8 Nov 2025 06:04:12 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=BA=A7=E6=A4=85?= =?UTF-8?q?=E8=A1=8C=E4=B8=BA=E7=8E=A9=E5=AE=B6=E6=9C=9D=E5=90=91=E4=B8=8D?= =?UTF-8?q?=E6=AD=A3=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bukkit/block/entity/SeatBlockEntity.java | 42 +++++-------------- 1 file changed, 11 insertions(+), 31 deletions(-) diff --git a/bukkit/src/main/java/net/momirealms/craftengine/bukkit/block/entity/SeatBlockEntity.java b/bukkit/src/main/java/net/momirealms/craftengine/bukkit/block/entity/SeatBlockEntity.java index 8b520e63a..421e8f94e 100644 --- a/bukkit/src/main/java/net/momirealms/craftengine/bukkit/block/entity/SeatBlockEntity.java +++ b/bukkit/src/main/java/net/momirealms/craftengine/bukkit/block/entity/SeatBlockEntity.java @@ -1,6 +1,5 @@ package net.momirealms.craftengine.bukkit.block.entity; -import net.momirealms.craftengine.bukkit.block.behavior.SeatBlockBehavior; import net.momirealms.craftengine.bukkit.entity.seat.BukkitSeat; import net.momirealms.craftengine.core.block.ImmutableBlockState; import net.momirealms.craftengine.core.block.entity.BlockEntity; @@ -14,8 +13,6 @@ import net.momirealms.craftengine.core.world.BlockPos; import net.momirealms.craftengine.core.world.WorldPosition; import net.momirealms.sparrow.nbt.CompoundTag; -import java.util.Optional; - public class SeatBlockEntity extends BlockEntity implements SeatOwner { private final Seat[] seats; @@ -41,41 +38,24 @@ public class SeatBlockEntity extends BlockEntity implements SeatOwner { } public boolean spawnSeat(Player player) { - Optional seatBehavior = super.blockState.behavior().getAs(SeatBlockBehavior.class); - if (seatBehavior.isEmpty()) { - return false; - } - float yRot = 0; - Property directionProperty = seatBehavior.get().directionProperty(); - if (directionProperty != null) { - HorizontalDirection direction = super.blockState.get(directionProperty); - if (direction == HorizontalDirection.NORTH) { - yRot = 180; - } else if (direction == HorizontalDirection.EAST) { - yRot = -90; - } else if (direction == HorizontalDirection.WEST) { - yRot = 90; - } + Property facing = super.blockState.owner().value().getProperty("facing"); + int yRot = 0; + if (facing != null && facing.valueClass() == HorizontalDirection.class) { + HorizontalDirection direction = (HorizontalDirection) super.blockState.get(facing); + yRot = switch (direction) { + case NORTH -> 0; + case SOUTH -> 180; + case WEST -> 270; + case EAST -> 90; + }; } for (Seat 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, 180 - yRot, getYRot()))) { + if (seat.spawnSeat(player, new WorldPosition(super.world.world(), super.pos.x() + 0.5, super.pos.y(), super.pos.z() + 0.5, 0, yRot))) { 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; - }; - } }