diff --git a/SubstrateCS/Properties/AssemblyInfo.cs b/SubstrateCS/Properties/AssemblyInfo.cs index 894323b..2bd795f 100644 --- a/SubstrateCS/Properties/AssemblyInfo.cs +++ b/SubstrateCS/Properties/AssemblyInfo.cs @@ -30,8 +30,8 @@ using System.Runtime.InteropServices; // Build Number // Revision // -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] +[assembly: AssemblyVersion("1.0.1.0")] +[assembly: AssemblyFileVersion("1.0.1.0")] // This library is compatible with all CLS-compliant .NET programming languages. [assembly: CLSCompliant(true)] \ No newline at end of file diff --git a/SubstrateCS/Source/Entities/EntityAnimal.cs b/SubstrateCS/Source/Entities/EntityAnimal.cs new file mode 100644 index 0000000..493e812 --- /dev/null +++ b/SubstrateCS/Source/Entities/EntityAnimal.cs @@ -0,0 +1,93 @@ +using System; +using System.Collections.Generic; +using System.Text; +using Substrate.Nbt; + +namespace Substrate.Entities +{ + public class EntityAnimal : EntityMob + { + public static readonly SchemaNodeCompound AnimalSchema = MobSchema.MergeInto(new SchemaNodeCompound("") + { + new SchemaNodeScaler("Age", TagType.TAG_INT, SchemaOptions.CREATE_ON_MISSING), + new SchemaNodeScaler("InLove", TagType.TAG_INT, SchemaOptions.CREATE_ON_MISSING), + }); + + private int _age; + private int _inLove; + + public int Age + { + get { return _age; } + set { _age = value; } + } + + public int InLove + { + get { return _inLove; } + set { _inLove = value; } + } + + protected EntityAnimal (string id) + : base(id) + { + } + + public EntityAnimal () + : this(TypeId) + { + } + + public EntityAnimal (TypedEntity e) + : base(e) + { + EntityAnimal e2 = e as EntityAnimal; + if (e2 != null) { + _age = e2._age; + _inLove = e2._inLove; + } + } + + + #region INBTObject Members + + public override TypedEntity LoadTree (TagNode tree) + { + TagNodeCompound ctree = tree as TagNodeCompound; + if (ctree == null || base.LoadTree(tree) == null) { + return null; + } + + _age = ctree["Age"].ToTagInt(); + _inLove = ctree["InLove"].ToTagInt(); + + return this; + } + + public override TagNode BuildTree () + { + TagNodeCompound tree = base.BuildTree() as TagNodeCompound; + tree["Age"] = new TagNodeInt(_age); + tree["InLove"] = new TagNodeInt(_inLove); + + return tree; + } + + public override bool ValidateTree (TagNode tree) + { + return new NbtVerifier(tree, AnimalSchema).Verify(); + } + + #endregion + + + #region ICopyable Members + + public override TypedEntity Copy () + { + return new EntityAnimal(this); + } + + #endregion + } +} diff --git a/SubstrateCS/Source/Entities/EntityChicken.cs b/SubstrateCS/Source/Entities/EntityChicken.cs index 325f69c..1ef5a9a 100644 --- a/SubstrateCS/Source/Entities/EntityChicken.cs +++ b/SubstrateCS/Source/Entities/EntityChicken.cs @@ -6,9 +6,9 @@ namespace Substrate.Entities { using Substrate.Nbt; - public class EntityChicken : EntityMob + public class EntityChicken : EntityAnimal { - public static readonly SchemaNodeCompound ChickenSchema = MobSchema.MergeInto(new SchemaNodeCompound("") + public static readonly SchemaNodeCompound ChickenSchema = AnimalSchema.MergeInto(new SchemaNodeCompound("") { new SchemaNodeString("id", TypeId), }); diff --git a/SubstrateCS/Source/Entities/EntityPig.cs b/SubstrateCS/Source/Entities/EntityPig.cs index 425ad9b..32db2ba 100644 --- a/SubstrateCS/Source/Entities/EntityPig.cs +++ b/SubstrateCS/Source/Entities/EntityPig.cs @@ -6,9 +6,9 @@ namespace Substrate.Entities { using Substrate.Nbt; - public class EntityPig : EntityMob + public class EntityPig : EntityAnimal { - public static readonly SchemaNodeCompound PigSchema = MobSchema.MergeInto(new SchemaNodeCompound("") + public static readonly SchemaNodeCompound PigSchema = AnimalSchema.MergeInto(new SchemaNodeCompound("") { new SchemaNodeString("id", TypeId), new SchemaNodeScaler("Saddle", TagType.TAG_BYTE), diff --git a/SubstrateCS/Source/Entities/EntitySheep.cs b/SubstrateCS/Source/Entities/EntitySheep.cs index 180ab4c..680f2ec 100644 --- a/SubstrateCS/Source/Entities/EntitySheep.cs +++ b/SubstrateCS/Source/Entities/EntitySheep.cs @@ -6,9 +6,9 @@ namespace Substrate.Entities { using Substrate.Nbt; - public class EntitySheep : EntityMob + public class EntitySheep : EntityAnimal { - public static readonly SchemaNodeCompound SheepSchema = MobSchema.MergeInto(new SchemaNodeCompound("") + public static readonly SchemaNodeCompound SheepSchema = AnimalSchema.MergeInto(new SchemaNodeCompound("") { new SchemaNodeString("id", TypeId), new SchemaNodeScaler("Sheared", TagType.TAG_BYTE), diff --git a/SubstrateCS/Source/Entities/EntityWolf.cs b/SubstrateCS/Source/Entities/EntityWolf.cs index 345d681..b3da6aa 100644 --- a/SubstrateCS/Source/Entities/EntityWolf.cs +++ b/SubstrateCS/Source/Entities/EntityWolf.cs @@ -6,9 +6,9 @@ namespace Substrate.Entities { using Substrate.Nbt; - public class EntityWolf : EntityMob + public class EntityWolf : EntityAnimal { - public static readonly SchemaNodeCompound WolfSchema = MobSchema.MergeInto(new SchemaNodeCompound("") + public static readonly SchemaNodeCompound WolfSchema = AnimalSchema.MergeInto(new SchemaNodeCompound("") { new SchemaNodeString("id", TypeId), new SchemaNodeScaler("Owner", TagType.TAG_STRING), diff --git a/SubstrateCS/Substrate (NET2).csproj b/SubstrateCS/Substrate (NET2).csproj index 711d65a..a272b84 100644 --- a/SubstrateCS/Substrate (NET2).csproj +++ b/SubstrateCS/Substrate (NET2).csproj @@ -77,6 +77,7 @@ + diff --git a/SubstrateCS/Substrate (NET4).csproj b/SubstrateCS/Substrate (NET4).csproj index 1155118..b7d4ca9 100644 --- a/SubstrateCS/Substrate (NET4).csproj +++ b/SubstrateCS/Substrate (NET4).csproj @@ -77,6 +77,7 @@ +