Skip to content

Commit a4bb980

Browse files
Add fallback for world_gen_settings.dat
Paper servers modify the world structure a little which stopped Amulet from opening the world. With this small modification, Paper worlds can be opened as well as worlds where that file does not exist for some reason.
1 parent 99a4338 commit a4bb980

1 file changed

Lines changed: 28 additions & 4 deletions

File tree

amulet/level/formats/anvil_world/format.py

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -246,11 +246,35 @@ def _register_dimension(
246246
def _get_dimenion_bounds(self, dimension_type_str: Dimension) -> SelectionGroup:
247247
if self.version >= 2709: # This number might be smaller
248248
if self.version >= 4786: # This number might be smaller
249-
world_gen_settings = load_nbt(
250-
os.path.join(
251-
self.path, "data", "minecraft", "world_gen_settings.dat"
249+
world_gen_settings_path = os.path.join(
250+
self.path, "data", "minecraft", "world_gen_settings.dat"
251+
)
252+
if not os.path.isfile(world_gen_settings_path):
253+
world_gen_settings_path = os.path.join(
254+
self.path,
255+
"dimensions",
256+
"minecraft",
257+
"overworld",
258+
"data",
259+
"minecraft",
260+
"world_gen_settings.dat",
261+
)
262+
if os.path.isfile(world_gen_settings_path):
263+
world_gen_settings = load_nbt(
264+
world_gen_settings_path
265+
).compound.get_compound("data", CompoundTag())
266+
else:
267+
world_gen_settings = CompoundTag(
268+
{
269+
"dimensions": CompoundTag(
270+
{
271+
dimension_type_str: CompoundTag(
272+
{"type": StringTag("minecraft:overworld")}
273+
)
274+
}
275+
)
276+
}
252277
)
253-
).compound.get_compound("data", CompoundTag())
254278
else:
255279
# If in a version that supports custom height data packs
256280
world_gen_settings = self.root_tag.compound.get_compound(

0 commit comments

Comments
 (0)