fixed some orientation errors

This commit is contained in:
2025-07-14 00:06:44 +02:00
parent 8851f3c032
commit 0bfb031212

View File

@ -6,6 +6,8 @@ import org.bukkit.Location;
import org.bukkit.NamespacedKey;
import org.bukkit.block.BlockFace;
import org.bukkit.block.data.Directional;
import org.bukkit.block.data.type.Chest;
import org.bukkit.block.data.type.EnderChest;
import org.bukkit.entity.BlockDisplay;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
@ -74,19 +76,19 @@ public class Pixels {
}
private void setEntityRotation(Entity entity, @Nullable Directional direction) {
if(direction == null) return;
if(!(direction instanceof EnderChest || direction instanceof Chest)) return;
BlockFace blockFace = direction.getFacing();
float yaw = switch (blockFace) {
case NORTH -> 0;
case SOUTH -> 180;
case WEST -> -90;
case EAST -> 90;
case NORTH -> 180;
case SOUTH -> 0;
case WEST -> 90;
case EAST -> -90;
default -> entity.getLocation().getYaw();
};
float pitch = switch (blockFace) {
case UP -> -90;
case DOWN -> 90;
case UP -> 90;
case DOWN -> -90;
default -> 0;
};
entity.setRotation(yaw, pitch);