diff --git a/SubstrateCS/Source/Level.cs b/SubstrateCS/Source/Level.cs index aa9ab94..a1f6757 100644 --- a/SubstrateCS/Source/Level.cs +++ b/SubstrateCS/Source/Level.cs @@ -46,6 +46,7 @@ namespace Substrate new SchemaNodeScaler("thunderTime", TagType.TAG_INT, SchemaOptions.OPTIONAL), new SchemaNodeScaler("GameType", TagType.TAG_INT, SchemaOptions.OPTIONAL), new SchemaNodeScaler("MapFeatures", TagType.TAG_BYTE, SchemaOptions.OPTIONAL), + new SchemaNodeScaler("hardcore", TagType.TAG_BYTE, SchemaOptions.OPTIONAL), }, }; @@ -74,6 +75,7 @@ namespace Substrate private int? _gameType; private byte? _mapFeatures; + private byte? _hardcore; /// /// Gets or sets the creation time of the world as a long timestamp. @@ -217,6 +219,15 @@ namespace Substrate set { _mapFeatures = value ? (byte)1 : (byte)0; } } + /// + /// Gets or sets a value indicating whether the map is hardcore mode + /// + public bool Hardcore + { + get { return (_hardcore ?? 0) == 1; } + set { _hardcore = value ? (byte)1 : (byte)0; } + } + /// /// Gets a representing the schema of a level. /// @@ -243,6 +254,7 @@ namespace Substrate _randomSeed = new Random().Next(); _version = 19132; _name = "Untitled"; + _hardcore = 0; GameType = GameType.SURVIVAL; UseMapFeatures = true; @@ -393,6 +405,9 @@ namespace Substrate if (ctree.ContainsKey("MapFeatures")) { _mapFeatures = ctree["MapFeatures"].ToTagByte(); } + if (ctree.ContainsKey("hardcore")) { + _hardcore = ctree["hardcore"].ToTagByte(); + } _source = ctree.Copy() as TagNodeCompound; @@ -460,6 +475,9 @@ namespace Substrate if (_mapFeatures != null) { data["MapFeatures"] = new TagNodeByte(_mapFeatures ?? 0); } + if (_hardcore != null) { + data["hardcore"] = new TagNodeByte(_hardcore ?? 0); + } if (_source != null) { data.MergeFrom(_source); diff --git a/SubstrateCS/Source/Player.cs b/SubstrateCS/Source/Player.cs index 683aab7..41cb73c 100644 --- a/SubstrateCS/Source/Player.cs +++ b/SubstrateCS/Source/Player.cs @@ -6,6 +6,17 @@ using Substrate.Nbt; namespace Substrate { + public class PlayerAbilities + { + private static readonly SchemaNodeCompound _schema = new SchemaNodeCompound("") + { + new SchemaNodeScaler("flying", TagType.TAG_BYTE), + new SchemaNodeScaler("instabuild", TagType.TAG_SHORT), + new SchemaNodeScaler("mayfly", TagType.TAG_SHORT), + new SchemaNodeScaler("invulnerable", TagType.TAG_SHORT), + }; + } + /// /// Represents a Player from either single- or multi-player Minecraft. /// @@ -27,6 +38,14 @@ namespace Substrate new SchemaNodeScaler("SpawnX", TagType.TAG_INT, SchemaOptions.OPTIONAL), new SchemaNodeScaler("SpawnY", TagType.TAG_INT, SchemaOptions.OPTIONAL), new SchemaNodeScaler("SpawnZ", TagType.TAG_INT, SchemaOptions.OPTIONAL), + new SchemaNodeScaler("foodLevel", TagType.TAG_INT, SchemaOptions.OPTIONAL), + new SchemaNodeScaler("foodTickTimer", TagType.TAG_INT, SchemaOptions.OPTIONAL), + new SchemaNodeScaler("foodExhaustionLevel", TagType.TAG_FLOAT, SchemaOptions.OPTIONAL), + new SchemaNodeScaler("foodSaturationLevel", TagType.TAG_FLOAT, SchemaOptions.OPTIONAL), + new SchemaNodeScaler("XpP", TagType.TAG_FLOAT, SchemaOptions.OPTIONAL), + new SchemaNodeScaler("XpLevel", TagType.TAG_INT, SchemaOptions.OPTIONAL), + new SchemaNodeScaler("XpTotal", TagType.TAG_INT, SchemaOptions.OPTIONAL), + new SchemaNodeScaler("Score", TagType.TAG_INT, SchemaOptions.OPTIONAL), }); private const int _CAPACITY = 105; @@ -43,6 +62,15 @@ namespace Substrate private int? _spawnY; private int? _spawnZ; + private int? _foodLevel; + private int? _foodTickTimer; + private float? _foodExhaustion; + private float? _foodSaturation; + private float? _xpP; + private int? _xpLevel; + private int? _xpTotal; + private int? _score; + private string _world; private string _name; @@ -151,6 +179,69 @@ namespace Substrate set { _name = value; } } + /// + /// Gets or sets the player's score. + /// + public int Score + { + get { return _score ?? 0; } + set { _score = value; } + } + + /// + /// Gets or sets the player's XP Level. + /// + public int XPLevel + { + get { return _xpLevel ?? 0; } + set { _xpLevel = value; } + } + + /// + /// Gets or sets the amount of the player's XP points. + /// + public int XPTotal + { + get { return _xpTotal ?? 0; } + set { _xpTotal = value; } + } + + /// + /// Gets or sets the hunger level of the player. Valid values range 0 - 20. + /// + public int HungerLevel + { + get { return _foodLevel ?? 0; } + set { _foodLevel = value; } + } + + /// + /// Gets or sets the player's hunger saturation level, which is reserve food capacity above . + /// + public float HungerSaturationLevel + { + get { return _foodSaturation ?? 0; } + set { _foodSaturation = value; } + } + + /// + /// Gets or sets the counter towards the next hunger point decrement. Valid values range 0.0 - 4.0. + /// + public float HungerExhaustionLevel + { + get { return _foodExhaustion ?? 0; } + set { _foodExhaustion = value; } + } + + /// + /// Gets or sets the timer used to periodically heal or damage the player based on . Valid values range 0 - 80. + /// + public int HungerTimer + { + get { return _foodTickTimer ?? 0; } + set { _foodTickTimer = value; } + } + /// /// Creates a new object with reasonable default values. /// @@ -247,6 +338,31 @@ namespace Substrate _world = ctree["World"].ToTagString(); } + if (ctree.ContainsKey("foodLevel")) { + _foodLevel = ctree["foodLevel"].ToTagInt(); + } + if (ctree.ContainsKey("foodTickTimer")) { + _foodTickTimer = ctree["foodTickTimer"].ToTagInt(); + } + if (ctree.ContainsKey("foodExhaustionLevel")) { + _foodExhaustion = ctree["foodExhaustionLevel"].ToTagFloat(); + } + if (ctree.ContainsKey("foodSaturationLevel")) { + _foodSaturation = ctree["foodSaturationLevel"].ToTagFloat(); + } + if (ctree.ContainsKey("XpP")) { + _xpP = ctree["XpP"].ToTagFloat(); + } + if (ctree.ContainsKey("XpLevel")) { + _xpLevel = ctree["XpLevel"].ToTagInt(); + } + if (ctree.ContainsKey("XpTotal")) { + _xpTotal = ctree["XpTotal"].ToTagInt(); + } + if (ctree.ContainsKey("Score")) { + _score = ctree["Score"].ToTagInt(); + } + _inventory.LoadTree(ctree["Inventory"].ToTagList()); return this; @@ -292,6 +408,23 @@ namespace Substrate tree["World"] = new TagNodeString(_world); } + if (_foodLevel != null) + tree["foodLevel"] = new TagNodeInt(_foodLevel ?? 0); + if (_foodTickTimer != null) + tree["foodTickTimer"] = new TagNodeInt(_foodTickTimer ?? 0); + if (_foodExhaustion != null) + tree["foodExhaustionLevel"] = new TagNodeFloat(_foodExhaustion ?? 0); + if (_foodSaturation != null) + tree["foodSaturation"] = new TagNodeFloat(_foodSaturation ?? 0); + if (_xpP != null) + tree["XpP"] = new TagNodeFloat(_xpP ?? 0); + if (_xpLevel != null) + tree["XpLevel"] = new TagNodeInt(_xpLevel ?? 0); + if (_xpTotal != null) + tree["XpTotal"] = new TagNodeInt(_xpTotal ?? 0); + if (_score != null) + tree["Score"] = new TagNodeInt(_score ?? 0); + tree["Inventory"] = _inventory.BuildTree(); return tree;