I’m new to Fabric mod development and I’ve come across an interesting issue. I need a World instance for certain actions within my mod, but I don’t know how to get it. I tried the solutions for Forge but the class names are different and I can’t find the appropriate ones in Fabric. I also checked the wiki but they only write about creating custom worlds.
Is there a way of getting a world instance by the world’s name? Or just for getting the list of worlds?
There is no way to get any world instance on the client. This has 2 pretty obvious reasons:
- Not all worlds are not loaded/present on the client side for the sake of memory, cpu and network usage.
- Security. The client doesn’t need to know which dimensions are available, so why should the server tell it? If you know which dimensions are available, you might be able to find wayarounds of in-game limitations, especially if these are custom dimensions.
You can however get a certain world instance: the client’s currently loaded dimension. You can access it via
MinecraftClient.getInstance().world, which points to a