Add data pack dimension support for Forge 1.16.5 and 1.17.1

This commit is contained in:
Mike Primm 2021-11-15 20:51:35 -06:00
parent 4610bba449
commit bf857b4b27
2 changed files with 18 additions and 13 deletions

View File

@ -38,17 +38,18 @@ public class ForgeWorld extends DynmapWorld
public static String getWorldName(IServerWorld w) {
RegistryKey<World> rk = w.getWorld().getDimensionKey();
if (rk == World.OVERWORLD) { // Overworld?
String id = rk.getLocation().getNamespace() + "_" + rk.getLocation().getPath();
if (id.equals("minecraft_overworld")) { // Overworld?
return w.getWorld().getServer().getServerConfiguration().getWorldName();
}
else if (rk == World.THE_END) {
else if (id.equals("minecraft_the_end")) {
return "DIM1";
}
else if (rk == World.THE_NETHER) {
else if (id.equals("minecraft_the_nether")) {
return "DIM-1";
}
else {
return rk.getRegistryName().getNamespace() + "_" + rk.getRegistryName().getPath();
return id;
}
}
@ -58,7 +59,7 @@ public class ForgeWorld extends DynmapWorld
w.getWorld().getSeaLevel(),
w.getWorld().getDimensionKey() == World.THE_NETHER,
w.getWorld().getDimensionKey() == World.THE_END,
w.getWorld().getDimensionKey().getRegistryName().getPath());
getWorldName(w));
setWorldLoaded(w);
}
public ForgeWorld(String name, int height, int sealevel, boolean nether, boolean the_end, String deftitle)

View File

@ -38,15 +38,19 @@ public class ForgeWorld extends DynmapWorld
public static String getWorldName(ServerLevelAccessor w) {
ResourceKey<Level> rk = w.getLevel().dimension();
if (rk == Level.OVERWORLD) { // Overworld?
String id = rk.location().getNamespace() + "_" + rk.location().getPath();
if (id.equals("minecraft_overworld")) { // Overworld?
return w.getLevel().serverLevelData.getLevelName();
} else if (rk == Level.END) {
return "DIM1";
} else if (rk == Level.NETHER) {
return "DIM-1";
} else {
return rk.getRegistryName() + "_" + rk.location();
}
}
else if (id.equals("minecraft_the_end")) {
return "DIM1";
}
else if (id.equals("minecraft_the_nether")) {
return "DIM-1";
}
else {
return id;
}
}
public void updateWorld(ServerLevelAccessor w) {