Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Fix MCServerChunkGenerator #450

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
12 changes: 8 additions & 4 deletions src/mceditlib/minecraft_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import urllib

from mceditlib import worldeditor
from mceditlib.anvil.adapter import AnvilWorldAdapter
from mceditlib.exceptions import ChunkNotPresent
from mceditlib.directories import appSupportDir
from mceditlib.util import exhaust
Expand Down Expand Up @@ -317,11 +318,12 @@ def createReadme(self):
def tempWorldForLevel(self, level):

# tempDir = tempfile.mkdtemp("mclevel_servergen")
tempDir = os.path.join(self.worldCacheDir, self.jarStorage.checksumForVersion(self.serverVersion), str(level.RandomSeed))
seed = level.getWorldMetadata().RandomSeed
tempDir = os.path.join(self.worldCacheDir, self.jarStorage.checksumForVersion(self.serverVersion), str(seed))
propsFile = os.path.join(tempDir, "server.properties")
properties = readProperties(propsFile)

tempWorld = self.tempWorldCache.get((self.serverVersion, level.RandomSeed))
tempWorld = self.tempWorldCache.get((self.serverVersion, seed))

if tempWorld is None:
if not os.path.exists(tempDir):
Expand All @@ -332,12 +334,14 @@ def tempWorldForLevel(self, level):
worldName = properties.setdefault("level-name", worldName)

tempWorldDir = os.path.join(tempDir, worldName)
tempWorld = worldeditor.WorldEditor(tempWorldDir, create=not os.path.exists(tempWorldDir), random_seed=level.RandomSeed)
tempWorld = worldeditor.WorldEditor(tempWorldDir, create=not os.path.exists(tempWorldDir), adapterClass=AnvilWorldAdapter)
tempWorld.getWorldMetadata().RandomSeed = seed
tempWorld.adapter.syncToDisk() # Write updated seed to level.dat
tempWorld.close()

tempWorldRO = worldeditor.WorldEditor(tempWorldDir, readonly=True)

self.tempWorldCache[self.serverVersion, level.RandomSeed] = tempWorldRO
self.tempWorldCache[self.serverVersion, seed] = tempWorldRO

if level.dimNo == 0:
properties["allow-nether"] = "false"
Expand Down