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 ---
|
# --- World info ---
|
||||||
|
|
||||||
|
class WorldVersionRef(nbtattr.NBTCompoundRef):
|
||||||
|
Id = nbtattr.NBTAttr('Id', 'i')
|
||||||
|
Name = nbtattr.NBTAttr('Name', 's')
|
||||||
|
Snapshot = nbtattr.NBTAttr('Snapshot', 'b')
|
||||||
|
|
||||||
|
|
||||||
class AnvilWorldMetadata(object):
|
class AnvilWorldMetadata(object):
|
||||||
|
|
||||||
@ -377,6 +382,8 @@ class AnvilWorldMetadata(object):
|
|||||||
|
|
||||||
Spawn = nbtattr.KeyedVectorAttr('SpawnX', 'SpawnY', 'SpawnZ', nbt.TAG_Int)
|
Spawn = nbtattr.KeyedVectorAttr('SpawnX', 'SpawnY', 'SpawnZ', nbt.TAG_Int)
|
||||||
|
|
||||||
|
Version = nbtattr.NBTCompoundAttr('Version', WorldVersionRef)
|
||||||
|
|
||||||
def is1_8World(self):
|
def is1_8World(self):
|
||||||
# Minecraft 1.8 adds a dozen tags to level.dat/Data. These tags are removed if
|
# 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!)
|
# the world is played in 1.7 (and all of the items are removed too!)
|
||||||
@ -502,8 +509,17 @@ class AnvilWorldAdapter(object):
|
|||||||
lastPlayedTime = 0
|
lastPlayedTime = 0
|
||||||
|
|
||||||
version = "Unknown Version"
|
version = "Unknown Version"
|
||||||
|
try:
|
||||||
try:
|
try:
|
||||||
metadata = AnvilWorldMetadata(levelTag)
|
metadata = AnvilWorldMetadata(levelTag)
|
||||||
|
versionTag = metadata.Version
|
||||||
|
if versionTag.Snapshot:
|
||||||
|
version = "Minecraft Snapshot " + versionTag.Name
|
||||||
|
else:
|
||||||
|
version = "Minecraft " + versionTag.Name
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
|
||||||
stackVersion = VERSION_1_8 if metadata.is1_8World() else VERSION_1_7
|
stackVersion = VERSION_1_8 if metadata.is1_8World() else VERSION_1_7
|
||||||
|
|
||||||
if stackVersion == VERSION_1_7:
|
if stackVersion == VERSION_1_7:
|
||||||
|
Reference in New Issue
Block a user