Added state property to BlockInfo (solid/nonsolid/fluid)

This commit is contained in:
Justin Aquadro 2011-06-01 04:59:57 +00:00
parent 41cfa1b425
commit 8e2e602ec5

View file

@ -99,6 +99,13 @@ namespace Substrate
public const int LOCKED_CHEST = 95; public const int LOCKED_CHEST = 95;
} }
public enum BlockState
{
SOLID,
NONSOLID,
FLUID
}
public class BlockInfo public class BlockInfo
{ {
public const int MAX_BLOCKS = 256; public const int MAX_BLOCKS = 256;
@ -168,6 +175,8 @@ namespace Substrate
private int _luminance = MIN_LUMINANCE; private int _luminance = MIN_LUMINANCE;
private bool _transmitLight = false; private bool _transmitLight = false;
private BlockState _state = BlockState.SOLID;
private DataLimits _dataLimits; private DataLimits _dataLimits;
public static ItemCache<BlockInfo> BlockTable; public static ItemCache<BlockInfo> BlockTable;
@ -203,6 +212,11 @@ namespace Substrate
get { return _transmitLight; } get { return _transmitLight; }
} }
public BlockState State
{
get { return _state; }
}
public BlockInfo (int id) public BlockInfo (int id)
{ {
_id = id; _id = id;
@ -250,6 +264,12 @@ namespace Substrate
return this; return this;
} }
public BlockInfo SetState (BlockState state)
{
_state = state;
return this;
}
public bool TestData (int data) public bool TestData (int data)
{ {
if (_dataLimits == null) { if (_dataLimits == null) {
@ -357,18 +377,18 @@ namespace Substrate
OpacityTable = new ItemCache<int>(_opacityTable); OpacityTable = new ItemCache<int>(_opacityTable);
LuminanceTable = new ItemCache<int>(_luminanceTable); LuminanceTable = new ItemCache<int>(_luminanceTable);
Air = new BlockInfo(0, "Air").SetOpacity(0); Air = new BlockInfo(0, "Air").SetOpacity(0).SetState(BlockState.NONSOLID);
Stone = new BlockInfo(1, "Stone"); Stone = new BlockInfo(1, "Stone");
Grass = new BlockInfo(2, "Grass"); Grass = new BlockInfo(2, "Grass");
Dirt = new BlockInfo(3, "Dirt"); Dirt = new BlockInfo(3, "Dirt");
Cobblestone = new BlockInfo(4, "Cobblestone"); Cobblestone = new BlockInfo(4, "Cobblestone");
WoodPlank = new BlockInfo(5, "Wooden Plank"); WoodPlank = new BlockInfo(5, "Wooden Plank");
Sapling = new BlockInfo(6, "Sapling").SetOpacity(0); Sapling = new BlockInfo(6, "Sapling").SetOpacity(0).SetState(BlockState.NONSOLID);
Bedrock = new BlockInfo(7, "Bedrock"); Bedrock = new BlockInfo(7, "Bedrock");
Water = new BlockInfo(8, "Water").SetOpacity(3); Water = new BlockInfo(8, "Water").SetOpacity(3).SetState(BlockState.FLUID);
StationaryWater = new BlockInfo(9, "Stationary Water").SetOpacity(3); StationaryWater = new BlockInfo(9, "Stationary Water").SetOpacity(3).SetState(BlockState.FLUID);
Lava = new BlockInfo(10, "Lava").SetLuminance(MAX_LUMINANCE); Lava = new BlockInfo(10, "Lava").SetLuminance(MAX_LUMINANCE).SetState(BlockState.FLUID);
StationaryLava = new BlockInfo(11, "Stationary Lava").SetLuminance(MAX_LUMINANCE); StationaryLava = new BlockInfo(11, "Stationary Lava").SetLuminance(MAX_LUMINANCE).SetState(BlockState.FLUID);
Sand = new BlockInfo(12, "Sand"); Sand = new BlockInfo(12, "Sand");
Gravel = new BlockInfo(13, "Gravel"); Gravel = new BlockInfo(13, "Gravel");
GoldOre = new BlockInfo(14, "Gold Ore"); GoldOre = new BlockInfo(14, "Gold Ore");
@ -384,13 +404,13 @@ namespace Substrate
Sandstone = new BlockInfo(24, "Sandstone"); Sandstone = new BlockInfo(24, "Sandstone");
NoteBlock = new BlockInfoEx(25, "Note Block"); NoteBlock = new BlockInfoEx(25, "Note Block");
Bed = new BlockInfo(26, "Bed").SetOpacity(0); Bed = new BlockInfo(26, "Bed").SetOpacity(0);
PoweredRail = new BlockInfo(27, "Powered Rail").SetOpacity(0); PoweredRail = new BlockInfo(27, "Powered Rail").SetOpacity(0).SetState(BlockState.NONSOLID);
DetectorRail = new BlockInfo(28, "Detector Rail").SetOpacity(0); DetectorRail = new BlockInfo(28, "Detector Rail").SetOpacity(0).SetState(BlockState.NONSOLID);
Wool = new BlockInfo(35, "Wool"); Wool = new BlockInfo(35, "Wool");
YellowFlower = new BlockInfo(37, "Yellow Flower").SetOpacity(0); YellowFlower = new BlockInfo(37, "Yellow Flower").SetOpacity(0).SetState(BlockState.NONSOLID);
RedRose = new BlockInfo(38, "Red Rose").SetOpacity(0); RedRose = new BlockInfo(38, "Red Rose").SetOpacity(0).SetState(BlockState.NONSOLID);
BrownMushroom = new BlockInfo(39, "Brown Mushroom").SetOpacity(0).SetLuminance(1); BrownMushroom = new BlockInfo(39, "Brown Mushroom").SetOpacity(0).SetLuminance(1).SetState(BlockState.NONSOLID);
RedMushroom = new BlockInfo(40, "Red Mushroom").SetOpacity(0); RedMushroom = new BlockInfo(40, "Red Mushroom").SetOpacity(0).SetState(BlockState.NONSOLID);
GoldBlock = new BlockInfo(41, "Gold Block"); GoldBlock = new BlockInfo(41, "Gold Block");
IronBlock = new BlockInfo(42, "Iron Block"); IronBlock = new BlockInfo(42, "Iron Block");
DoubleSlab = new BlockInfo(43, "Double Slab"); DoubleSlab = new BlockInfo(43, "Double Slab");
@ -400,47 +420,47 @@ namespace Substrate
Bookshelf = new BlockInfo(47, "Bookshelf"); Bookshelf = new BlockInfo(47, "Bookshelf");
MossStone = new BlockInfo(48, "Moss Stone"); MossStone = new BlockInfo(48, "Moss Stone");
Obsidian = new BlockInfo(49, "Obsidian"); Obsidian = new BlockInfo(49, "Obsidian");
Torch = new BlockInfo(50, "Torch").SetOpacity(0).SetLuminance(MAX_LUMINANCE - 1); Torch = new BlockInfo(50, "Torch").SetOpacity(0).SetLuminance(MAX_LUMINANCE - 1).SetState(BlockState.NONSOLID);
Fire = new BlockInfo(51, "Fire").SetOpacity(0).SetLuminance(MAX_LUMINANCE); Fire = new BlockInfo(51, "Fire").SetOpacity(0).SetLuminance(MAX_LUMINANCE).SetState(BlockState.NONSOLID);
MonsterSpawner = (BlockInfoEx)new BlockInfoEx(52, "Monster Spawner").SetOpacity(0); MonsterSpawner = (BlockInfoEx)new BlockInfoEx(52, "Monster Spawner").SetOpacity(0);
WoodStairs = new BlockInfo(53, "Wooden Stairs").SetOpacity(0); WoodStairs = new BlockInfo(53, "Wooden Stairs").SetOpacity(0);
Chest = new BlockInfoEx(54, "Chest"); Chest = new BlockInfoEx(54, "Chest");
RedstoneWire = new BlockInfo(55, "Redstone Wire").SetOpacity(0); RedstoneWire = new BlockInfo(55, "Redstone Wire").SetOpacity(0).SetState(BlockState.NONSOLID);
DiamondOre = new BlockInfo(56, "Diamond Ore"); DiamondOre = new BlockInfo(56, "Diamond Ore");
DiamondBlock = new BlockInfo(57, "Diamond Block"); DiamondBlock = new BlockInfo(57, "Diamond Block");
CraftTable = new BlockInfo(58, "Crafting Table"); CraftTable = new BlockInfo(58, "Crafting Table");
Crops = new BlockInfo(59, "Crops").SetOpacity(0); Crops = new BlockInfo(59, "Crops").SetOpacity(0).SetState(BlockState.NONSOLID);
Farmland = new BlockInfo(60, "Farmland").SetOpacity(0); Farmland = new BlockInfo(60, "Farmland").SetOpacity(0);
Furnace = new BlockInfoEx(61, "Furnace"); Furnace = new BlockInfoEx(61, "Furnace");
BurningFurnace = (BlockInfoEx)new BlockInfoEx(62, "Burning Furnace").SetLuminance(MAX_LUMINANCE - 1); BurningFurnace = (BlockInfoEx)new BlockInfoEx(62, "Burning Furnace").SetLuminance(MAX_LUMINANCE - 1);
SignPost = (BlockInfoEx)new BlockInfoEx(63, "Sign Post").SetOpacity(0); SignPost = (BlockInfoEx)new BlockInfoEx(63, "Sign Post").SetOpacity(0).SetState(BlockState.NONSOLID);
WoodDoor = new BlockInfo(64, "Wooden Door").SetOpacity(0); WoodDoor = new BlockInfo(64, "Wooden Door").SetOpacity(0);
Ladder = new BlockInfo(65, "Ladder").SetOpacity(0); Ladder = new BlockInfo(65, "Ladder").SetOpacity(0);
Rails = new BlockInfo(66, "Rails").SetOpacity(0); Rails = new BlockInfo(66, "Rails").SetOpacity(0).SetState(BlockState.NONSOLID);
CobbleStairs = new BlockInfo(67, "Cobblestone Stairs").SetOpacity(0); CobbleStairs = new BlockInfo(67, "Cobblestone Stairs").SetOpacity(0);
WallSign = (BlockInfoEx)new BlockInfoEx(68, "Wall Sign").SetOpacity(0); WallSign = (BlockInfoEx)new BlockInfoEx(68, "Wall Sign").SetOpacity(0).SetState(BlockState.NONSOLID);
Lever = new BlockInfo(69, "Lever").SetOpacity(0); Lever = new BlockInfo(69, "Lever").SetOpacity(0).SetState(BlockState.NONSOLID);
StonePlate = new BlockInfo(70, "Stone Pressure Plate").SetOpacity(0); StonePlate = new BlockInfo(70, "Stone Pressure Plate").SetOpacity(0).SetState(BlockState.NONSOLID);
IronDoor = new BlockInfo(71, "Iron Door").SetOpacity(0); IronDoor = new BlockInfo(71, "Iron Door").SetOpacity(0);
WoodPlate = new BlockInfo(72, "Wooden Pressure Plate").SetOpacity(0); WoodPlate = new BlockInfo(72, "Wooden Pressure Plate").SetOpacity(0).SetState(BlockState.NONSOLID);
RedstoneOre = new BlockInfo(73, "Redstone Ore"); RedstoneOre = new BlockInfo(73, "Redstone Ore");
GlowRedstoneOre = new BlockInfo(74, "Glowing Redstone Ore").SetLuminance(9); GlowRedstoneOre = new BlockInfo(74, "Glowing Redstone Ore").SetLuminance(9);
RedstoneTorch = new BlockInfo(75, "Redstone Torch (Off)").SetOpacity(0); RedstoneTorch = new BlockInfo(75, "Redstone Torch (Off)").SetOpacity(0).SetState(BlockState.NONSOLID);
RedstoneTorchOn = new BlockInfo(76, "Redstone Torch (On)").SetOpacity(0).SetLuminance(7); RedstoneTorchOn = new BlockInfo(76, "Redstone Torch (On)").SetOpacity(0).SetLuminance(7).SetState(BlockState.NONSOLID);
StoneButton = new BlockInfo(77, "Stone Button").SetOpacity(0); StoneButton = new BlockInfo(77, "Stone Button").SetOpacity(0).SetState(BlockState.NONSOLID);
Snow = new BlockInfo(78, "Snow").SetOpacity(0); Snow = new BlockInfo(78, "Snow").SetOpacity(0).SetState(BlockState.NONSOLID);
Ice = new BlockInfo(79, "Ice").SetOpacity(3); Ice = new BlockInfo(79, "Ice").SetOpacity(3);
SnowBlock = new BlockInfo(80, "Snow Block"); SnowBlock = new BlockInfo(80, "Snow Block");
Cactus = new BlockInfo(81, "Cactus").SetOpacity(0); Cactus = new BlockInfo(81, "Cactus").SetOpacity(0);
ClayBlock = new BlockInfo(82, "Clay Block"); ClayBlock = new BlockInfo(82, "Clay Block");
SugarCane = new BlockInfo(83, "Sugar Cane").SetOpacity(0); SugarCane = new BlockInfo(83, "Sugar Cane").SetOpacity(0).SetState(BlockState.NONSOLID);
Jukebox = new BlockInfo(84, "Jukebox"); Jukebox = new BlockInfo(84, "Jukebox");
Fence = new BlockInfo(85, "Fence").SetOpacity(0); Fence = new BlockInfo(85, "Fence").SetOpacity(0);
Pumpkin = new BlockInfo(86, "Pumpkin"); Pumpkin = new BlockInfo(86, "Pumpkin");
Netherrack = new BlockInfo(87, "Netherrack"); Netherrack = new BlockInfo(87, "Netherrack");
SoulSand = new BlockInfo(88, "Soul Sand"); SoulSand = new BlockInfo(88, "Soul Sand");
Glowstone = new BlockInfo(89, "Glowstone Block").SetLuminance(MAX_LUMINANCE); Glowstone = new BlockInfo(89, "Glowstone Block").SetLuminance(MAX_LUMINANCE);
Portal = new BlockInfo(90, "Portal").SetOpacity(0).SetLuminance(11); Portal = new BlockInfo(90, "Portal").SetOpacity(0).SetLuminance(11).SetState(BlockState.NONSOLID);
JackOLantern = new BlockInfo(91, "Jack-O-Lantern").SetLuminance(MAX_LUMINANCE); JackOLantern = new BlockInfo(91, "Jack-O-Lantern").SetLuminance(MAX_LUMINANCE);
CakeBlock = new BlockInfo(92, "Cake Block").SetOpacity(0); CakeBlock = new BlockInfo(92, "Cake Block").SetOpacity(0);
RedstoneRepeater = new BlockInfo(93, "Redstone Repeater (Off)").SetOpacity(0); RedstoneRepeater = new BlockInfo(93, "Redstone Repeater (Off)").SetOpacity(0);