From 82725b5e325088a67c75810b4bb5ced76a67de9d Mon Sep 17 00:00:00 2001 From: NxDs <7994264+nxds@users.noreply.github.com> Date: Fri, 10 Feb 2023 18:32:44 -0500 Subject: [PATCH] Add BlockFace#fromDirection (cherry picked from commit cc39a90857f6fbcb4ba64cd76dbcf2ec37c27644) --- .../server/instance/block/BlockFace.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/main/java/net/minestom/server/instance/block/BlockFace.java b/src/main/java/net/minestom/server/instance/block/BlockFace.java index 680486866..ec69fe236 100644 --- a/src/main/java/net/minestom/server/instance/block/BlockFace.java +++ b/src/main/java/net/minestom/server/instance/block/BlockFace.java @@ -60,4 +60,21 @@ public enum BlockFace { return BlockFace.WEST; } } + + /** + * Get the BlockFace corresponding to the given {@link Direction}. + * + * @param direction the direction + * @return the corresponding BlockFace + */ + public static BlockFace fromDirection(Direction direction) { + return switch (direction) { + case UP -> TOP; + case DOWN -> BOTTOM; + case NORTH -> NORTH; + case SOUTH -> SOUTH; + case WEST -> WEST; + case EAST -> EAST; + }; + } }