diff --git a/MCGalaxy/Blocks/Block.Convert.cs b/MCGalaxy/Blocks/Block.Convert.cs
index 4f347cfec..4eb7c69e6 100644
--- a/MCGalaxy/Blocks/Block.Convert.cs
+++ b/MCGalaxy/Blocks/Block.Convert.cs
@@ -20,7 +20,7 @@ using BlockID = System.UInt16;
using BlockRaw = System.Byte;
namespace MCGalaxy {
- public sealed partial class Block {
+ public static partial class Block {
internal static string[] coreNames = new string[Block.Count];
public static bool Undefined(BlockID block) { return IsPhysicsType(block) && coreNames[block].CaselessEq("unknown"); }
diff --git a/MCGalaxy/Blocks/Block.CoreProps.cs b/MCGalaxy/Blocks/Block.CoreProps.cs
index 3fdd9a7f8..f42dcade1 100644
--- a/MCGalaxy/Blocks/Block.CoreProps.cs
+++ b/MCGalaxy/Blocks/Block.CoreProps.cs
@@ -21,8 +21,7 @@ using MCGalaxy.Blocks;
using BlockID = System.UInt16;
namespace MCGalaxy {
-
- public sealed partial class Block {
+ public static partial class Block {
public static BlockProps[] Props = new BlockProps[Block.ExtendedCount];
public static readonly object PropsLock = new object();
diff --git a/MCGalaxy/Blocks/Block.ID.cs b/MCGalaxy/Blocks/Block.ID.cs
index 2ba610358..fe4fe75d2 100644
--- a/MCGalaxy/Blocks/Block.ID.cs
+++ b/MCGalaxy/Blocks/Block.ID.cs
@@ -18,14 +18,33 @@
using System;
namespace MCGalaxy {
- public sealed partial class Block {
+ public static partial class Block {
public const byte OriginalMaxBlock = Obsidian;
public const byte OriginalCount = OriginalMaxBlock + 1;
public const byte CpeMaxBlock = StoneBrick;
public const byte CpeCount = CpeMaxBlock + 1;
public const int Count = 256;
+
+ #if TEN_BIT_BLOCKS
+ public const ushort MaxRaw = 767;
+ public const int ExtendedCount = 256 * 4;
+ public static ushort[] ExtendedBase = new ushort[Block.Count];
+ public static byte[] ExtendedClass = new byte[4];
+
+ static Block() {
+ ExtendedBase[custom_block] = Extended;
+ ExtendedBase[custom_block_2] = Extended * 2;
+ ExtendedBase[custom_block_3] = Extended * 3;
+
+ ExtendedClass[0] = Air;
+ ExtendedClass[1] = custom_block;
+ ExtendedClass[2] = custom_block_2;
+ ExtendedClass[3] = custom_block_3;
+ }
+ #else
public const ushort MaxRaw = 255;
public const int ExtendedCount = 256 * 2;
+ #endif
// Original blocks
public const byte Air = 0;
@@ -261,7 +280,10 @@ namespace MCGalaxy {
public const byte Geyser = 196;
public const byte Checkpoint = 197;
- // 198, 199 free
+ #if TEN_BIT_BLOCKS
+ public const byte custom_block_2 = 198;
+ public const byte custom_block_3 = 199;
+ #endif
// Air type blocks
public const byte Air_Flood = 200;
diff --git a/MCGalaxy/Blocks/Block.cs b/MCGalaxy/Blocks/Block.cs
index a20fc22a3..696b4e32c 100644
--- a/MCGalaxy/Blocks/Block.cs
+++ b/MCGalaxy/Blocks/Block.cs
@@ -22,7 +22,7 @@ using MCGalaxy.Maths;
using BlockID = System.UInt16;
namespace MCGalaxy {
- public sealed partial class Block {
+ public static partial class Block {
public static bool Walkthrough(BlockID block) {
return block == Air || block == Sapling || block == Block.Snow
diff --git a/MCGalaxy/Commands/World/CmdResizeLvl.cs b/MCGalaxy/Commands/World/CmdResizeLvl.cs
index 6ef69d016..1733e2218 100644
--- a/MCGalaxy/Commands/World/CmdResizeLvl.cs
+++ b/MCGalaxy/Commands/World/CmdResizeLvl.cs
@@ -69,7 +69,11 @@ namespace MCGalaxy.Commands.World {
{
byte block = lvl.blocks[x + lvl.Width * (z + y * lvl.Length)];
temp.blocks[x + width * (z + y * length)] = block;
+ #if TEN_BIT_BLOCKS
+ if (Block.ExtendedBase[block] == 0) continue;
+ #else
if (block != Block.custom_block) continue;
+ #endif
byte extBlock = lvl.FastGetExtTile(x, y, z);
temp.FastSetExtTile(x, y, z, extBlock);
diff --git a/MCGalaxy/Drawing/DrawOps/DrawOpPerformer.cs b/MCGalaxy/Drawing/DrawOps/DrawOpPerformer.cs
index 43e16eac9..3c1cbe76d 100644
--- a/MCGalaxy/Drawing/DrawOps/DrawOpPerformer.cs
+++ b/MCGalaxy/Drawing/DrawOps/DrawOpPerformer.cs
@@ -169,16 +169,25 @@ namespace MCGalaxy.Drawing.Ops {
int index = b.X + lvl.Width * (b.Z + b.Y * lvl.Length);
BlockID old = lvl.blocks[index];
+ #if TEN_BIT_BLOCKS
+ BlockID extended = Block.ExtendedBase[old];
+ if (extended > 0) old = (BlockID)(extended | lvl.FastGetExtTile(b.X, b.Y, b.Z));
+ #else
if (old == Block.custom_block) old = (BlockID)(Block.Extended | lvl.FastGetExtTile(b.X, b.Y, b.Z));
- if (old == Block.Invalid) return;
+ #endif
+ if (old == Block.Invalid) return;
// Check to make sure the block is actually different and that we can change it
if (old == b.Block || !lvl.CheckAffectPermissions(p, b.X, b.Y, b.Z, old, b.Block)) return;
// Set the block (inlined)
lvl.Changed = true;
if (b.Block >= Block.Extended) {
+ #if TEN_BIT_BLOCKS
+ lvl.blocks[index] = Block.ExtendedClass[b.Block >> Block.ExtendedShift];
+ #else
lvl.blocks[index] = Block.custom_block;
+ #endif
lvl.FastSetExtTile(b.X, b.Y, b.Z, (BlockRaw)b.Block);
} else {
lvl.blocks[index] = (BlockRaw)b.Block;
diff --git a/MCGalaxy/Generator/Foliage/AshTree.cs b/MCGalaxy/Generator/Foliage/AshTree.cs
index add51e0be..da570dea4 100644
--- a/MCGalaxy/Generator/Foliage/AshTree.cs
+++ b/MCGalaxy/Generator/Foliage/AshTree.cs
@@ -36,8 +36,8 @@ namespace MCGalaxy.Generator.Foliage {
public override void SetData(Random rnd, int value) {
this.rnd = rnd;
- height = (byte)value;
- size = (byte)(maxExtent + maxCluster);
+ height = value;
+ size = maxExtent + maxCluster;
branchBaseHeight = height / 4;
branchAmount = rnd.Next(10, 25);
diff --git a/MCGalaxy/Levels/Level.Blocks.cs b/MCGalaxy/Levels/Level.Blocks.cs
index fe56d86c5..fd74953c1 100644
--- a/MCGalaxy/Levels/Level.Blocks.cs
+++ b/MCGalaxy/Levels/Level.Blocks.cs
@@ -46,14 +46,24 @@ namespace MCGalaxy {
/// Undefined behaviour if coordinates are invalid.
public BlockID FastGetBlock(int index) {
byte raw = blocks[index];
+ #if TEN_BIT_BLOCKS
+ BlockID extended = Block.ExtendedBase[raw];
+ return extended == 0 ? raw : (BlockID)(extended | GetExtTile(index));
+ #else
return raw != Block.custom_block ? raw : (BlockID)(Block.Extended | GetExtTile(index));
+ #endif
}
/// Gets the block at the given coordinates.
/// Undefined behaviour if coordinates are invalid.
public BlockID FastGetBlock(ushort x, ushort y, ushort z) {
byte raw = blocks[x + Width * (z + y * Length)];
+ #if TEN_BIT_BLOCKS
+ BlockID extended = Block.ExtendedBase[raw];
+ return extended == 0 ? raw : (BlockID)(extended | FastGetExtTile(x, y, z));
+ #else
return raw != Block.custom_block ? raw : (BlockID)(Block.Extended | FastGetExtTile(x, y, z));
+ #endif
}
/// Gets the block at the given coordinates.
@@ -61,7 +71,13 @@ namespace MCGalaxy {
public BlockID GetBlock(ushort x, ushort y, ushort z) {
if (x >= Width || y >= Height || z >= Length || blocks == null) return Block.Invalid;
byte raw = blocks[x + Width * (z + y * Length)];
+
+ #if TEN_BIT_BLOCKS
+ BlockID extended = Block.ExtendedBase[raw];
+ return extended == 0 ? raw : (BlockID)(extended | FastGetExtTile(x, y, z));
+ #else
return raw != Block.custom_block ? raw : (BlockID)(Block.Extended | FastGetExtTile(x, y, z));
+ #endif
}
/// Gets the block at the given coordinates.
@@ -70,7 +86,13 @@ namespace MCGalaxy {
if (x >= Width || y >= Height || z >= Length || blocks == null) { index = -1; return Block.Invalid; }
index = x + Width * (z + y * Length);
byte raw = blocks[index];
+
+ #if TEN_BIT_BLOCKS
+ BlockID extended = Block.ExtendedBase[raw];
+ return extended == 0 ? raw : (BlockID)(extended | FastGetExtTile(x, y, z));
+ #else
return raw != Block.custom_block ? raw : (BlockID)(Block.Extended | FastGetExtTile(x, y, z));
+ #endif
}
/// Gets whether the block at the given coordinates is air.
@@ -256,7 +278,11 @@ namespace MCGalaxy {
errorLocation = "Setting tile";
if (block >= Block.Extended) {
- SetTile(x, y, z, Block.custom_block);
+ #if TEN_BIT_BLOCKS
+ SetTile(x, y, z, Block.ExtendedClass[block >> Block.ExtendedShift]);
+ #else
+ SetTile(x, y, z, Block.custom_block);
+ #endif
FastSetExtTile(x, y, z, (BlockRaw)block);
} else {
SetTile(x, y, z, (BlockRaw)block);
@@ -310,7 +336,12 @@ namespace MCGalaxy {
PhysicsArgs data = default(PhysicsArgs), bool addUndo = true) {
if (blocks == null || b < 0 || b >= blocks.Length) return false;
BlockID old = blocks[b];
- old = old != Block.custom_block ? old : (BlockID)(Block.Extended | GetExtTile(b));
+ #if TEN_BIT_BLOCKS
+ BlockID extended = Block.ExtendedBase[old];
+ if (extended > 0) old = (BlockID)(extended | GetExtTile(b));
+ #else
+ if (old == Block.custom_block) old = (BlockID)(Block.Extended | GetExtTile(b));
+ #endif
try
{
@@ -342,7 +373,11 @@ namespace MCGalaxy {
Changed = true;
if (block >= Block.Extended) {
+ #if TEN_BIT_BLOCKS
+ blocks[b] = Block.ExtendedClass[block >> Block.ExtendedShift];
+ #else
blocks[b] = Block.custom_block;
+ #endif
ushort x, y, z;
IntToPos(b, out x, out y, out z);
FastSetExtTile(x, y, z, (BlockRaw)block);
diff --git a/MCGalaxy/Levels/Level.Physics.cs b/MCGalaxy/Levels/Level.Physics.cs
index 2668d24b9..595570944 100644
--- a/MCGalaxy/Levels/Level.Physics.cs
+++ b/MCGalaxy/Levels/Level.Physics.cs
@@ -152,9 +152,16 @@ namespace MCGalaxy {
OnPhysicsUpdateEvent.Call(C.X, C.Y, C.Z, C.Data, this);
C.Block = blocks[chk.Index];
+ #if TEN_BIT_BLOCKS
+ BlockID extended = Block.ExtendedBase[C.Block];
+ if (extended > 0) {
+ C.Block = (BlockID)(extended | FastGetExtTile(C.X, C.Y, C.Z));
+ }
+ #else
if (C.Block == Block.custom_block) {
C.Block = (BlockID)(Block.Extended | FastGetExtTile(C.X, C.Y, C.Z));
}
+ #endif
if ((C.Data.Raw & mask) == 0 || C.Data.Type1 == PhysicsArgs.Custom || extraHandler(this, ref C)) {
HandlePhysics handler = handlers[C.Block];