diff --git a/SubstrateCS/Source/BlockInfo.cs b/SubstrateCS/Source/BlockInfo.cs index 7182199..2bcdfea 100644 --- a/SubstrateCS/Source/BlockInfo.cs +++ b/SubstrateCS/Source/BlockInfo.cs @@ -144,6 +144,16 @@ namespace Substrate public const int REDSTONE_LAMP_ON = 124; public const int DOUBLE_WOOD_SLAB = 125; public const int WOOD_SLAB = 126; + public const int COCOA_PLANT = 127; + public const int SANDSTONE_STAIRS = 128; + public const int EMERALD_ORE = 129; + public const int ENDER_CHEST = 130; + public const int TRIPWIRE_HOOK = 131; + public const int TRIPWIRE = 132; + public const int EMERALD_BLOCK = 133; + public const int SPRUCE_WOOD_STAIRS = 134; + public const int BIRCH_WOOD_STAIRS = 135; + public const int JUNGLE_WOOD_STAIRS = 136; } /// @@ -641,6 +651,16 @@ namespace Substrate public static BlockInfo RedstoneLampOn; public static BlockInfo DoubleWoodSlab; public static BlockInfo WoodSlab; + public static BlockInfo CocoaPlant; + public static BlockInfo SandstoneStairs; + public static BlockInfo EmeraldOre; + public static BlockInfoEx EnderChest; + public static BlockInfo TripwireHook; + public static BlockInfo Tripwire; + public static BlockInfo EmeraldBlock; + public static BlockInfo SpruceWoodStairs; + public static BlockInfo BirchWoodStairs; + public static BlockInfo JungleWoodStairs; static BlockInfo () { @@ -779,6 +799,16 @@ namespace Substrate RedstoneLampOn = new BlockInfo(124, "Redstone Lamp (On)").SetLuminance(15).SetTick(2); DoubleWoodSlab = new BlockInfo(125, "Double Wood Slab"); WoodSlab = new BlockInfo(126, "Wood Slab"); + CocoaPlant = new BlockInfo(127, "Cocoa Plant").SetLuminance(2).SetOpacity(0); + SandstoneStairs = new BlockInfo(128, "Sandstone Stairs").SetOpacity(0); + EmeraldOre = new BlockInfo(129, "Emerald Ore"); + EnderChest = (BlockInfoEx)new BlockInfoEx(130, "Ender Chest").SetLuminance(7).SetOpacity(0); + TripwireHook = new BlockInfo(131, "Tripwire Hook").SetOpacity(0).SetState(BlockState.NONSOLID); + Tripwire = new BlockInfo(132, "Tripwire").SetOpacity(0).SetState(BlockState.NONSOLID); + EmeraldBlock = new BlockInfo(133, "Emerald Block"); + SpruceWoodStairs = new BlockInfo(134, "Sprice Wood Stairs").SetOpacity(0); + BirchWoodStairs = new BlockInfo(135, "Birch Wood Stairs").SetOpacity(0); + JungleWoodStairs = new BlockInfo(136, "Jungle Wood Stairs").SetOpacity(0); for (int i = 0; i < MAX_BLOCKS; i++) { if (_blockTable[i] == null) { @@ -797,6 +827,11 @@ namespace Substrate BrickStairs.SetLightTransmission(false); StoneBrickStairs.SetLightTransmission(false); NetherBrickStairs.SetLightTransmission(false); + WoodSlab.SetLightTransmission(false); + SandstoneStairs.SetLightTransmission(false); + SpruceWoodStairs.SetLightTransmission(false); + BirchWoodStairs.SetLightTransmission(false); + JungleWoodStairs.SetLightTransmission(false); // Override default fluid blocking rules @@ -818,6 +853,7 @@ namespace Substrate EnchantmentTable.SetTileEntity("EnchantTable"); BrewingStand.SetTileEntity("Cauldron"); EndPortal.SetTileEntity("Airportal"); + EnderChest.SetTileEntity("EnderChest"); // Set Data Limits @@ -876,6 +912,8 @@ namespace Substrate EndPortalFrame.SetDataLimits(0, 0, 0x7); WoodSlab.SetDataLimits(0, 5, 0); DoubleWoodSlab.SetDataLimits(0, 5, 0x8); + TripwireHook.SetDataLimits(0, 3, 0xC); + Tripwire.SetDataLimits(0, 0, 0x5); } } diff --git a/SubstrateCS/Source/Data.cs b/SubstrateCS/Source/Data.cs index e1fc3bf..f4f9aad 100644 --- a/SubstrateCS/Source/Data.cs +++ b/SubstrateCS/Source/Data.cs @@ -414,6 +414,28 @@ namespace Substrate EYE_OF_ENDER = 0x4, } + public enum TripwireHookDirection + { + SOUTH = 0, + WEST = 1, + NORTH = 2, + EAST = 3, + } + + [Flags] + public enum TripwireHookState + { + READY = 0x04, + ACTIVATED = 0x08, + } + + [Flags] + public enum TripwireState + { + UNDER_OBJECT = 0x01, + ACTIVATED = 0x04, + } + // Item Data public enum CoalType diff --git a/SubstrateCS/Source/Item.cs b/SubstrateCS/Source/Item.cs index e63ddbd..a196411 100644 --- a/SubstrateCS/Source/Item.cs +++ b/SubstrateCS/Source/Item.cs @@ -17,6 +17,9 @@ namespace Substrate new SchemaNodeScaler("Count", TagType.TAG_BYTE), new SchemaNodeCompound("tag", new SchemaNodeCompound("") { new SchemaNodeList("ench", TagType.TAG_COMPOUND, Enchantment.Schema, SchemaOptions.OPTIONAL), + new SchemaNodeScaler("title", TagType.TAG_STRING, SchemaOptions.OPTIONAL), + new SchemaNodeScaler("author", TagType.TAG_STRING, SchemaOptions.OPTIONAL), + new SchemaNodeList("pages", TagType.TAG_STRING, SchemaOptions.OPTIONAL), }, SchemaOptions.OPTIONAL), }; diff --git a/SubstrateCS/Source/ItemInfo.cs b/SubstrateCS/Source/ItemInfo.cs index 20e4cd1..a616b98 100644 --- a/SubstrateCS/Source/ItemInfo.cs +++ b/SubstrateCS/Source/ItemInfo.cs @@ -142,6 +142,7 @@ namespace Substrate public const int FIRE_CHARGE = 385; public const int BOOK_AND_QUILL = 386; public const int WRITTEN_BOOK = 387; + public const int EMERALD = 388; public const int MUSIC_DISC_13 = 2256; public const int MUSIC_DISC_CAT = 2257; public const int MUSIC_DISC_BLOCKS = 2258; @@ -403,6 +404,7 @@ namespace Substrate public static ItemInfo FireCharge; public static ItemInfo BookAndQuill; public static ItemInfo WrittenBook; + public static ItemInfo Emerald; public static ItemInfo MusicDisc13; public static ItemInfo MusicDiscCat; public static ItemInfo MusicDiscBlocks; @@ -552,6 +554,7 @@ namespace Substrate FireCharge = new ItemInfo(385, "Fire Charge").SetStackSize(64); BookAndQuill = new ItemInfo(386, "Book and Quill"); WrittenBook = new ItemInfo(387, "Written Book"); + Emerald = new ItemInfo(388, "Emerald").SetStackSize(64); MusicDisc13 = new ItemInfo(2256, "13 Disc"); MusicDiscCat = new ItemInfo(2257, "Cat Disc"); MusicDiscBlocks = new ItemInfo(2258, "Blocks Disc"); diff --git a/SubstrateCS/Source/Player.cs b/SubstrateCS/Source/Player.cs index 0a51566..0d3388f 100644 --- a/SubstrateCS/Source/Player.cs +++ b/SubstrateCS/Source/Player.cs @@ -9,12 +9,17 @@ namespace Substrate /// /// Encompases data to specify player abilities, especially mode-dependent abilities. /// + /// Whether or not any of these values are respected by the game client is dependent upon the active game mode. public class PlayerAbilities : ICopyable { private bool _flying; private bool _instabuild; private bool _mayfly; private bool _invulnerable; + private bool _maybuild; + + private float _walkSpeed = 0.1f; + private float _flySpeed = 0.05f; /// /// Gets or sets whether the player is currently flying. @@ -52,6 +57,33 @@ namespace Substrate set { _invulnerable = value; } } + /// + /// Gets or sets whether the player can create or destroy blocks. + /// + public bool MayBuild + { + get { return _maybuild; } + set { _maybuild = value; } + } + + /// + /// Gets or sets the player's walking speed. Always 0.1. + /// + public float FlySpeed + { + get { return _flySpeed; } + set { _flySpeed = value; } + } + + /// + /// Gets or sets the player's flying speed. Always 0.05. + /// + public float WalkSpeed + { + get { return _walkSpeed; } + set { _walkSpeed = value; } + } + #region ICopyable Members /// @@ -62,6 +94,9 @@ namespace Substrate pa._instabuild = _instabuild; pa._mayfly = _mayfly; pa._invulnerable = _invulnerable; + pa._maybuild = _maybuild; + pa._walkSpeed = _walkSpeed; + pa._flySpeed = _flySpeed; return pa; } @@ -69,6 +104,13 @@ namespace Substrate #endregion } + public enum PlayerGameType + { + Survival = 0, + Creative = 1, + Adventure = 2, + } + /// /// Represents a Player from either single- or multi-player Minecraft. /// @@ -84,6 +126,7 @@ namespace Substrate new SchemaNodeScaler("HurtTime", TagType.TAG_SHORT), new SchemaNodeScaler("Dimension", TagType.TAG_INT), new SchemaNodeList("Inventory", TagType.TAG_COMPOUND, ItemCollection.Schema), + //new SchemaNodeList("EnderItems", TagType.TAG_COMPOUND, ItemCollection.Schema, SchemaOptions.OPTIONAL), new SchemaNodeScaler("World", TagType.TAG_STRING, SchemaOptions.OPTIONAL), new SchemaNodeScaler("Sleeping", TagType.TAG_BYTE, SchemaOptions.CREATE_ON_MISSING), new SchemaNodeScaler("SleepTimer", TagType.TAG_SHORT, SchemaOptions.CREATE_ON_MISSING), @@ -98,15 +141,20 @@ namespace Substrate new SchemaNodeScaler("XpLevel", TagType.TAG_INT, SchemaOptions.OPTIONAL), new SchemaNodeScaler("XpTotal", TagType.TAG_INT, SchemaOptions.OPTIONAL), new SchemaNodeScaler("Score", TagType.TAG_INT, SchemaOptions.OPTIONAL), + new SchemaNodeScaler("PlayerGameType", TagType.TAG_INT, SchemaOptions.OPTIONAL), new SchemaNodeCompound("abilities", new SchemaNodeCompound("") { new SchemaNodeScaler("flying", TagType.TAG_BYTE), new SchemaNodeScaler("instabuild", TagType.TAG_BYTE), new SchemaNodeScaler("mayfly", TagType.TAG_BYTE), new SchemaNodeScaler("invulnerable", TagType.TAG_BYTE), + new SchemaNodeScaler("mayBuild", TagType.TAG_BYTE, SchemaOptions.OPTIONAL), + new SchemaNodeScaler("walkSpeed", TagType.TAG_FLOAT, SchemaOptions.OPTIONAL), + new SchemaNodeScaler("flySpeed", TagType.TAG_FLOAT, SchemaOptions.OPTIONAL), }, SchemaOptions.OPTIONAL), }); private const int _CAPACITY = 105; + private const int _ENDER_CAPACITY = 27; private short _attackTime; private short _deathTime; @@ -134,8 +182,10 @@ namespace Substrate private PlayerAbilities _abilities; + private PlayerGameType? _gameType; private ItemCollection _inventory; + private ItemCollection _enderItems; /// /// Gets or sets the number of ticks left in the player's "invincibility shield" after last struck. @@ -182,6 +232,12 @@ namespace Substrate set { _dimension = value; } } + public PlayerGameType GameType + { + get { return _gameType ?? PlayerGameType.Survival; } + set { _gameType = value; } + } + /// /// Gets or sets a value indicating whether the player is sleeping in a bed. /// @@ -318,6 +374,7 @@ namespace Substrate : base() { _inventory = new ItemCollection(_CAPACITY); + _enderItems = new ItemCollection(_ENDER_CAPACITY); _abilities = new PlayerAbilities(); // Sane defaults @@ -343,6 +400,7 @@ namespace Substrate _hurtTime = p._hurtTime; _dimension = p._dimension; + _gameType = p._gameType; _sleeping = p._sleeping; _sleepTimer = p._sleepTimer; _spawnX = p._spawnX; @@ -350,6 +408,7 @@ namespace Substrate _spawnZ = p._spawnZ; _world = p._world; _inventory = p._inventory.Copy(); + _enderItems = p._inventory.Copy(); _foodLevel = p._foodLevel; _foodTickTimer = p._foodTickTimer; @@ -458,10 +517,22 @@ namespace Substrate _abilities.InstantBuild = pb["instabuild"].ToTagByte().Data == 1; _abilities.MayFly = pb["mayfly"].ToTagByte().Data == 1; _abilities.Invulnerable = pb["invulnerable"].ToTagByte().Data == 1; + _abilities.MayBuild = pb["mayBuild"].ToTagByte().Data == 1; + _abilities.WalkSpeed = pb["walkSpeed"].ToTagFloat(); + _abilities.FlySpeed = pb["flySpeed"].ToTagFloat(); + } + + if (ctree.ContainsKey("PlayerGameType")) { + _gameType = (PlayerGameType)ctree["PlayerGameType"].ToTagInt().Data; } _inventory.LoadTree(ctree["Inventory"].ToTagList()); + if (ctree.ContainsKey("EnderItems")) { + if (ctree["EnderItems"].ToTagList().Count > 0) + _enderItems.LoadTree(ctree["EnderItems"].ToTagList()); + } + return this; } @@ -527,17 +598,24 @@ namespace Substrate if (_score != null) tree["Score"] = new TagNodeInt(_score ?? 0); + if (_gameType != null) + tree["PlayerGameType"] = new TagNodeInt((int)(_gameType ?? PlayerGameType.Survival)); + if (AbilitiesSet()) { TagNodeCompound pb = new TagNodeCompound(); pb["flying"] = new TagNodeByte(_abilities.Flying ? (byte)1 : (byte)0); pb["instabuild"] = new TagNodeByte(_abilities.InstantBuild ? (byte)1 : (byte)0); pb["mayfly"] = new TagNodeByte(_abilities.MayFly ? (byte)1 : (byte)0); pb["invulnerable"] = new TagNodeByte(_abilities.Invulnerable ? (byte)1 : (byte)0); + pb["mayBuild"] = new TagNodeByte(_abilities.MayBuild ? (byte)1 : (byte)0); + pb["walkSpeed"] = new TagNodeFloat(_abilities.WalkSpeed); + pb["flySpeed"] = new TagNodeFloat(_abilities.FlySpeed); tree["abilities"] = pb; } tree["Inventory"] = _inventory.BuildTree(); + tree["EnderItems"] = _enderItems.BuildTree(); return tree; } @@ -580,5 +658,10 @@ namespace Substrate } #endregion + + public ItemCollection EnderItems + { + get { return _enderItems; } + } } } \ No newline at end of file