From ced562fdd1da941c91ce39328f7a7a00e023f704 Mon Sep 17 00:00:00 2001 From: Trumeet Date: Thu, 14 Jul 2022 11:57:49 -0700 Subject: Add pos and world in Entity API:ADD Signed-off-by: Trumeet --- src/main/java/moe/ymc/acron/common/WorldKey.java | 25 +++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'src/main/java/moe/ymc/acron/common') diff --git a/src/main/java/moe/ymc/acron/common/WorldKey.java b/src/main/java/moe/ymc/acron/common/WorldKey.java index 9e4212d..fa10d54 100644 --- a/src/main/java/moe/ymc/acron/common/WorldKey.java +++ b/src/main/java/moe/ymc/acron/common/WorldKey.java @@ -1,6 +1,12 @@ package moe.ymc.acron.common; import com.google.gson.annotations.SerializedName; +import net.minecraft.util.Identifier; +import net.minecraft.world.dimension.DimensionType; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; public enum WorldKey { @SerializedName("overworld") @@ -8,5 +14,22 @@ public enum WorldKey { @SerializedName("nether") NETHER, @SerializedName("end") - END + END; + + private static final Logger LOGGER = LogManager.getLogger(); + + public static @Nullable WorldKey create(@NotNull Identifier identifier) { + if (identifier.equals(DimensionType.OVERWORLD_ID)) { + return OVERWORLD; + } else if (identifier.equals(DimensionType.THE_NETHER_ID)) { + return NETHER; + } else if (identifier.equals(DimensionType.THE_END_ID)) { + return END; + } else { + LOGGER.warn("Unknown world {}:{}. Returning NULL to the client.", + identifier.getNamespace(), + identifier.getPath()); + return null; + } + } } \ No newline at end of file -- cgit v1.2.3