Properly support air as a custom block

This commit is contained in:
UnknownShadow200 2017-09-11 10:05:41 +10:00
parent 12496aa19f
commit f657da8021
4 changed files with 22 additions and 23 deletions

View File

@ -116,7 +116,7 @@ namespace MCGalaxy
public const byte Door_Cobblestone = 80;
//public const byte Door_Cobblestone_air = 81;// unused in core
public const byte Door_Red = 83;
//public const byte Door_Red_air = 84; // unused in core
//public const byte Door_Red_air = 84; // unused in core
public const byte Door_Orange = 85;
public const byte Door_Yellow = 86;
@ -141,7 +141,7 @@ namespace MCGalaxy
public const byte Op_Water = 106;
public const byte Op_Lava = 107;
//public const byte GrieferStone = 108; // unused in core
//public const byte GrieferStone = 108; // unused in core
public const byte LavaSponge = 109;
public const byte FloatWood = 110;
@ -269,18 +269,18 @@ namespace MCGalaxy
public const byte Air_FloodLayer = 202;
public const byte Air_FloodDown = 203;
public const byte Air_FloodUp = 204;
//public const byte Door_Obsidian_air = 205; // unused in core
//public const byte Door_Glass_air = 206; // unused in core
//public const byte Door_Stone_air = 207; // unused in core
//public const byte Door_Leaves_air = 208; // unused in core
//public const byte Door_Sand_air = 209; // unused in core
//public const byte Door_Wood_air = 210; // unused in core
//public const byte Door_Obsidian_air = 205; // unused in core
//public const byte Door_Glass_air = 206; // unused in core
//public const byte Door_Stone_air = 207; // unused in core
//public const byte Door_Leaves_air = 208; // unused in core
//public const byte Door_Sand_air = 209; // unused in core
//public const byte Door_Wood_air = 210; // unused in core
public const byte Door_Green_air = 211;
public const byte Door_TNT_air = 212;
//public const byte Door_Slab_air = 213; // unused in core
//public const byte Door_Slab_air = 213; // unused in core
//public const byte Door_AirActivatable_air = 214;
//public const byte Door_Water_air = 215; // unused in core
//public const byte Door_Lava_air = 216; // unused in core
//public const byte Door_Water_air = 215; // unused in core
//public const byte Door_Lava_air = 216; // unused in core
public const byte Door_Air_air = 217;
// 218, 219 free
@ -289,11 +289,11 @@ namespace MCGalaxy
public const byte Door_Grass = 222;
public const byte Door_Blue = 223;
public const byte Door_Bookshelf = 224;
//public const byte Door_Iron_air = 225; // unused in core
//public const byte Door_Dirt_air = 226; // unused in core
//public const byte Door_Grass_air = 227; // unused in core
//public const byte Door_Blue_air = 228; // unused in core
//public const byte Door_Bookshelf_air = 229;// unused in core
//public const byte Door_Iron_air = 225; // unused in core
//public const byte Door_Dirt_air = 226; // unused in core
//public const byte Door_Grass_air = 227; // unused in core
//public const byte Door_Blue_air = 228; // unused in core
//public const byte Door_Bookshelf_air = 229; // unused in core
public const byte Train = 230;
@ -324,7 +324,7 @@ namespace MCGalaxy
public const byte SnakeTail = 252;
public const byte Door_Gold = 253;
//public const byte Door_Gold_air = 254; // unused in core
//public const byte Door_Gold_air = 254; // unused in core
public const byte Zero = 0xff; // backwards compatibility
public const byte Invalid = 0xff;

View File

@ -120,8 +120,7 @@ namespace MCGalaxy {
public static void LoadGlobal() {
BlockDefinition[] oldDefs = GlobalDefs;
GlobalDefs = Load(true, null);
GlobalDefs[Block.Air] = DefaultSet.MakeCustomBlock(Block.Air);
GlobalDefs[Block.Air].Name = "Air fallback";
GlobalDefs[Block.Air] = null;
try {
if (File.Exists(GlobalPath)) {
@ -266,7 +265,7 @@ namespace MCGalaxy {
internal static void SendLevelCustomBlocks(Player pl) {
BlockDefinition[] defs = pl.level.CustomBlockDefs;
for (int i = 1; i < defs.Length; i++) {
for (int i = 0; i < defs.Length; i++) {
BlockDefinition def = defs[i];
if (def != null) pl.Send(def.MakeDefinePacket(pl));
}
@ -274,7 +273,7 @@ namespace MCGalaxy {
internal static void SendLevelInventoryOrder(Player pl) {
BlockDefinition[] defs = pl.level.CustomBlockDefs;
for (int i = 1; i < defs.Length; i++) {
for (int i = 0; i < defs.Length; i++) {
BlockDefinition def = defs[i];
if (def != null && def.InventoryOrder >= 0) {
pl.Send(Packet.SetInventoryOrder((byte)i, (byte)def.InventoryOrder));

View File

@ -167,7 +167,7 @@ namespace MCGalaxy.Commands.CPE {
BlockDefinition[] defs = global ? BlockDefinition.GlobalDefs : p.level.CustomBlockDefs;
List<BlockDefinition> defsInScope = new List<BlockDefinition>();
for (int i = 1; i < Block.Count; i++) {
for (int i = 0; i < Block.Count; i++) {
BlockDefinition def = defs[i];
ExtBlock block = ExtBlock.FromRaw((byte)i);

View File

@ -236,7 +236,7 @@ namespace MCGalaxy {
void RemoveOldLevelCustomBlocks(Level oldLevel) {
BlockDefinition[] defs = oldLevel.CustomBlockDefs;
for (int i = 1; i < defs.Length; i++) {
for (int i = 0; i < defs.Length; i++) {
BlockDefinition def = defs[i];
if (def == BlockDefinition.GlobalDefs[i]) continue;
Send(Packet.UndefineBlock((byte)i));