Reading writing dat files

I mean it does, it’s just not in the form factor that you are requesting i.e. .dat files.

Well I’m toying with the level_sponge.dat for importing non sponge worlds so the form factor is important

While you’ll still have to write the object yourself, SpongeCommon has NbtTranslator while will create NBTTagCompound (the raw MC class) from a DataContainer and vice versa.

I noticed that when I was doing some research last night, but I’m not sure how to access SpongeCommon from my project

You just need to include it as a dependency in gradle/maven instead of SpongeAPI - but be aware this means your plugin would only work with Sponge version that use SpongeCommon (currently, SpongeForge and SpongeVanilla).

Actually that doesn’t work. There is an issue with the maven dependencies.

There is a PR to fix it, but i don’t think it has gone through yet…

What do you mean? Non sponge worlds should import fine into sponge. Sponge just uses mc world format and just adds data. It doesn’t actually change any base minecraft storage…

From my testing, Sponge will not detect worlds unless they a level_sponge.dat file in them.

Is this spongeforge or spongevanilla?

I know in spongeforge, Minecraft Forge is responsible for loading the world, and then sponge just adds its extra metadata. Spongevannilla might behave differently.

This is sounding like a bug more than anything. I would create an issue or make a pull request.

SpongeForge. I haven’t done any testing with SpongeVanilla. I assumed this was just the way it is, and was the reason people were requesting I add import support for my multi world plugin. Please don’t tell me all that work was for nothing

I would try to talk to one of the sponge devs about how world loading works.
Just putting a world into the world folder does not mean it will load. A plugin has to try and actually load it.
However once you load the world, Sponge SHOULD automatically add it’s own data. If it doesn’t, that is a bug.

I see. OK i just attempted the load a world and it did generate the data file and loaded but it didn’t generate a unique dimension id so it ended up unloading the default world due to id conflict.

You know, it would’ve been better to just start from the get go that SpongeForge doesn’t import old worlds if they were in the top directory (like how Bukkit structured worlds). This is an xy problem where you ask how to read/write to level_sponge.dat files, when in reality you just wanted to import old worlds into sponge. Submit the issue on github for SpongeForge and we’ll get to it very very soon.

3 Likes

Yeah probably but I read somewhere that bukkit worlds had to be imported through manual process which is why I didn’t ask. May have been an old thread or something.

I’ll give you a hint, although specific questions are easier to answer, it’s almost always good to just blurt out everything at once. Let the pros do the filtering for you.

Little addition:
A huge load of blurt doesn’t help, but a few sentences on what you’re trying to achieve and some things you already tried usually helps a whole lot.

1 Like

I mean in the context of the xy problem, blurt is better than ommission

1 Like

OK lets just say mistakes were made. That’s my bad. I created an issue ticket

https://github.com/SpongePowered/SpongeForge/issues/441

3 Likes

High fives

lolztext 2 sooperced teh 15 char min.

Related: SpongeDocs issue about migrating bukkit worlds.

There is also this thread which discusses the problem in more detail.