MC 1.2 data, more organizational

This commit is contained in:
Justin Aquadro 2012-04-28 16:53:24 -04:00
parent 66dfc9da95
commit 09d51e6f16
7 changed files with 509 additions and 423 deletions

View file

@ -7,412 +7,6 @@ using System.IO;
namespace Substrate
{
public class AnvilSection : INbtObject<AnvilSection>, ICopyable<AnvilSection>
{
public static SchemaNodeCompound SectionSchema = new SchemaNodeCompound()
{
new SchemaNodeArray("Blocks", 4096),
new SchemaNodeArray("Data", 2048),
new SchemaNodeArray("SkyLight", 2048),
new SchemaNodeArray("BlockLight", 2048),
new SchemaNodeScaler("Y", TagType.TAG_BYTE),
new SchemaNodeArray("AddBlocks", 2048, SchemaOptions.OPTIONAL),
};
private const int XDIM = 16;
private const int YDIM = 16;
private const int ZDIM = 16;
private const int MIN_Y = 0;
private const int MAX_Y = 15;
private TagNodeCompound _tree;
private byte _y;
private YZXByteArray _blocks;
private YZXNibbleArray _data;
private YZXNibbleArray _blockLight;
private YZXNibbleArray _skyLight;
private YZXNibbleArray _addBlocks;
private AnvilSection ()
{
}
public AnvilSection (int y)
{
if (y < MIN_Y || y > MAX_Y)
throw new ArgumentOutOfRangeException();
_y = (byte)y;
BuildNbtTree();
}
public AnvilSection (TagNodeCompound tree)
{
LoadTree(tree);
}
public int Y
{
get { return _y; }
set
{
if (value < MIN_Y || value > MAX_Y)
throw new ArgumentOutOfRangeException();
_y = (byte)value;
_tree["Y"].ToTagByte().Data = _y;
}
}
public YZXByteArray Blocks
{
get { return _blocks; }
}
public YZXNibbleArray Data
{
get { return _data; }
}
public YZXNibbleArray BlockLight
{
get { return _blockLight; }
}
public YZXNibbleArray SkyLight
{
get { return _skyLight; }
}
public YZXNibbleArray AddBlocks
{
get { return _addBlocks; }
}
public bool CheckEmpty ()
{
return CheckBlocksEmpty() && CheckAddBlocksEmpty();
}
private bool CheckBlocksEmpty ()
{
for (int i = 0; i < _blocks.Length; i++)
if (_blocks[i] != 0)
return false;
return true;
}
private bool CheckAddBlocksEmpty ()
{
if (_addBlocks != null)
for (int i = 0; i < _addBlocks.Length; i++)
if (_addBlocks[i] != 0)
return false;
return true;
}
#region INbtObject<AnvilSection> Members
public AnvilSection LoadTree (TagNode tree)
{
TagNodeCompound ctree = tree as TagNodeCompound;
if (ctree == null) {
return null;
}
_y = ctree["Y"] as TagNodeByte;
_blocks = new YZXByteArray(XDIM, YDIM, ZDIM, ctree["Blocks"] as TagNodeByteArray);
_data = new YZXNibbleArray(XDIM, YDIM, ZDIM, ctree["Data"] as TagNodeByteArray);
_skyLight = new YZXNibbleArray(XDIM, YDIM, ZDIM, ctree["SkyLight"] as TagNodeByteArray);
_blockLight = new YZXNibbleArray(XDIM, YDIM, ZDIM, ctree["BlockLight"] as TagNodeByteArray);
if (!ctree.ContainsKey("AddBlocks"))
ctree["AddBlocks"] = new TagNodeByteArray(new byte[2048]);
_addBlocks = new YZXNibbleArray(XDIM, YDIM, ZDIM, ctree["AddBlocks"] as TagNodeByteArray);
_tree = ctree;
return this;
}
public AnvilSection LoadTreeSafe (TagNode tree)
{
if (!ValidateTree(tree)) {
return null;
}
return LoadTree(tree);
}
public TagNode BuildTree ()
{
TagNodeCompound copy = new TagNodeCompound();
foreach (KeyValuePair<string, TagNode> node in _tree) {
copy.Add(node.Key, node.Value);
}
if (CheckAddBlocksEmpty())
copy.Remove("AddBlocks");
return copy;
}
public bool ValidateTree (TagNode tree)
{
NbtVerifier v = new NbtVerifier(tree, SectionSchema);
return v.Verify();
}
#endregion
#region ICopyable<AnvilSection> Members
public AnvilSection Copy ()
{
return new AnvilSection().LoadTree(_tree.Copy());
}
#endregion
private void BuildNbtTree ()
{
int elements3 = XDIM * YDIM * ZDIM;
TagNodeByteArray blocks = new TagNodeByteArray(new byte[elements3]);
TagNodeByteArray data = new TagNodeByteArray(new byte[elements3 >> 1]);
TagNodeByteArray skyLight = new TagNodeByteArray(new byte[elements3 >> 1]);
TagNodeByteArray blockLight = new TagNodeByteArray(new byte[elements3 >> 1]);
TagNodeByteArray addBlocks = new TagNodeByteArray(new byte[elements3 >> 1]);
_blocks = new YZXByteArray(XDIM, YDIM, ZDIM, blocks);
_data = new YZXNibbleArray(XDIM, YDIM, ZDIM, data);
_skyLight = new YZXNibbleArray(XDIM, YDIM, ZDIM, skyLight);
_blockLight = new YZXNibbleArray(XDIM, YDIM, ZDIM, blockLight);
_addBlocks = new YZXNibbleArray(XDIM, YDIM, ZDIM, addBlocks);
TagNodeCompound tree = new TagNodeCompound();
tree.Add("Y", new TagNodeByte(_y));
tree.Add("Blocks", blocks);
tree.Add("Data", data);
tree.Add("SkyLight", skyLight);
tree.Add("BlockLight", blockLight);
tree.Add("AddBlocks", addBlocks);
_tree = tree;
}
}
public class CompositeYZXByteArray : IDataArray3
{
private YZXByteArray[] _sections;
public CompositeYZXByteArray (YZXByteArray[] sections)
{
for (int i = 0; i < sections.Length; i++)
if (sections[i] == null)
throw new ArgumentException("sections argument cannot have null entries.");
for (int i = 0; i < sections.Length; i++) {
if (sections[i].Length != sections[0].Length
|| sections[i].XDim != sections[0].XDim
|| sections[i].YDim != sections[0].YDim
|| sections[i].ZDim != sections[0].ZDim)
throw new ArgumentException("All elements in sections argument must have same metrics.");
}
_sections = sections;
}
#region IByteArray3 Members
public int this[int x, int y, int z]
{
get
{
int ydiv = y / _sections[0].YDim;
int yrem = y - (ydiv * _sections[0].YDim);
return _sections[ydiv][x, yrem, z];
}
set
{
int ydiv = y / _sections[0].YDim;
int yrem = y - (ydiv * _sections[0].YDim);
_sections[ydiv][x, yrem, z] = value;
}
}
public int XDim
{
get { return _sections[0].XDim; }
}
public int YDim
{
get { return _sections[0].YDim * _sections.Length; }
}
public int ZDim
{
get { return _sections[0].ZDim; }
}
public int GetIndex (int x, int y, int z)
{
int ydiv = y / _sections[0].YDim;
int yrem = y - (ydiv * _sections[0].YDim);
return ydiv * _sections[ydiv].GetIndex(x, yrem, z);
}
public void GetMultiIndex (int index, out int x, out int y, out int z)
{
int idiv = index / _sections[0].Length;
int irem = index - (idiv * _sections[0].Length);
_sections[idiv].GetMultiIndex(irem, out x, out y, out z);
}
#endregion
#region IByteArray Members
public int this[int i]
{
get
{
int idiv = i / _sections[0].Length;
int irem = i - (idiv * _sections[0].Length);
return _sections[idiv][irem];
}
set
{
int idiv = i / _sections[0].Length;
int irem = i - (idiv * _sections[0].Length);
_sections[idiv][irem] = value;
}
}
public int Length
{
get { return _sections[0].Length * _sections.Length; }
}
public void Clear ()
{
for (int i = 0; i < _sections.Length; i++)
_sections[i].Clear();
}
#endregion
}
public class CompositeYZXNibbleArray : IDataArray3
{
private YZXNibbleArray[] _sections;
public CompositeYZXNibbleArray (YZXNibbleArray[] sections)
{
for (int i = 0; i < sections.Length; i++)
if (sections[i] == null)
throw new ArgumentException("sections argument cannot have null entries.");
for (int i = 0; i < sections.Length; i++) {
if (sections[i].Length != sections[0].Length
|| sections[i].XDim != sections[0].XDim
|| sections[i].YDim != sections[0].YDim
|| sections[i].ZDim != sections[0].ZDim)
throw new ArgumentException("All elements in sections argument must have same metrics.");
}
_sections = sections;
}
#region IByteArray3 Members
public int this[int x, int y, int z]
{
get
{
int ydiv = y / _sections[0].YDim;
int yrem = y - (ydiv * _sections[0].YDim);
return _sections[ydiv][x, yrem, z];
}
set
{
int ydiv = y / _sections[0].YDim;
int yrem = y - (ydiv * _sections[0].YDim);
_sections[ydiv][x, yrem, z] = (byte)value;
}
}
public int XDim
{
get { return _sections[0].XDim; }
}
public int YDim
{
get { return _sections[0].YDim * _sections.Length; }
}
public int ZDim
{
get { return _sections[0].ZDim; }
}
public int GetIndex (int x, int y, int z)
{
int ydiv = y / _sections[0].YDim;
int yrem = y - (ydiv * _sections[0].YDim);
return ydiv * _sections[ydiv].GetIndex(x, yrem, z);
}
public void GetMultiIndex (int index, out int x, out int y, out int z)
{
int idiv = index / _sections[0].Length;
int irem = index - (idiv * _sections[0].Length);
_sections[idiv].GetMultiIndex(irem, out x, out y, out z);
}
#endregion
#region IByteArray Members
public int this[int i]
{
get
{
int idiv = i / _sections[0].Length;
int irem = i - (idiv * _sections[0].Length);
return _sections[idiv][irem];
}
set
{
int idiv = i / _sections[0].Length;
int irem = i - (idiv * _sections[0].Length);
_sections[idiv][irem] = (byte)value;
}
}
public int Length
{
get { return _sections[0].Length * _sections.Length; }
}
public void Clear ()
{
for (int i = 0; i < _sections.Length; i++)
_sections[i].Clear();
}
#endregion
}
public class AnvilChunk : IChunk, INbtObject<AnvilChunk>, ICopyable<AnvilChunk>
{
public static SchemaNodeCompound LevelSchema = new SchemaNodeCompound()

View file

@ -0,0 +1,206 @@
using System;
using System.Collections.Generic;
using System.Text;
using Substrate.Nbt;
using Substrate.Core;
namespace Substrate
{
public class AnvilSection : INbtObject<AnvilSection>, ICopyable<AnvilSection>
{
public static SchemaNodeCompound SectionSchema = new SchemaNodeCompound()
{
new SchemaNodeArray("Blocks", 4096),
new SchemaNodeArray("Data", 2048),
new SchemaNodeArray("SkyLight", 2048),
new SchemaNodeArray("BlockLight", 2048),
new SchemaNodeScaler("Y", TagType.TAG_BYTE),
new SchemaNodeArray("AddBlocks", 2048, SchemaOptions.OPTIONAL),
};
private const int XDIM = 16;
private const int YDIM = 16;
private const int ZDIM = 16;
private const int MIN_Y = 0;
private const int MAX_Y = 15;
private TagNodeCompound _tree;
private byte _y;
private YZXByteArray _blocks;
private YZXNibbleArray _data;
private YZXNibbleArray _blockLight;
private YZXNibbleArray _skyLight;
private YZXNibbleArray _addBlocks;
private AnvilSection ()
{
}
public AnvilSection (int y)
{
if (y < MIN_Y || y > MAX_Y)
throw new ArgumentOutOfRangeException();
_y = (byte)y;
BuildNbtTree();
}
public AnvilSection (TagNodeCompound tree)
{
LoadTree(tree);
}
public int Y
{
get { return _y; }
set
{
if (value < MIN_Y || value > MAX_Y)
throw new ArgumentOutOfRangeException();
_y = (byte)value;
_tree["Y"].ToTagByte().Data = _y;
}
}
public YZXByteArray Blocks
{
get { return _blocks; }
}
public YZXNibbleArray Data
{
get { return _data; }
}
public YZXNibbleArray BlockLight
{
get { return _blockLight; }
}
public YZXNibbleArray SkyLight
{
get { return _skyLight; }
}
public YZXNibbleArray AddBlocks
{
get { return _addBlocks; }
}
public bool CheckEmpty ()
{
return CheckBlocksEmpty() && CheckAddBlocksEmpty();
}
private bool CheckBlocksEmpty ()
{
for (int i = 0; i < _blocks.Length; i++)
if (_blocks[i] != 0)
return false;
return true;
}
private bool CheckAddBlocksEmpty ()
{
if (_addBlocks != null)
for (int i = 0; i < _addBlocks.Length; i++)
if (_addBlocks[i] != 0)
return false;
return true;
}
#region INbtObject<AnvilSection> Members
public AnvilSection LoadTree (TagNode tree)
{
TagNodeCompound ctree = tree as TagNodeCompound;
if (ctree == null) {
return null;
}
_y = ctree["Y"] as TagNodeByte;
_blocks = new YZXByteArray(XDIM, YDIM, ZDIM, ctree["Blocks"] as TagNodeByteArray);
_data = new YZXNibbleArray(XDIM, YDIM, ZDIM, ctree["Data"] as TagNodeByteArray);
_skyLight = new YZXNibbleArray(XDIM, YDIM, ZDIM, ctree["SkyLight"] as TagNodeByteArray);
_blockLight = new YZXNibbleArray(XDIM, YDIM, ZDIM, ctree["BlockLight"] as TagNodeByteArray);
if (!ctree.ContainsKey("AddBlocks"))
ctree["AddBlocks"] = new TagNodeByteArray(new byte[2048]);
_addBlocks = new YZXNibbleArray(XDIM, YDIM, ZDIM, ctree["AddBlocks"] as TagNodeByteArray);
_tree = ctree;
return this;
}
public AnvilSection LoadTreeSafe (TagNode tree)
{
if (!ValidateTree(tree)) {
return null;
}
return LoadTree(tree);
}
public TagNode BuildTree ()
{
TagNodeCompound copy = new TagNodeCompound();
foreach (KeyValuePair<string, TagNode> node in _tree) {
copy.Add(node.Key, node.Value);
}
if (CheckAddBlocksEmpty())
copy.Remove("AddBlocks");
return copy;
}
public bool ValidateTree (TagNode tree)
{
NbtVerifier v = new NbtVerifier(tree, SectionSchema);
return v.Verify();
}
#endregion
#region ICopyable<AnvilSection> Members
public AnvilSection Copy ()
{
return new AnvilSection().LoadTree(_tree.Copy());
}
#endregion
private void BuildNbtTree ()
{
int elements3 = XDIM * YDIM * ZDIM;
TagNodeByteArray blocks = new TagNodeByteArray(new byte[elements3]);
TagNodeByteArray data = new TagNodeByteArray(new byte[elements3 >> 1]);
TagNodeByteArray skyLight = new TagNodeByteArray(new byte[elements3 >> 1]);
TagNodeByteArray blockLight = new TagNodeByteArray(new byte[elements3 >> 1]);
TagNodeByteArray addBlocks = new TagNodeByteArray(new byte[elements3 >> 1]);
_blocks = new YZXByteArray(XDIM, YDIM, ZDIM, blocks);
_data = new YZXNibbleArray(XDIM, YDIM, ZDIM, data);
_skyLight = new YZXNibbleArray(XDIM, YDIM, ZDIM, skyLight);
_blockLight = new YZXNibbleArray(XDIM, YDIM, ZDIM, blockLight);
_addBlocks = new YZXNibbleArray(XDIM, YDIM, ZDIM, addBlocks);
TagNodeCompound tree = new TagNodeCompound();
tree.Add("Y", new TagNodeByte(_y));
tree.Add("Blocks", blocks);
tree.Add("Data", data);
tree.Add("SkyLight", skyLight);
tree.Add("BlockLight", blockLight);
tree.Add("AddBlocks", addBlocks);
_tree = tree;
}
}
}

View file

@ -60,8 +60,8 @@ namespace Substrate
public const int RED_MUSHROOM = 40;
public const int GOLD_BLOCK = 41;
public const int IRON_BLOCK = 42;
public const int DOUBLE_SLAB = 43;
public const int SLAB = 44;
public const int DOUBLE_STONE_SLAB = 43;
public const int STONE_SLAB = 44;
public const int BRICK_BLOCK = 45;
public const int TNT = 46;
public const int BOOKSHELF = 47;
@ -140,6 +140,10 @@ namespace Substrate
public const int END_PORTAL_FRAME = 120;
public const int END_STONE = 121;
public const int DRAGON_EGG = 122;
public const int REDSTONE_LAMP_OFF = 123;
public const int REDSTONE_LAMP_ON = 124;
public const int DOUBLE_WOOD_SLAB = 125;
public const int WOOD_SLAB = 126;
}
/// <summary>
@ -553,8 +557,8 @@ namespace Substrate
public static BlockInfo RedMushroom;
public static BlockInfo GoldBlock;
public static BlockInfo IronBlock;
public static BlockInfo DoubleSlab;
public static BlockInfo Slab;
public static BlockInfo DoubleStoneSlab;
public static BlockInfo StoneSlab;
public static BlockInfo BrickBlock;
public static BlockInfo TNT;
public static BlockInfo Bookshelf;
@ -633,6 +637,10 @@ namespace Substrate
public static BlockInfo EndPortalFrame;
public static BlockInfo EndStone;
public static BlockInfo DragonEgg;
public static BlockInfo RedstoneLampOff;
public static BlockInfo RedstoneLampOn;
public static BlockInfo DoubleWoodSlab;
public static BlockInfo WoodSlab;
static BlockInfo ()
{
@ -687,8 +695,8 @@ namespace Substrate
RedMushroom = new BlockInfo(40, "Red Mushroom").SetOpacity(0).SetState(BlockState.NONSOLID).SetTick(10);
GoldBlock = new BlockInfo(41, "Gold Block");
IronBlock = new BlockInfo(42, "Iron Block");
DoubleSlab = new BlockInfo(43, "Double Slab");
Slab = new BlockInfo(44, "Slab").SetOpacity(0);
DoubleStoneSlab = new BlockInfo(43, "Double Slab");
StoneSlab = new BlockInfo(44, "Slab").SetOpacity(0);
BrickBlock = new BlockInfo(45, "Brick Block");
TNT = new BlockInfo(46, "TNT");
Bookshelf = new BlockInfo(47, "Bookshelf");
@ -767,6 +775,10 @@ namespace Substrate
EndPortalFrame = new BlockInfo(120, "End Portal Frame").SetLuminance(MAX_LUMINANCE);
EndStone = new BlockInfo(121, "End Stone");
DragonEgg = new BlockInfo(122, "Dragon Egg").SetOpacity(0).SetLuminance(1).SetTick(3);
RedstoneLampOff = new BlockInfo(123, "Redstone Lamp (Off)").SetTick(2);
RedstoneLampOn = new BlockInfo(124, "Redstone Lamp (On)").SetLuminance(15).SetTick(2);
DoubleWoodSlab = new BlockInfo(125, "Double Wood Slab");
WoodSlab = new BlockInfo(126, "Wood Slab");
for (int i = 0; i < MAX_BLOCKS; i++) {
if (_blockTable[i] == null) {
@ -778,7 +790,7 @@ namespace Substrate
Lava.SetLightTransmission(false);
StationaryLava.SetLightTransmission(false);
Slab.SetLightTransmission(false);
StoneSlab.SetLightTransmission(false);
WoodStairs.SetLightTransmission(false);
Farmland.SetLightTransmission(false);
CobbleStairs.SetLightTransmission(false);
@ -830,8 +842,8 @@ namespace Substrate
RedstoneTorchOn.SetDataLimits(0, 5, 0);
Rails.SetDataLimits(0, 9, 0);
Ladder.SetDataLimits(2, 5, 0);
WoodStairs.SetDataLimits(0, 3, 0);
CobbleStairs.SetDataLimits(0, 3, 0);
WoodStairs.SetDataLimits(0, 3, 0x4);
CobbleStairs.SetDataLimits(0, 3, 0x4);
Lever.SetDataLimits(0, 6, 0x8);
WoodDoor.SetDataLimits(0, 3, 0xC);
IronDoor.SetDataLimits(0, 3, 0xC);
@ -846,8 +858,8 @@ namespace Substrate
JackOLantern.SetDataLimits(0, 3, 0);
StonePlate.SetDataLimits(0, 0, 0x1);
WoodPlate.SetDataLimits(0, 0, 0x1);
Slab.SetDataLimits(0, 6, 0);
DoubleSlab.SetDataLimits(0, 3, 0);
StoneSlab.SetDataLimits(0, 5, 0);
DoubleStoneSlab.SetDataLimits(0, 5, 0x8);
Cactus.SetDataLimits(0, 5, 0);
Bed.SetDataLimits(0, 3, 0x8);
RedstoneRepeater.SetDataLimits(0, 0, 0xF);
@ -862,6 +874,8 @@ namespace Substrate
BrewingStand.SetDataLimits(0, 0, 0x7);
Cauldron.SetDataLimits(0, 3, 0);
EndPortalFrame.SetDataLimits(0, 0, 0x7);
WoodSlab.SetDataLimits(0, 5, 0);
DoubleWoodSlab.SetDataLimits(0, 5, 0x8);
}
}

View file

@ -0,0 +1,109 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Substrate.Core
{
public class CompositeYZXByteArray : IDataArray3
{
private YZXByteArray[] _sections;
public CompositeYZXByteArray (YZXByteArray[] sections)
{
for (int i = 0; i < sections.Length; i++)
if (sections[i] == null)
throw new ArgumentException("sections argument cannot have null entries.");
for (int i = 0; i < sections.Length; i++) {
if (sections[i].Length != sections[0].Length
|| sections[i].XDim != sections[0].XDim
|| sections[i].YDim != sections[0].YDim
|| sections[i].ZDim != sections[0].ZDim)
throw new ArgumentException("All elements in sections argument must have same metrics.");
}
_sections = sections;
}
#region IByteArray3 Members
public int this[int x, int y, int z]
{
get
{
int ydiv = y / _sections[0].YDim;
int yrem = y - (ydiv * _sections[0].YDim);
return _sections[ydiv][x, yrem, z];
}
set
{
int ydiv = y / _sections[0].YDim;
int yrem = y - (ydiv * _sections[0].YDim);
_sections[ydiv][x, yrem, z] = value;
}
}
public int XDim
{
get { return _sections[0].XDim; }
}
public int YDim
{
get { return _sections[0].YDim * _sections.Length; }
}
public int ZDim
{
get { return _sections[0].ZDim; }
}
public int GetIndex (int x, int y, int z)
{
int ydiv = y / _sections[0].YDim;
int yrem = y - (ydiv * _sections[0].YDim);
return ydiv * _sections[ydiv].GetIndex(x, yrem, z);
}
public void GetMultiIndex (int index, out int x, out int y, out int z)
{
int idiv = index / _sections[0].Length;
int irem = index - (idiv * _sections[0].Length);
_sections[idiv].GetMultiIndex(irem, out x, out y, out z);
}
#endregion
#region IByteArray Members
public int this[int i]
{
get
{
int idiv = i / _sections[0].Length;
int irem = i - (idiv * _sections[0].Length);
return _sections[idiv][irem];
}
set
{
int idiv = i / _sections[0].Length;
int irem = i - (idiv * _sections[0].Length);
_sections[idiv][irem] = value;
}
}
public int Length
{
get { return _sections[0].Length * _sections.Length; }
}
public void Clear ()
{
for (int i = 0; i < _sections.Length; i++)
_sections[i].Clear();
}
#endregion
}
}

View file

@ -0,0 +1,109 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Substrate.Core
{
public class CompositeYZXNibbleArray : IDataArray3
{
private YZXNibbleArray[] _sections;
public CompositeYZXNibbleArray (YZXNibbleArray[] sections)
{
for (int i = 0; i < sections.Length; i++)
if (sections[i] == null)
throw new ArgumentException("sections argument cannot have null entries.");
for (int i = 0; i < sections.Length; i++) {
if (sections[i].Length != sections[0].Length
|| sections[i].XDim != sections[0].XDim
|| sections[i].YDim != sections[0].YDim
|| sections[i].ZDim != sections[0].ZDim)
throw new ArgumentException("All elements in sections argument must have same metrics.");
}
_sections = sections;
}
#region IByteArray3 Members
public int this[int x, int y, int z]
{
get
{
int ydiv = y / _sections[0].YDim;
int yrem = y - (ydiv * _sections[0].YDim);
return _sections[ydiv][x, yrem, z];
}
set
{
int ydiv = y / _sections[0].YDim;
int yrem = y - (ydiv * _sections[0].YDim);
_sections[ydiv][x, yrem, z] = (byte)value;
}
}
public int XDim
{
get { return _sections[0].XDim; }
}
public int YDim
{
get { return _sections[0].YDim * _sections.Length; }
}
public int ZDim
{
get { return _sections[0].ZDim; }
}
public int GetIndex (int x, int y, int z)
{
int ydiv = y / _sections[0].YDim;
int yrem = y - (ydiv * _sections[0].YDim);
return ydiv * _sections[ydiv].GetIndex(x, yrem, z);
}
public void GetMultiIndex (int index, out int x, out int y, out int z)
{
int idiv = index / _sections[0].Length;
int irem = index - (idiv * _sections[0].Length);
_sections[idiv].GetMultiIndex(irem, out x, out y, out z);
}
#endregion
#region IByteArray Members
public int this[int i]
{
get
{
int idiv = i / _sections[0].Length;
int irem = i - (idiv * _sections[0].Length);
return _sections[idiv][irem];
}
set
{
int idiv = i / _sections[0].Length;
int irem = i - (idiv * _sections[0].Length);
_sections[idiv][irem] = (byte)value;
}
}
public int Length
{
get { return _sections[0].Length * _sections.Length; }
}
public void Clear ()
{
for (int i = 0; i < _sections.Length; i++)
_sections[i].Clear();
}
#endregion
}
}

View file

@ -153,6 +153,12 @@ namespace Substrate
ASCEND_EAST = 3,
}
[Flags]
public enum StairInversion
{
Inverted = 0x04,
}
public enum LeverOrientation
{
SOUTH = 1,
@ -243,6 +249,12 @@ namespace Substrate
STONE_BRICK = 5,
}
[Flags]
public enum SlabInversion
{
Inverted = 0x08,
}
public enum BedOrientation
{
WEST = 0,

View file

@ -137,8 +137,22 @@ namespace Substrate
public const int CAULDRON = 380;
public const int EYE_OF_ENDER = 381;
public const int GLISTERING_MELON = 382;
public const int GOLD_MUSIC_DISC = 2256;
public const int GREEN_MUSIC_DISC = 2257;
public const int SPAWN_EGG = 383;
public const int BOTTLE_O_ENCHANTING = 384;
public const int FIRE_CHARGE = 385;
public const int BOOK_AND_QUILL = 386;
public const int WRITTEN_BOOK = 387;
public const int MUSIC_DISC_13 = 2256;
public const int MUSIC_DISC_CAT = 2257;
public const int MUSIC_DISC_BLOCKS = 2258;
public const int MUSIC_DISC_CHIRP = 2259;
public const int MUSIC_DISC_FAR = 2260;
public const int MUSIC_DISC_MALL = 2261;
public const int MUSIC_DISC_MELLOHI = 2262;
public const int MUSIC_DISC_STAL = 2263;
public const int MUSIC_DISC_STRAD = 2264;
public const int MUSIC_DISC_WARD = 2265;
public const int MUSIC_DISC_11 = 2266;
}
/// <summary>
@ -384,8 +398,22 @@ namespace Substrate
public static ItemInfo Cauldron;
public static ItemInfo EyeOfEnder;
public static ItemInfo GlisteringMelon;
public static ItemInfo GoldMusicDisc;
public static ItemInfo GreenMusicDisc;
public static ItemInfo SpawnEgg;
public static ItemInfo BottleOEnchanting;
public static ItemInfo FireCharge;
public static ItemInfo BookAndQuill;
public static ItemInfo WrittenBook;
public static ItemInfo MusicDisc13;
public static ItemInfo MusicDiscCat;
public static ItemInfo MusicDiscBlocks;
public static ItemInfo MusicDiscChirp;
public static ItemInfo MusicDiscFar;
public static ItemInfo MusicDiscMall;
public static ItemInfo MusicDiscMellohi;
public static ItemInfo MusicDiscStal;
public static ItemInfo MusicDiscStrad;
public static ItemInfo MusicDiscWard;
public static ItemInfo MusicDisc11;
static ItemInfo ()
{
@ -519,8 +547,22 @@ namespace Substrate
Cauldron = new ItemInfo(380, "Cauldron");
EyeOfEnder = new ItemInfo(381, "Eye of Ender").SetStackSize(64);
GlisteringMelon = new ItemInfo(382, "Glistering Melon").SetStackSize(64);
GoldMusicDisc = new ItemInfo(2256, "Gold Music Disc");
GreenMusicDisc = new ItemInfo(2257, "Green Music Disc");
SpawnEgg = new ItemInfo(383, "Spawn Egg").SetStackSize(64);
BottleOEnchanting = new ItemInfo(384, "Bottle O' Enchanting").SetStackSize(64);
FireCharge = new ItemInfo(385, "Fire Charge").SetStackSize(64);
BookAndQuill = new ItemInfo(386, "Book and Quill");
WrittenBook = new ItemInfo(387, "Written Book");
MusicDisc13 = new ItemInfo(2256, "13 Disc");
MusicDiscCat = new ItemInfo(2257, "Cat Disc");
MusicDiscBlocks = new ItemInfo(2258, "Blocks Disc");
MusicDiscChirp = new ItemInfo(2259, "Chirp Disc");
MusicDiscFar = new ItemInfo(2260, "Far Disc");
MusicDiscMall = new ItemInfo(2261, "Mall Disc");
MusicDiscMellohi = new ItemInfo(2262, "Mellohi Disc");
MusicDiscStal = new ItemInfo(2263, "Stal Disc");
MusicDiscStrad = new ItemInfo(2264, "Strad Disc");
MusicDiscWard = new ItemInfo(2265, "Ward Disc");
MusicDisc11 = new ItemInfo(2266, "11 Disc");
}
}
}