From eb7c3a9cc56a7c2b770b01f1949c23e34052bc8b Mon Sep 17 00:00:00 2001 From: cry-inc Date: Fri, 10 May 2013 21:50:41 +0200 Subject: [PATCH] Added support for the GeneratorName setting in Anvil worlds --- SubstrateCS/Source/Level.cs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/SubstrateCS/Source/Level.cs b/SubstrateCS/Source/Level.cs index bc02f65..90dec98 100644 --- a/SubstrateCS/Source/Level.cs +++ b/SubstrateCS/Source/Level.cs @@ -50,6 +50,7 @@ namespace Substrate new SchemaNodeScaler("RandomSeed", TagType.TAG_LONG), new SchemaNodeScaler("version", TagType.TAG_INT, SchemaOptions.OPTIONAL), new SchemaNodeScaler("LevelName", TagType.TAG_STRING, SchemaOptions.OPTIONAL), + new SchemaNodeScaler("generatorName", TagType.TAG_STRING, SchemaOptions.OPTIONAL), new SchemaNodeScaler("raining", TagType.TAG_BYTE, SchemaOptions.OPTIONAL), new SchemaNodeScaler("thundering", TagType.TAG_BYTE, SchemaOptions.OPTIONAL), new SchemaNodeScaler("rainTime", TagType.TAG_INT, SchemaOptions.OPTIONAL), @@ -77,6 +78,7 @@ namespace Substrate private long _randomSeed; private int? _version; private string _name; + private string _generator; private byte? _raining; private byte? _thundering; @@ -175,6 +177,16 @@ namespace Substrate } } + /// + /// Gets or sets the name of the world generator. + /// + /// This should be 'default', 'flat', or 'largeBiomes'. + public string GeneratorName + { + get { return _generator; } + set { _generator = value; } + } + /// /// Gets or sets a value indicating that it is raining in the world. /// @@ -273,6 +285,7 @@ namespace Substrate //_version = 19132; _version = 19133; _name = "Untitled"; + _generator = "default"; _hardcore = 0; GameType = GameType.SURVIVAL; @@ -298,6 +311,7 @@ namespace Substrate _randomSeed = p._randomSeed; _version = p._version; _name = p._name; + _generator = p._generator; _raining = p._raining; _thundering = p._thundering; @@ -408,6 +422,10 @@ namespace Substrate _name = ctree["LevelName"].ToTagString(); } + if (ctree.ContainsKey("generatorName")) { + _generator = ctree["generatorName"].ToTagString(); + } + if (ctree.ContainsKey("raining")) { _raining = ctree["raining"].ToTagByte(); } @@ -478,6 +496,10 @@ namespace Substrate data["LevelName"] = new TagNodeString(_name); } + if (_generator != null) { + data["generatorName"] = new TagNodeString(_generator); + } + if (_raining != null) { data["raining"] = new TagNodeByte(_raining ?? 0); }