Пример #1
0
    def __init__(self,
                 filename=None,
                 create=False,
                 readonly=False,
                 adapterClass=None,
                 adapter=None,
                 resume=None):
        """
        Load a Minecraft level of any format from the given filename.

        If you try to create an existing world, IOError will be raised.

        :type filename: str or unknown or unicode
        :type create: bool
        :type readonly: bool
        :type adapter: unknown or mceditlib.anvil.adapter.AnvilWorldAdapter or mceditlib.schematic.SchematicFileAdapter
        :type adapterClass: class
        :type resume: None or bool
        :return:
        :rtype: WorldEditor
        """
        self.playerCache = {}
        assert not (create and readonly)
        assert not create or adapterClass, "create=True requires an adapterClass"

        if adapter:
            self.adapter = adapter
        elif adapterClass:
            self.adapter = adapterClass(filename,
                                        create,
                                        readonly,
                                        resume=resume)
        else:
            self.adapter = findAdapter(filename, readonly, resume=resume)

        self.filename = filename
        self.readonly = readonly

        # maps (cx, cz, dimName) tuples to WorldEditorChunk
        self._loadedChunks = weakref.WeakValueDictionary()

        # caches ChunkData from adapter
        self._chunkDataCache = cachefunc.lru_cache_object(
            self._getChunkDataRaw, 1000)
        self._chunkDataCache.should_decache = self._shouldUnloadChunkData
        self._chunkDataCache.will_decache = self._willUnloadChunkData

        # caches recently used WorldEditorChunks
        self.recentChunks = collections.deque(maxlen=100)

        self._allChunks = None

        self.recentDirtyChunks = collections.defaultdict(set)
        self.recentDirtyFiles = set()

        self.recentDirtySections = collections.defaultdict(set)

        self.dimensions = {}

        self.currentRevision = 0
Пример #2
0
    def __init__(self, filename=None, create=False, readonly=False, adapterClass=None, adapter=None, resume=None):
        """
        Load a Minecraft level of any format from the given filename.

        If you try to create an existing world, IOError will be raised.

        :type filename: str or unknown or unicode
        :type create: bool
        :type readonly: bool
        :type adapter: unknown or mceditlib.anvil.adapter.AnvilWorldAdapter or mceditlib.schematic.SchematicFileAdapter
        :type adapterClass: class
        :type resume: None or bool
        :return:
        :rtype: WorldEditor
        """
        self.playerCache = {}
        assert not (create and readonly)
        assert not create or adapterClass, "create=True requires an adapterClass"

        if adapter:
            self.adapter = adapter
        elif adapterClass:
            self.adapter = adapterClass(filename, create, readonly, resume=resume)
        else:
            self.adapter = findAdapter(filename, readonly, resume=resume)

        self.filename = filename
        self.readonly = readonly

        # maps (cx, cz, dimName) tuples to WorldEditorChunk
        self._loadedChunks = weakref.WeakValueDictionary()

        # caches ChunkData from adapter
        self._chunkDataCache = cachefunc.lru_cache_object(self._getChunkDataRaw, 1000)
        self._chunkDataCache.should_decache = self._shouldUnloadChunkData
        self._chunkDataCache.will_decache = self._willUnloadChunkData

        # caches recently used WorldEditorChunks
        self.recentChunks = collections.deque(maxlen=100)

        self._allChunks = None

        self.recentDirtyChunks = collections.defaultdict(set)
        self.recentDirtyFiles = set()

        self.recentDirtySections = collections.defaultdict(set)

        self.dimensions = {}

        self.currentRevision = 0
Пример #3
0
 def __init__(self, dimension):
     self.dimension = dimension
     self.sectionCache = lru_cache_object(self._createSection, 1000)
Пример #4
0
 def __init__(self, dimension):
     self.dimension = dimension
     self.sectionCache = lru_cache_object(self._createSection, 1000)