From e639e7daefb596dd94f427bcfbdfc8452057865d Mon Sep 17 00:00:00 2001 From: Justin Aquadro Date: Sat, 5 Nov 2011 00:31:08 -0400 Subject: [PATCH] Including 1.9p5 block types, block data, and tile entities --- SubstrateCS/Source/BlockInfo.cs | 47 +++++++- SubstrateCS/Source/Data.cs | 32 ++++++ .../TileEntities/TileEntityBrewingStand.cs | 100 ++++++++++++++++++ .../TileEntityEnchantmentTable.cs | 63 +++++++++++ .../TileEntities/TileEntityEndPortal.cs | 63 +++++++++++ SubstrateCS/Source/TileEntityFactory.cs | 3 + SubstrateCS/Substrate.csproj | 3 + 7 files changed, 310 insertions(+), 1 deletion(-) create mode 100644 SubstrateCS/Source/TileEntities/TileEntityBrewingStand.cs create mode 100644 SubstrateCS/Source/TileEntities/TileEntityEnchantmentTable.cs create mode 100644 SubstrateCS/Source/TileEntities/TileEntityEndPortal.cs diff --git a/SubstrateCS/Source/BlockInfo.cs b/SubstrateCS/Source/BlockInfo.cs index a173198..1cd1117 100644 --- a/SubstrateCS/Source/BlockInfo.cs +++ b/SubstrateCS/Source/BlockInfo.cs @@ -128,6 +128,18 @@ namespace Substrate public const int FENCE_GATE = 107; public const int BRICK_STAIRS = 108; public const int STONE_BRICK_STAIRS = 109; + public const int MYCELIUM = 110; + public const int LILLY_PAD = 111; + public const int NETHER_BRICK = 112; + public const int NETHER_BRICK_FENCE = 113; + public const int NETHER_BRICK_STAIRS = 114; + public const int NETHER_WART = 115; + public const int ENCHANTMENT_TABLE = 116; + public const int BREWING_STAND = 117; + public const int CAULDRON = 118; + public const int END_PORTAL = 119; + public const int END_PORTAL_FRAME = 120; + public const int END_STONE = 121; } /// @@ -585,6 +597,18 @@ namespace Substrate public static BlockInfo FenceGate; public static BlockInfo BrickStairs; public static BlockInfo StoneBrickStairs; + public static BlockInfo Mycelium; + public static BlockInfo LillyPad; + public static BlockInfo NetherBrick; + public static BlockInfo NetherBrickFence; + public static BlockInfo NetherBrickStairs; + public static BlockInfo NetherWart; + public static BlockInfoEx EnchantmentTable; + public static BlockInfoEx BrewingStand; + public static BlockInfo Cauldron; + public static BlockInfoEx EndPortal; + public static BlockInfo EndPortalFrame; + public static BlockInfo EndStone; static BlockInfo () { @@ -706,6 +730,18 @@ namespace Substrate FenceGate = new BlockInfo(107, "Fence Gate").SetOpacity(0); BrickStairs = new BlockInfo(108, "Brick Stairs").SetOpacity(0); StoneBrickStairs = new BlockInfo(109, "Stone Brick Stairs").SetOpacity(0); + Mycelium = new BlockInfo(110, "Mycelium"); + LillyPad = new BlockInfo(111, "Lilly Pad").SetOpacity(0).SetState(BlockState.NONSOLID); + NetherBrick = new BlockInfo(112, "Nether Brick"); + NetherBrickFence = new BlockInfo(113, "Nether Brick Fence").SetOpacity(0); + NetherBrickStairs = new BlockInfo(114, "Nether Brick Stairs").SetOpacity(0); + NetherWart = new BlockInfo(115, "Nether Wart").SetOpacity(0).SetState(BlockState.NONSOLID); + EnchantmentTable = (BlockInfoEx)new BlockInfoEx(116, "Enchantment Table").SetOpacity(0); + BrewingStand = (BlockInfoEx)new BlockInfoEx(117, "Brewing Stand").SetOpacity(0); + Cauldron = new BlockInfo(118, "Cauldron").SetOpacity(0); + EndPortal = (BlockInfoEx)new BlockInfoEx(119, "End Portal").SetOpacity(0).SetLuminance(MAX_LUMINANCE).SetState(BlockState.NONSOLID); + EndPortalFrame = new BlockInfo(120, "End Portal Frame").SetLuminance(MAX_LUMINANCE); + EndStone = new BlockInfo(121, "End Stone"); for (int i = 0; i < MAX_BLOCKS; i++) { if (_blockTable[i] == null) { @@ -723,6 +759,7 @@ namespace Substrate CobbleStairs.SetLightTransmission(false); BrickStairs.SetLightTransmission(false); StoneBrickStairs.SetLightTransmission(false); + NetherBrickStairs.SetLightTransmission(false); // Override default fluid blocking rules @@ -741,6 +778,9 @@ namespace Substrate BurningFurnace.SetTileEntity("Furnace"); SignPost.SetTileEntity("Sign"); WallSign.SetTileEntity("Sign"); + EnchantmentTable.SetTileEntity("EnchantTable"); + BrewingStand.SetTileEntity("Cauldron"); + EndPortal.SetTileEntity("Airportal"); // Set Data Limits @@ -771,6 +811,7 @@ namespace Substrate WoodDoor.SetDataLimits(0, 3, 0xC); IronDoor.SetDataLimits(0, 3, 0xC); StoneButton.SetDataLimits(1, 4, 0x8); + Snow.SetDataLimits(0, 7, 0); SignPost.SetDataLimits(0, 15, 0); WallSign.SetDataLimits(2, 5, 0); Furnace.SetDataLimits(2, 5, 0); @@ -780,7 +821,7 @@ namespace Substrate JackOLantern.SetDataLimits(0, 3, 0); StonePlate.SetDataLimits(0, 0, 0x1); WoodPlate.SetDataLimits(0, 0, 0x1); - Slab.SetDataLimits(0, 3, 0); + Slab.SetDataLimits(0, 6, 0); DoubleSlab.SetDataLimits(0, 3, 0); Cactus.SetDataLimits(0, 5, 0); Bed.SetDataLimits(0, 3, 0x8); @@ -792,6 +833,10 @@ namespace Substrate HugeBrownMushroom.SetDataLimits(0, 10, 0); Vines.SetDataLimits(0, 0, 0xF); FenceGate.SetDataLimits(0, 3, 0x4); + SilverfishStone.SetDataLimits(0, 2, 0); + BrewingStand.SetDataLimits(0, 0, 0x7); + Cauldron.SetDataLimits(0, 3, 0); + EndPortalFrame.SetDataLimits(0, 0, 0x7); } } diff --git a/SubstrateCS/Source/Data.cs b/SubstrateCS/Source/Data.cs index d1530a9..6dc556b 100644 --- a/SubstrateCS/Source/Data.cs +++ b/SubstrateCS/Source/Data.cs @@ -231,6 +231,8 @@ namespace Substrate SANDSTONE = 1, WOOD = 2, COBBLESTONE = 3, + BRICK = 4, + STONE_BRICK = 5, } public enum BedOrientation @@ -355,6 +357,36 @@ namespace Substrate OPEN = 0x4, } + public enum SilverfishBlockType + { + STONE = 0, + COBBLESTONE = 1, + STONE_BRICK = 2, + } + + [Flags] + public enum BrewingStandState + { + NONE = 0x0, + SLOT_EAST = 0x1, + SLOT_SOUTHWEST = 0x2, + SLOT_NORTHWEST = 0x4, + } + + public enum CauldronLevel + { + EMPTY = 0, + ONE_THIRD = 1, + TWO_THIRDS = 2, + FULL = 3, + } + + [Flags] + public enum EndPortalState + { + EYE_OF_ENDER = 0x4, + } + // Item Data public enum CoalType diff --git a/SubstrateCS/Source/TileEntities/TileEntityBrewingStand.cs b/SubstrateCS/Source/TileEntities/TileEntityBrewingStand.cs new file mode 100644 index 0000000..e3baace --- /dev/null +++ b/SubstrateCS/Source/TileEntities/TileEntityBrewingStand.cs @@ -0,0 +1,100 @@ +using System; +using System.Collections.Generic; +using Substrate.Core; +using Substrate.Nbt; + +namespace Substrate.TileEntities +{ + public class TileEntityBrewingStand : TileEntity, IItemContainer + { + public static readonly SchemaNodeCompound BrewingStandSchema = TileEntity.Schema.MergeInto(new SchemaNodeCompound("") + { + new SchemaNodeString("id", "Cauldron"), + new SchemaNodeList("Items", TagType.TAG_COMPOUND, ItemCollection.Schema), + new SchemaNodeScaler("BrewTime", TagType.TAG_SHORT), + }); + + private const int _CAPACITY = 4; + + private ItemCollection _items; + private short _brewTime; + + public TileEntityBrewingStand () + : base("Cauldron") + { + _items = new ItemCollection(_CAPACITY); + } + + public TileEntityBrewingStand (TileEntity te) + : base(te) + { + TileEntityBrewingStand tec = te as TileEntityBrewingStand; + if (tec != null) { + _items = tec._items.Copy(); + _brewTime = tec._brewTime; + } + else { + _items = new ItemCollection(_CAPACITY); + } + } + + public int BrewTime + { + get { return _brewTime; } + set { _brewTime = (short)value; } + } + + #region ICopyable Members + + public override TileEntity Copy () + { + return new TileEntityBrewingStand(this); + } + + #endregion + + + #region IItemContainer Members + + public ItemCollection Items + { + get { return _items; } + } + + #endregion + + + #region INBTObject Members + + public override TileEntity LoadTree (TagNode tree) + { + TagNodeCompound ctree = tree as TagNodeCompound; + if (ctree == null || base.LoadTree(tree) == null) { + return null; + } + + TagNodeList items = ctree["Items"].ToTagList(); + _items = new ItemCollection(_CAPACITY).LoadTree(items); + + _brewTime = ctree["BrewTime"].ToTagShort(); + + return this; + } + + public override TagNode BuildTree () + { + TagNodeCompound tree = base.BuildTree() as TagNodeCompound; + tree["Items"] = _items.BuildTree(); + tree["BrewTime"] = new TagNodeShort(_brewTime); + + return tree; + } + + public override bool ValidateTree (TagNode tree) + { + return new NbtVerifier(tree, BrewingStandSchema).Verify(); + } + + #endregion + } +} diff --git a/SubstrateCS/Source/TileEntities/TileEntityEnchantmentTable.cs b/SubstrateCS/Source/TileEntities/TileEntityEnchantmentTable.cs new file mode 100644 index 0000000..8fc69d8 --- /dev/null +++ b/SubstrateCS/Source/TileEntities/TileEntityEnchantmentTable.cs @@ -0,0 +1,63 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Substrate.TileEntities +{ + using Substrate.Nbt; + + public class TileEntityEnchantmentTable : TileEntity + { + public static readonly SchemaNodeCompound EnchantTableSchema = TileEntity.Schema.MergeInto(new SchemaNodeCompound("") + { + new SchemaNodeString("id", "EnchantTable"), + }); + + public TileEntityEnchantmentTable () + : base("EnchantTable") + { + } + + public TileEntityEnchantmentTable (TileEntity te) + : base(te) + { + } + + + #region ICopyable Members + + public override TileEntity Copy () + { + return new TileEntityEnchantmentTable(this); + } + + #endregion + + + #region INBTObject Members + + public override TileEntity LoadTree (TagNode tree) + { + TagNodeCompound ctree = tree as TagNodeCompound; + if (ctree == null || base.LoadTree(tree) == null) { + return null; + } + + return this; + } + + public override TagNode BuildTree () + { + TagNodeCompound tree = base.BuildTree() as TagNodeCompound; + + return tree; + } + + public override bool ValidateTree (TagNode tree) + { + return new NbtVerifier(tree, EnchantTableSchema).Verify(); + } + + #endregion + } +} diff --git a/SubstrateCS/Source/TileEntities/TileEntityEndPortal.cs b/SubstrateCS/Source/TileEntities/TileEntityEndPortal.cs new file mode 100644 index 0000000..4804841 --- /dev/null +++ b/SubstrateCS/Source/TileEntities/TileEntityEndPortal.cs @@ -0,0 +1,63 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Substrate.TileEntities +{ + using Substrate.Nbt; + + public class TileEntityEndPortal : TileEntity + { + public static readonly SchemaNodeCompound EndPortalSchema = TileEntity.Schema.MergeInto(new SchemaNodeCompound("") + { + new SchemaNodeString("id", "Airportal"), + }); + + public TileEntityEndPortal () + : base("Airportal") + { + } + + public TileEntityEndPortal (TileEntity te) + : base(te) + { + } + + + #region ICopyable Members + + public override TileEntity Copy () + { + return new TileEntityEndPortal(this); + } + + #endregion + + + #region INBTObject Members + + public override TileEntity LoadTree (TagNode tree) + { + TagNodeCompound ctree = tree as TagNodeCompound; + if (ctree == null || base.LoadTree(tree) == null) { + return null; + } + + return this; + } + + public override TagNode BuildTree () + { + TagNodeCompound tree = base.BuildTree() as TagNodeCompound; + + return tree; + } + + public override bool ValidateTree (TagNode tree) + { + return new NbtVerifier(tree, EndPortalSchema).Verify(); + } + + #endregion + } +} diff --git a/SubstrateCS/Source/TileEntityFactory.cs b/SubstrateCS/Source/TileEntityFactory.cs index 3bab10b..2f1dd87 100644 --- a/SubstrateCS/Source/TileEntityFactory.cs +++ b/SubstrateCS/Source/TileEntityFactory.cs @@ -77,7 +77,10 @@ namespace Substrate static TileEntityFactory () { + _registry["Airportal"] = typeof(TileEntityEndPortal); + _registry["Cauldron"] = typeof(TileEntityBrewingStand); _registry["Chest"] = typeof(TileEntityChest); + _registry["EnchantTable"] = typeof(TileEntityEnchantmentTable); _registry["Furnace"] = typeof(TileEntityFurnace); _registry["MobSpawner"] = typeof(TileEntityMobSpawner); _registry["Music"] = typeof(TileEntityMusic); diff --git a/SubstrateCS/Substrate.csproj b/SubstrateCS/Substrate.csproj index 51164ce..19301df 100644 --- a/SubstrateCS/Substrate.csproj +++ b/SubstrateCS/Substrate.csproj @@ -174,7 +174,10 @@ + + +