Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@

import net.minecraft.core.BlockPos;
import net.minecraft.core.Vec3i;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.pathfinder.Node;
import net.minecraft.world.phys.Vec3;
import org.bukkit.Location;
import org.bukkit.World;
import org.jspecify.annotations.Nullable;

public final class CraftLocation {

Expand Down Expand Up @@ -65,8 +68,9 @@ public static net.minecraft.core.GlobalPos toGlobalPos(Location loc) {
return net.minecraft.core.GlobalPos.of(((org.bukkit.craftbukkit.CraftWorld) loc.getWorld()).getHandle().dimension(), toBlockPosition(loc));
}

public static Location fromGlobalPos(net.minecraft.core.GlobalPos globalPos) {
return CraftLocation.toBukkit(globalPos.pos(), net.minecraft.server.MinecraftServer.getServer().getLevel(globalPos.dimension()));
public static @Nullable Location fromGlobalPos(net.minecraft.core.GlobalPos globalPos) {
ServerLevel level = MinecraftServer.getServer().getLevel(globalPos.dimension());
return level != null ? CraftLocation.toBukkit(globalPos.pos(), level) : null;
}

public static Vec3 toVec3(Location loc) {
Expand Down
Loading