Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Revert "Support dimensions with arbitrary directory names."

This reverts commit 90460f8.
  • Loading branch information...
commit 89648d77a229422a2f5d952503e7e1b51b52c8cb 1 parent e904341
@codewarrior0 codewarrior0 authored
Showing with 21 additions and 36 deletions.
  1. +14 −25 infiniteworld.py
  2. +0 −1  level.py
  3. +7 −10 mce.py
View
39 infiniteworld.py
@@ -1247,32 +1247,21 @@ def preloadDimensions(self):
for dirname in worldDirs:
if dirname.startswith("DIM"):
try:
- intInDirname = re.findall("\\d+", dirname)
- if len(intInDirname) > 0:
- dimNo = int(intInDirname[-1])
- else:
- dimNo = 999 # identical dimNo should not matter
+ dimNo = int(dirname[3:])
log.info("Found dimension {0}".format(dirname))
- dim = MCAlphaDimension(self, dimNo, dirname)
- self.dimensions[dirname] = dim
+ dim = MCAlphaDimension(self, dimNo)
+ self.dimensions[dimNo] = dim
except Exception, e:
log.error(u"Error loading dimension {0}: {1}".format(dirname, e))
- def getDimension(self, dimNo, dirname=None):
- if dirname is None:
- dirname = "DIM" + str(int(dimNo))
-
+ def getDimension(self, dimNo):
if self.dimNo != 0:
- return self.parentWorld.getDimension(dimNo, dirname)
-
- if dimNo == 0:
- return self
+ return self.parentWorld.getDimension(dimNo)
- if dirname in self.dimensions:
- return self.dimensions[dirname]
-
- dim = MCAlphaDimension(self, dimNo, dirname, create=True)
- self.dimensions[dirname] = dim
+ if dimNo in self.dimensions:
+ return self.dimensions[dimNo]
+ dim = MCAlphaDimension(self, dimNo, create=True)
+ self.dimensions[dimNo] = dim
return dim
# --- Region I/O ---
@@ -1696,22 +1685,22 @@ def createPlayer(self, playerName):
class MCAlphaDimension (MCInfdevOldLevel):
- def __init__(self, parentWorld, dimNo, dirname, create=False):
- filename = parentWorld.worldFolder.getFolderPath(dirname)
+ def __init__(self, parentWorld, dimNo, create=False):
+ filename = parentWorld.worldFolder.getFolderPath("DIM" + str(int(dimNo)))
+
self.parentWorld = parentWorld
MCInfdevOldLevel.__init__(self, filename, create)
self.dimNo = dimNo
self.filename = parentWorld.filename
self.players = parentWorld.players
self.playerTagCache = parentWorld.playerTagCache
- self.dirname = dirname
@property
def root_tag(self):
return self.parentWorld.root_tag
def __str__(self):
- return "MCAlphaDimension({0}, {1} ({2}))".format(self.parentWorld, self.dirname, self.dimNo)
+ return "MCAlphaDimension({0}, {1})".format(self.parentWorld, self.dimNo)
def loadLevelDat(self, create=False, random_seed=None, last_played=None):
pass
@@ -1727,7 +1716,7 @@ def _create(self, *args, **kw):
@property
def displayName(self):
return u"{0} ({1})".format(self.parentWorld.displayName,
- self.dimensionNames.get(self.dimNo, "%s (%d)" % (self.dirname, self.dimNo)))
+ self.dimensionNames.get(self.dimNo, "Dimension %d" % self.dimNo))
def saveInPlace(self, saveSelf=False):
"""saving the dimension will save the parent world, which will save any
View
1  level.py
@@ -139,7 +139,6 @@ class MCLevel(object):
dimNo = 0
parentWorld = None
world = None
- directory = None
@classmethod
def isLevel(cls, filename):
View
17 mce.py
@@ -1285,12 +1285,13 @@ def _dimension(self, command):
dimension [ <dim> ]
Load another dimension, a sub-world of this level. Without options, lists
- all of the dimensions found in this world. <dim> can be a number, a
- directory or one of these keywords:
+ all of the dimensions found in this world. <dim> can be a number or one of
+ these keywords:
nether, hell, slip: DIM-1
earth, overworld, parent: parent world
end: DIM1
"""
+
if len(command):
if command[0].lower() in ("earth", "overworld", "parent"):
if self.level.parentWorld:
@@ -1305,14 +1306,10 @@ def _dimension(self, command):
elif command[0].lower() == "end":
dimNo = 1
else:
- dirname = None
- dimNo = None
- try:
- dimNo = int(command[0])
- except ValueError:
- dirname = command[0]
+ dimNo = self.readInt(command)
- self.level = self.level.getDimension(dimNo, dirname)
+ if dimNo in self.level.dimensions:
+ self.level = self.level.dimensions[dimNo]
return
if self.level.parentWorld:
@@ -1320,7 +1317,7 @@ def _dimension(self, command):
if len(self.level.dimensions):
print u"Dimensions in {0}:".format(self.level.displayName)
- for k in self.level.dimensions.values():
+ for k in self.level.dimensions:
print "{0}: {1}".format(k, infiniteworld.MCAlphaDimension.dimensionNames.get(k, "Unknown"))
def _help(self, command):
Please sign in to comment.
Something went wrong with that request. Please try again.