Use Version
tag of level.dat to display version in world list
This commit is contained in:
parent
e30dbea2d6
commit
169309d833
@ -345,6 +345,11 @@ class AnvilChunkData(object):
|
||||
|
||||
# --- World info ---
|
||||
|
||||
class WorldVersionRef(nbtattr.NBTCompoundRef):
|
||||
Id = nbtattr.NBTAttr('Id', 'i')
|
||||
Name = nbtattr.NBTAttr('Name', 's')
|
||||
Snapshot = nbtattr.NBTAttr('Snapshot', 'b')
|
||||
|
||||
|
||||
class AnvilWorldMetadata(object):
|
||||
|
||||
@ -377,6 +382,8 @@ class AnvilWorldMetadata(object):
|
||||
|
||||
Spawn = nbtattr.KeyedVectorAttr('SpawnX', 'SpawnY', 'SpawnZ', nbt.TAG_Int)
|
||||
|
||||
Version = nbtattr.NBTCompoundAttr('Version', WorldVersionRef)
|
||||
|
||||
def is1_8World(self):
|
||||
# Minecraft 1.8 adds a dozen tags to level.dat/Data. These tags are removed if
|
||||
# the world is played in 1.7 (and all of the items are removed too!)
|
||||
@ -503,16 +510,25 @@ class AnvilWorldAdapter(object):
|
||||
|
||||
version = "Unknown Version"
|
||||
try:
|
||||
metadata = AnvilWorldMetadata(levelTag)
|
||||
stackVersion = VERSION_1_8 if metadata.is1_8World() else VERSION_1_7
|
||||
try:
|
||||
metadata = AnvilWorldMetadata(levelTag)
|
||||
versionTag = metadata.Version
|
||||
if versionTag.Snapshot:
|
||||
version = "Minecraft Snapshot " + versionTag.Name
|
||||
else:
|
||||
version = "Minecraft " + versionTag.Name
|
||||
|
||||
if stackVersion == VERSION_1_7:
|
||||
version = "Minecraft 1.7"
|
||||
if "FML" in metadata.metadataTag:
|
||||
version = "MinecraftForge 1.7"
|
||||
except Exception as e:
|
||||
|
||||
if stackVersion == VERSION_1_8:
|
||||
version = "Minecraft 1.8+"
|
||||
stackVersion = VERSION_1_8 if metadata.is1_8World() else VERSION_1_7
|
||||
|
||||
if stackVersion == VERSION_1_7:
|
||||
version = "Minecraft 1.7"
|
||||
if "FML" in metadata.metadataTag:
|
||||
version = "MinecraftForge 1.7"
|
||||
|
||||
if stackVersion == VERSION_1_8:
|
||||
version = "Minecraft 1.8+"
|
||||
|
||||
except Exception as e:
|
||||
log.warn("Failed to get version info for %s: %r", filename, e, exc_info=1)
|
||||
|
Reference in New Issue
Block a user