mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-25 06:04:46 -04:00
Style: Rename Block.Zero to more logicial Block.Invalid
This commit is contained in:
parent
2351b447bb
commit
0eeed407b6
@ -82,7 +82,7 @@ namespace MCGalaxy.Blocks {
|
||||
|
||||
if (Block.Props[i].IsTDoor) {
|
||||
deleteHandlers[i] = DeleteBehaviour.RevertDoor;
|
||||
} else if (Block.Props[i].ODoorId != Block.Zero) {
|
||||
} else if (Block.Props[i].ODoorId != Block.Invalid) {
|
||||
deleteHandlers[i] = DeleteBehaviour.ODoor;
|
||||
} else if (Block.Props[i].IsDoor) {
|
||||
deleteHandlers[i] = DeleteBehaviour.Door;
|
||||
@ -175,7 +175,7 @@ namespace MCGalaxy.Blocks {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (Block.odoor((byte)i) != Block.Zero) {
|
||||
if (Block.odoor((byte)i) != Block.Invalid) {
|
||||
physicsHandlers[i] = DoorPhysics.oDoor;
|
||||
physicsDoorsHandlers[i] = DoorPhysics.oDoor;
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ namespace MCGalaxy.Blocks {
|
||||
if (above == Block.custom_block)
|
||||
extAbove = lvl.GetExtTile(x, (ushort)(y + 1), z);
|
||||
|
||||
block = (above == Block.Zero || Block.LightPass(above, extAbove, lvl.CustomBlockDefs))
|
||||
block = (above == Block.Invalid || Block.LightPass(above, extAbove, lvl.CustomBlockDefs))
|
||||
? Block.grass : Block.dirt;
|
||||
p.ChangeBlock(x, y, z, block, 0);
|
||||
return false;
|
||||
|
@ -29,7 +29,7 @@ namespace MCGalaxy
|
||||
return block;
|
||||
if (Aliases.TryGetValue(type.ToLower(), out block))
|
||||
return block;
|
||||
return Block.Zero;
|
||||
return Block.Invalid;
|
||||
}
|
||||
|
||||
public static byte ConvertCPE(byte block) {
|
||||
|
@ -33,7 +33,7 @@ namespace MCGalaxy {
|
||||
// Fallback for unrecognised physics blocks
|
||||
if (i >= CpeCount) Props[i].ConvertId = Block.orange;
|
||||
|
||||
if ((i >= op_glass && i <= op_lava) || i == Zero || i == rocketstart || i == blackrock)
|
||||
if ((i >= op_glass && i <= op_lava) || i == Invalid || i == rocketstart || i == blackrock)
|
||||
Props[i].OPBlock = true;
|
||||
|
||||
if ((i >= tdoor && i <= tdoor8) || (i >= tdoor9 && i <= tdoor13))
|
||||
@ -216,7 +216,7 @@ namespace MCGalaxy {
|
||||
|
||||
SetDeath(Block.air, "{0} %Shit the floor &chard.", false);
|
||||
SetDeath(Block.water, "{0} %S&cdrowned.", false);
|
||||
SetDeath(Block.Zero, "{0} %Swas &cterminated.", false);
|
||||
SetDeath(Block.Invalid, "{0} %Swas &cterminated.", false);
|
||||
}
|
||||
|
||||
static void SetDeath(byte block, string message, bool collideKill = true) {
|
||||
|
@ -92,7 +92,6 @@ namespace MCGalaxy
|
||||
public const byte pillar = 63;
|
||||
public const byte crate = 64;
|
||||
public const byte stonebrick = 65;
|
||||
public const byte Zero = 0xff;
|
||||
|
||||
public const byte door_darkpink_air = 66;
|
||||
public const byte door_darkgrey_air = 67;
|
||||
@ -312,5 +311,7 @@ namespace MCGalaxy
|
||||
|
||||
public const byte door_gold = 253;
|
||||
public const byte door_gold_air = 254;
|
||||
public const byte Zero = 0xff; // backwards compatibility
|
||||
public const byte Invalid = 0xff;
|
||||
}
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ namespace MCGalaxy
|
||||
b.type = (byte)i;
|
||||
switch (i)
|
||||
{
|
||||
case Zero:
|
||||
case Invalid:
|
||||
b.lowestRank = LevelPermission.Admin;
|
||||
break;
|
||||
|
||||
@ -316,7 +316,7 @@ namespace MCGalaxy
|
||||
string[] block = line.Split(colon, StringSplitOptions.None);
|
||||
Blocks newBlock = new Blocks();
|
||||
|
||||
if (Block.Byte(block[0]) == Block.Zero) continue;
|
||||
if (Block.Byte(block[0]) == Block.Invalid) continue;
|
||||
newBlock.type = Block.Byte(block[0]);
|
||||
|
||||
string[] disallow = null;
|
||||
|
@ -214,7 +214,7 @@ namespace MCGalaxy {
|
||||
}
|
||||
|
||||
public static byte GetBlock(string msg, BlockDefinition[] defs) {
|
||||
for (int i = 1; i < 255; i++) {
|
||||
for (int i = 1; i < Block.Invalid; i++) {
|
||||
BlockDefinition def = defs[i];
|
||||
if (def == null) continue;
|
||||
if (def.Name.Replace(" ", "").CaselessEq(msg))
|
||||
@ -223,7 +223,7 @@ namespace MCGalaxy {
|
||||
|
||||
byte id;
|
||||
if (!byte.TryParse(msg, out id) || defs[id] == null)
|
||||
return Block.Zero;
|
||||
return Block.Invalid;
|
||||
return id;
|
||||
}
|
||||
|
||||
|
@ -68,7 +68,7 @@ namespace MCGalaxy.Blocks {
|
||||
ConvertId = block;
|
||||
SaveConvertId = block;
|
||||
Name = "unknown";
|
||||
ODoorId = Block.Zero;
|
||||
ODoorId = Block.Invalid;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -108,7 +108,7 @@ namespace MCGalaxy.Bots {
|
||||
int dz = Math.Abs(bot.pos[2] - p.pos[2]);
|
||||
|
||||
if (dx <= 8 && dy <= 16 && dz <= 8) {
|
||||
p.HandleDeath(Block.Zero);
|
||||
p.HandleDeath(Block.Invalid);
|
||||
}
|
||||
}
|
||||
bot.NextInstruction(); return true;
|
||||
|
@ -82,7 +82,7 @@ namespace MCGalaxy.Commands.CPE {
|
||||
}
|
||||
} else {
|
||||
targetId = GetFreeId(global, p == null ? null : p.level);
|
||||
if (targetId == Block.Zero) {
|
||||
if (targetId == Block.Invalid) {
|
||||
Player.Message(p, "There are no custom block ids left, " +
|
||||
"you must " + cmd +" remove a custom block first.");
|
||||
return;
|
||||
@ -272,7 +272,7 @@ namespace MCGalaxy.Commands.CPE {
|
||||
step++;
|
||||
} else if (step == 19) {
|
||||
byte fallback = GetFallback(p, value);
|
||||
if (fallback == Block.Zero) { SendStepHelp(p, global); return; }
|
||||
if (fallback == Block.Invalid) { SendStepHelp(p, global); return; }
|
||||
bd.FallBack = fallback;
|
||||
|
||||
if (!AddCustomBlock(p, bd, global, cmd)) return;
|
||||
@ -405,7 +405,7 @@ namespace MCGalaxy.Commands.CPE {
|
||||
case "fallbackid":
|
||||
case "fallbackblock":
|
||||
byte fallback = GetFallback(p, value);
|
||||
if (fallback == Block.Zero) return;
|
||||
if (fallback == Block.Invalid) return;
|
||||
def.FallBack = fallback; break;
|
||||
default:
|
||||
Player.Message(p, "Unrecognised property: " + parts[2]); return;
|
||||
@ -423,7 +423,7 @@ namespace MCGalaxy.Commands.CPE {
|
||||
// in case the list is modified before we finish the command.
|
||||
if (def != null) {
|
||||
bd.BlockID = GetFreeId(global, p == null ? null : p.level);
|
||||
if (bd.BlockID == Block.Zero) {
|
||||
if (bd.BlockID == Block.Invalid) {
|
||||
Player.Message(p, "There are no custom block ids left, " +
|
||||
"you must " + cmd + " remove a custom block first.");
|
||||
if (!global) {
|
||||
@ -451,15 +451,15 @@ namespace MCGalaxy.Commands.CPE {
|
||||
|
||||
if (block == Block.custom_block) {
|
||||
Player.Message(p, "&cCustom blocks cannot be used as fallback blocks.");
|
||||
return Block.Zero;
|
||||
return Block.Invalid;
|
||||
}
|
||||
if (block >= Block.CpeCount) {
|
||||
Player.Message(p, "&cPhysics block cannot be used as fallback blocks.");
|
||||
return Block.Zero;
|
||||
return Block.Invalid;
|
||||
}
|
||||
if (block == Block.Zero) {
|
||||
if (block == Block.Invalid) {
|
||||
Player.Message(p, "&cCannot use 'skip block' as fallback block.");
|
||||
return Block.Zero;
|
||||
return Block.Invalid;
|
||||
}
|
||||
return (byte)block;
|
||||
}
|
||||
@ -480,16 +480,16 @@ namespace MCGalaxy.Commands.CPE {
|
||||
// Start from opposite ends to avoid overlap.
|
||||
if (global) {
|
||||
BlockDefinition[] defs = BlockDefinition.GlobalDefs;
|
||||
for (int i = Block.CpeCount; i < 255; i++) {
|
||||
for (int i = Block.CpeCount; i < Block.Invalid; i++) {
|
||||
if (defs[i] == null) return (byte)i;
|
||||
}
|
||||
} else {
|
||||
BlockDefinition[] defs = lvl.CustomBlockDefs;
|
||||
for (int i = 254; i >= Block.CpeCount; i--) {
|
||||
for (int i = Block.Invalid; i >= Block.CpeCount; i--) {
|
||||
if (defs[i] == null) return (byte)i;
|
||||
}
|
||||
}
|
||||
return Block.Zero;
|
||||
return Block.Invalid;
|
||||
}
|
||||
|
||||
static void MessageNoBlock(Player p, int id, bool global, string cmd) {
|
||||
@ -537,7 +537,7 @@ namespace MCGalaxy.Commands.CPE {
|
||||
if (!int.TryParse(arg, out blockId)) {
|
||||
Player.Message(p, "&cProvided block id is not a number."); return false;
|
||||
}
|
||||
if (blockId <= 0 || blockId >= 255) {
|
||||
if (blockId <= 0 || blockId >= Block.Invalid) {
|
||||
Player.Message(p, "&cBlock id must be between 1-254"); return false;
|
||||
}
|
||||
return true;
|
||||
|
@ -61,7 +61,7 @@ namespace MCGalaxy.Commands {
|
||||
lookedAt.Z = (ushort)Math.Round(start.Z + (double)(dir.Z * i));
|
||||
|
||||
byte tile = p.level.GetTile(lookedAt.X, lookedAt.Y, lookedAt.Z);
|
||||
if (tile == Block.Zero) break;
|
||||
if (tile == Block.Invalid) break;
|
||||
|
||||
if (tile != Block.air && !allBlocks.Contains(lookedAt) && HandlesHitBlock(p, tile, bp, pos, false))
|
||||
break;
|
||||
|
@ -56,7 +56,7 @@ namespace MCGalaxy.Commands {
|
||||
|
||||
string src = p == null ? "(console)" : p.ColoredName;
|
||||
for (ushort yy = curY; yy <= 1000; yy++) {
|
||||
if (!Block.Walkthrough(who.level.GetTile(curX, yy, curZ)) && who.level.GetTile(curX, yy, curZ) != Block.Zero) {
|
||||
if (!Block.Walkthrough(who.level.GetTile(curX, yy, curZ)) && who.level.GetTile(curX, yy, curZ) != Block.Invalid) {
|
||||
foundHeight = (ushort)(yy - 1);
|
||||
who.level.ChatLevel(who.ColoredName + " %Swas slapped into the roof by " + src);
|
||||
break;
|
||||
|
@ -39,7 +39,7 @@ namespace MCGalaxy.Commands {
|
||||
void PlacedBlock(Player p, ushort x, ushort y, ushort z, byte type, byte extType) {
|
||||
if (!p.staticCommands) p.ClearBlockchange();
|
||||
byte b = p.level.GetTile(x, y, z);
|
||||
if (b == Block.Zero) { Player.Message(p, "Invalid Block ({0}, {1}, {2}).", x, y, z); return; }
|
||||
if (b == Block.Invalid) { Player.Message(p, "Invalid Block ({0}, {1}, {2}).", x, y, z); return; }
|
||||
p.RevertBlock(x, y, z);
|
||||
|
||||
byte id = b;
|
||||
|
@ -45,7 +45,7 @@ namespace MCGalaxy.Commands
|
||||
Player.Message(p, "Complex blocks: ");
|
||||
MultiPageOutput.Output(p, ComplexBlocks(), (name, i) => name,
|
||||
"blocks complex", "blocks", modifier, false);
|
||||
} else if (Block.Byte(args[0]) != Block.Zero) {
|
||||
} else if (Block.Byte(args[0]) != Block.Invalid) {
|
||||
OutputBlockData(p, args[0]);
|
||||
} else if (Group.Find(args[0]) != null) {
|
||||
Group grp = Group.Find(args[0]);
|
||||
@ -74,7 +74,7 @@ namespace MCGalaxy.Commands
|
||||
|
||||
static List<string> ComplexBlocks() {
|
||||
List<string> items = new List<string>(256);
|
||||
for (int i = Block.CpeCount; i < Block.Zero; i++) {
|
||||
for (int i = Block.CpeCount; i < Block.Invalid; i++) {
|
||||
if (Block.Props[i].Name.CaselessEq("unknown")) continue;
|
||||
items.Add(Block.Props[i].Name);
|
||||
}
|
||||
@ -102,7 +102,7 @@ namespace MCGalaxy.Commands
|
||||
}
|
||||
|
||||
string msg = "";
|
||||
for (byte i = Block.CpeCount; i < Block.Zero; i++) {
|
||||
for (byte i = Block.CpeCount; i < Block.Invalid; i++) {
|
||||
if (Block.Convert(i) == b)
|
||||
msg += Block.Name(i) + ", ";
|
||||
}
|
||||
@ -133,7 +133,7 @@ namespace MCGalaxy.Commands
|
||||
|
||||
if (props.IsDoor) Player.Message(p, "Block is an ordinary door");
|
||||
if (props.IsTDoor) Player.Message(p, "Block is a tdoor, which allows other blocks through when open");
|
||||
if (props.ODoorId != Block.Zero) Player.Message(p, "Block is an odoor, which toggles (GLITCHY)");
|
||||
if (props.ODoorId != Block.Invalid) Player.Message(p, "Block is an odoor, which toggles (GLITCHY)");
|
||||
|
||||
if (Block.Mover(b)) Player.Message(p, "Block can be activated by walking through it");
|
||||
}
|
||||
|
@ -94,7 +94,7 @@ namespace MCGalaxy.Commands {
|
||||
|
||||
bool ParseBlock(Player p, string message) {
|
||||
byte b = Block.Byte(message);
|
||||
if (b == Block.Zero) return false;
|
||||
if (b == Block.Invalid) return false;
|
||||
|
||||
//give more useful help messages for doors and other physics blocks and killer blocks
|
||||
switch (message.ToLower())
|
||||
|
@ -32,7 +32,7 @@ namespace MCGalaxy.Commands {
|
||||
byte toIgnore = Block.air;
|
||||
if (message != "") {
|
||||
toIgnore = Block.Byte(message);
|
||||
if (toIgnore == Block.Zero) {
|
||||
if (toIgnore == Block.Invalid) {
|
||||
Player.Message(p, "Could not find block specified"); return;
|
||||
}
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ namespace MCGalaxy.Commands {
|
||||
|
||||
static void SearchBlocks(Player p, string keyword, string modifier) {
|
||||
List<string> blocks = new List<string>();
|
||||
for (byte id = 0; id < 255; id++) {
|
||||
for (byte id = 0; id < Block.Invalid; id++) {
|
||||
string name = Block.Name(id);
|
||||
if (name.CaselessContains(keyword) && !name.CaselessEq("unknown"))
|
||||
blocks.Add(name);
|
||||
|
@ -29,7 +29,7 @@ namespace MCGalaxy.Commands {
|
||||
if (args.Length < 2) { Help(p); return; }
|
||||
|
||||
byte block = Block.Byte(args[0]);
|
||||
if (block == Block.Zero) { Player.Message(p, "Could not find block entered"); return; }
|
||||
if (block == Block.Invalid) { Player.Message(p, "Could not find block entered"); return; }
|
||||
Group grp = Group.FindMatches(p, args[1]);
|
||||
if (grp == null) return;
|
||||
|
||||
|
@ -35,7 +35,7 @@ namespace MCGalaxy.Commands.World {
|
||||
if (scope == null) return;
|
||||
|
||||
byte id = GetBlock(p, scope, args[1]);
|
||||
if (id == Block.Zero) return;
|
||||
if (id == Block.Invalid) return;
|
||||
string prop = args[2].ToLower();
|
||||
|
||||
// TODO: global and level custom blocks
|
||||
@ -60,18 +60,18 @@ namespace MCGalaxy.Commands.World {
|
||||
|
||||
if (Block.Name(id).CaselessEq("unknown")) {
|
||||
Player.Message(p, "&cThere is no block with id or name \"{0}\"", block);
|
||||
id = Block.Zero;
|
||||
id = Block.Invalid;
|
||||
}
|
||||
} else if (scope == BlockDefinition.GlobalProps) {
|
||||
id = BlockDefinition.GetBlock(block, BlockDefinition.GlobalDefs);
|
||||
if (id == Block.Zero)
|
||||
if (id == Block.Invalid)
|
||||
Player.Message(p, "&cThere is no global custom block with id or name \"{0}\"", block);
|
||||
} else {
|
||||
id = BlockDefinition.GetBlock(block, p.level.CustomBlockDefs);
|
||||
if (id == Block.Zero)
|
||||
if (id == Block.Invalid)
|
||||
Player.Message(p, "&cThere is no level custom block with id or name \"{0}\"", block);
|
||||
if (p.level.CustomBlockDefs[id] == BlockDefinition.GlobalDefs[id]) {
|
||||
Player.Message(p, "&cUse %T/blockprops global &cto modify this custom block."); return Block.Zero;
|
||||
Player.Message(p, "&cUse %T/blockprops global &cto modify this custom block."); return Block.Invalid;
|
||||
}
|
||||
}
|
||||
return id;
|
||||
|
@ -30,7 +30,7 @@ namespace MCGalaxy.Commands
|
||||
if (p == null) { MessageInGameOnly(p); return; }
|
||||
if (message == "") { Help(p); return; }
|
||||
|
||||
if (!message.CaselessEq("all") && Block.Byte(message) == Block.Zero) {
|
||||
if (!message.CaselessEq("all") && Block.Byte(message) == Block.Invalid) {
|
||||
Player.Message(p, "There is no block \"" + message + "\"."); return;
|
||||
}
|
||||
int phys = p.level.physics;
|
||||
|
@ -38,8 +38,8 @@ namespace MCGalaxy.Commands.Building {
|
||||
if (args.Length == 2) {
|
||||
byte src = Block.Byte(args[0]);
|
||||
byte dst = Block.Byte(args[1]);
|
||||
if (src == Block.Zero) { Player.Message(p, "There is no block \"{0}\".", src); return; }
|
||||
if (dst == Block.Zero) { Player.Message(p, "There is no block \"{1}\".", dst); return; }
|
||||
if (src == Block.Invalid) { Player.Message(p, "There is no block \"{0}\".", src); return; }
|
||||
if (dst == Block.Invalid) { Player.Message(p, "There is no block \"{1}\".", dst); return; }
|
||||
|
||||
if (!Block.Placable(src)) { Player.Message(p, Block.Name(src) + " isn't a special block."); return; }
|
||||
if (!Block.canPlace(p, dst)) { Formatter.MessageBlock(p, "bind ", dst); return; }
|
||||
|
@ -29,10 +29,10 @@ namespace MCGalaxy.Commands.Building {
|
||||
public CmdHollow() { }
|
||||
|
||||
public override void Use(Player p, string message) {
|
||||
byte skip = Block.Zero;
|
||||
byte skip = Block.Invalid;
|
||||
if (message != "") {
|
||||
skip = Block.Byte(message);
|
||||
if (skip == Block.Zero) { Player.Message(p, "Cannot find block entered."); return; }
|
||||
if (skip == Block.Invalid) { Player.Message(p, "Cannot find block entered."); return; }
|
||||
}
|
||||
|
||||
Player.Message(p, "Place two blocks to determine the edges.");
|
||||
|
@ -67,7 +67,7 @@ namespace MCGalaxy.Commands.Building {
|
||||
extBlock = 0;
|
||||
byte id = Block.Byte(name);
|
||||
if (Block.Props[id].IsMessageBlock) return id;
|
||||
if (name == "show") { ShowMessageBlocks(p); return Block.Zero; }
|
||||
if (name == "show") { ShowMessageBlocks(p); return Block.Invalid; }
|
||||
|
||||
id = BlockDefinition.GetBlock(name, p);
|
||||
if (p.level.CustomBlockProps[id].IsMessageBlock) {
|
||||
@ -83,7 +83,7 @@ namespace MCGalaxy.Commands.Building {
|
||||
if (name == "lava") id = Block.MsgLava;
|
||||
|
||||
allMessage = id == Block.MsgWhite && name != "white";
|
||||
if (!Block.Props[id].IsMessageBlock) { Help(p); return Block.Zero; }
|
||||
if (!Block.Props[id].IsMessageBlock) { Help(p); return Block.Invalid; }
|
||||
return id;
|
||||
}
|
||||
|
||||
|
@ -38,7 +38,7 @@ namespace MCGalaxy.Commands.Building {
|
||||
}
|
||||
|
||||
byte block = Block.Byte(message);
|
||||
if (block == Block.Zero) { Player.Message(p, "Could not find block given."); return; }
|
||||
if (block == Block.Invalid) { Player.Message(p, "Could not find block given."); return; }
|
||||
if (block == Block.air) { Player.Message(p, "Cannot use Air Mode."); return; }
|
||||
|
||||
if (!p.allowTnt && (block == Block.tnt || block == Block.bigtnt || block == Block.smalltnt
|
||||
|
@ -53,7 +53,7 @@ namespace MCGalaxy.Commands.Building {
|
||||
Player.Message(p, "Invalid parameters"); return;
|
||||
}
|
||||
|
||||
if (block == -1 || block == Block.Zero) return;
|
||||
if (block == -1 || block == Block.Invalid) return;
|
||||
if (!Block.canPlace(p, (byte)block)) { Formatter.MessageBlock(p, "place ", (byte)block); return; }
|
||||
Vec3U16 P = Vec3U16.ClampPos(x, y, z, p.level);
|
||||
|
||||
|
@ -43,7 +43,7 @@ namespace MCGalaxy.Commands.Building {
|
||||
}
|
||||
|
||||
data.Block = GetBlock(p, block, out data.ExtBlock);
|
||||
if (data.Block == Block.Zero) return;
|
||||
if (data.Block == Block.Invalid) return;
|
||||
|
||||
Player.Message(p, "Place an &aEntry block %Sfor the portal");
|
||||
p.ClearBlockchange();
|
||||
@ -56,7 +56,7 @@ namespace MCGalaxy.Commands.Building {
|
||||
extBlock = 0;
|
||||
byte id = Block.Byte(name);
|
||||
if (Block.Props[id].IsPortal) return id;
|
||||
if (name == "show") { ShowPortals(p); return Block.Zero; }
|
||||
if (name == "show") { ShowPortals(p); return Block.Invalid; }
|
||||
|
||||
id = BlockDefinition.GetBlock(name, p);
|
||||
if (p.level.CustomBlockProps[id].IsPortal) {
|
||||
@ -64,7 +64,7 @@ namespace MCGalaxy.Commands.Building {
|
||||
}
|
||||
|
||||
// Hardcoded aliases for backwards compatibility
|
||||
id = Block.Zero;
|
||||
id = Block.Invalid;
|
||||
if (name == "") id = Block.blue_portal;
|
||||
if (name == "blue") id = Block.blue_portal;
|
||||
if (name == "orange") id = Block.orange_portal;
|
||||
@ -72,7 +72,7 @@ namespace MCGalaxy.Commands.Building {
|
||||
if (name == "water") id = Block.water_portal;
|
||||
if (name == "lava") id = Block.lava_portal;
|
||||
|
||||
if (!Block.Props[id].IsPortal) { Help(p); return Block.Zero; }
|
||||
if (!Block.Props[id].IsPortal) { Help(p); return Block.Invalid; }
|
||||
return id;
|
||||
}
|
||||
|
||||
|
@ -62,7 +62,7 @@ namespace MCGalaxy.Commands.Building {
|
||||
bool Parse(Player p, string name, string arg, ref byte type, ref byte value) {
|
||||
if (name == "revert") {
|
||||
byte block = Block.Byte(arg);
|
||||
if (block == Block.Zero) { Player.Message(p, "Invalid block type."); return false; }
|
||||
if (block == Block.Invalid) { Player.Message(p, "Invalid block type."); return false; }
|
||||
type = PhysicsArgs.Revert; value = block;
|
||||
return true;
|
||||
}
|
||||
|
@ -83,12 +83,12 @@ namespace MCGalaxy.Commands.Building {
|
||||
bool checkPlacePerm = true) {
|
||||
byte block = Block.Byte(msg);
|
||||
extBlock = 0;
|
||||
if (msg.CaselessEq("skip") || msg.CaselessEq("none")) return Block.Zero;
|
||||
if (msg.CaselessEq("skip") || msg.CaselessEq("none")) return Block.Invalid;
|
||||
|
||||
if (block == Block.Zero) {
|
||||
if (block == Block.Invalid) {
|
||||
// try treat as a block definition id.
|
||||
block = BlockDefinition.GetBlock(msg, p);
|
||||
if (block == Block.Zero) {
|
||||
if (block == Block.Invalid) {
|
||||
Player.Message(p, "&cThere is no block \"{0}\".", msg);
|
||||
return -1;
|
||||
}
|
||||
|
@ -36,9 +36,9 @@ namespace MCGalaxy.Commands {
|
||||
while (y < p.level.Height) {
|
||||
y++;
|
||||
byte block = p.level.GetTile(x, y, z);
|
||||
if (!(Block.Convert(block) == Block.air || block == Block.Zero)) continue;
|
||||
if (!(Block.Convert(block) == Block.air || block == Block.Invalid)) continue;
|
||||
byte above = p.level.GetTile(x, (ushort)(y + 1), z);
|
||||
if (!(Block.Convert(above) == Block.air || above == Block.Zero)) continue;
|
||||
if (!(Block.Convert(above) == Block.air || above == Block.Invalid)) continue;
|
||||
|
||||
byte below = p.level.GetTile(x, (ushort)(y - 1), z);
|
||||
if (Solid(Block.Convert(below))) {
|
||||
@ -51,7 +51,7 @@ namespace MCGalaxy.Commands {
|
||||
}
|
||||
|
||||
static bool Solid(byte b) {
|
||||
return b != Block.air && (b < Block.water || b > Block.lavastill) && b != Block.Zero
|
||||
return b != Block.air && (b < Block.water || b > Block.lavastill) && b != Block.Invalid
|
||||
&& b != Block.shrub && (b < Block.yellowflower || b > Block.redmushroom);
|
||||
}
|
||||
|
||||
|
@ -36,9 +36,9 @@ namespace MCGalaxy.Commands {
|
||||
while (y > 0) {
|
||||
y--;
|
||||
byte block = p.level.GetTile(x, y, z);
|
||||
if (!(Block.Convert(block) == Block.air || block == Block.Zero)) continue;
|
||||
if (!(Block.Convert(block) == Block.air || block == Block.Invalid)) continue;
|
||||
byte above = p.level.GetTile(x, (ushort)(y + 1), z);
|
||||
if (!(Block.Convert(above) == Block.air || above == Block.Zero)) continue;
|
||||
if (!(Block.Convert(above) == Block.air || above == Block.Invalid)) continue;
|
||||
|
||||
byte below = p.level.GetTile(x, (ushort)(y - 1), z);
|
||||
if (Solid(Block.Convert(below))) {
|
||||
@ -51,7 +51,7 @@ namespace MCGalaxy.Commands {
|
||||
}
|
||||
|
||||
static bool Solid(byte b) {
|
||||
return b != Block.air && (b < Block.water || b > Block.lavastill) && b != Block.Zero
|
||||
return b != Block.air && (b < Block.water || b > Block.lavastill) && b != Block.Invalid
|
||||
&& b != Block.shrub && (b < Block.yellowflower || b > Block.redmushroom);
|
||||
}
|
||||
|
||||
|
@ -73,7 +73,7 @@ namespace MCGalaxy.Drawing.Brushes {
|
||||
count = new int[blocks.Length];
|
||||
for (int i = 0; i < count.Length; i++) {
|
||||
count[i] = 1;
|
||||
blocks[i] = new ExtBlock(Block.Zero, 0);
|
||||
blocks[i] = new ExtBlock(Block.Invalid, 0);
|
||||
}
|
||||
|
||||
// No blocks given, assume first is held block
|
||||
|
@ -51,7 +51,7 @@ namespace MCGalaxy.Drawing.Brushes {
|
||||
internal static ExtBlock[] GetBlocks(Player p, int start, int max, string[] parts) {
|
||||
ExtBlock[] blocks = new ExtBlock[max - start];
|
||||
for (int i = 0; i < blocks.Length; i++)
|
||||
blocks[i].Block = Block.Zero;
|
||||
blocks[i].Block = Block.Invalid;
|
||||
for (int i = 0; start < max; start++, i++ ) {
|
||||
byte extBlock = 0;
|
||||
int block = DrawCmd.GetBlock(p, parts[start], out extBlock);
|
||||
|
@ -65,7 +65,7 @@ namespace MCGalaxy.Drawing.Brushes {
|
||||
int block1 = DrawCmd.GetBlock(args.Player, parts[0], out extBlock1);
|
||||
if (block1 == -1) return null;
|
||||
if (parts.Length == 1)
|
||||
return new CheckeredBrush((byte)block1, extBlock1, Block.Zero, 0);
|
||||
return new CheckeredBrush((byte)block1, extBlock1, Block.Invalid, 0);
|
||||
|
||||
byte extBlock2;
|
||||
int block2 = DrawCmd.GetBlock(args.Player, parts[1], out extBlock2);
|
||||
|
@ -41,7 +41,7 @@ namespace MCGalaxy.Drawing.Brushes {
|
||||
if (tile == block.Block && (tile != Block.custom_block || extTile == block.Ext))
|
||||
return target.Block;
|
||||
}
|
||||
return Block.Zero;
|
||||
return Block.Invalid;
|
||||
}
|
||||
|
||||
public override byte NextExtBlock(DrawOp op) { return target.Ext; }
|
||||
@ -65,7 +65,7 @@ namespace MCGalaxy.Drawing.Brushes {
|
||||
for (int i = 0; i < exclude.Length; i++) {
|
||||
ExtBlock block = exclude[i];
|
||||
if (tile == block.Block && (tile != Block.custom_block || extTile == block.Ext))
|
||||
return Block.Zero;
|
||||
return Block.Invalid;
|
||||
}
|
||||
return target.Block;
|
||||
}
|
||||
|
@ -165,9 +165,9 @@ namespace MCGalaxy.Drawing.Ops {
|
||||
}
|
||||
|
||||
static void SetTileOutput(DrawOpBlock b, Player p, Level lvl) {
|
||||
if (b.Block == Block.Zero) return;
|
||||
if (b.Block == Block.Invalid) return;
|
||||
byte old = lvl.GetTile(b.X, b.Y, b.Z);
|
||||
if (old == Block.Zero) return;
|
||||
if (old == Block.Invalid) return;
|
||||
|
||||
bool same = old == b.Block;
|
||||
if (same && b.Block == Block.custom_block)
|
||||
@ -180,7 +180,7 @@ namespace MCGalaxy.Drawing.Ops {
|
||||
}
|
||||
|
||||
static void BufferedOutput(DrawOpBlock b, Player p, Level lvl) {
|
||||
if (b.Block == Block.Zero) return;
|
||||
if (b.Block == Block.Invalid) return;
|
||||
if (!lvl.DoBlockchange(p, b.X, b.Y, b.Z, b.Block, b.ExtBlock, true)) return;
|
||||
|
||||
int index = lvl.PosToInt(b.X, b.Y, b.Z);
|
||||
@ -189,7 +189,7 @@ namespace MCGalaxy.Drawing.Ops {
|
||||
}
|
||||
|
||||
static void SlowOutput(DrawOpBlock b, Player p, Level lvl) {
|
||||
if (b.Block == Block.Zero) return;
|
||||
if (b.Block == Block.Invalid) return;
|
||||
if (!lvl.DoBlockchange(p, b.X, b.Y, b.Z, b.Block, b.ExtBlock, true)) return;
|
||||
|
||||
int index = lvl.PosToInt(b.X, b.Y, b.Z);
|
||||
|
@ -40,7 +40,7 @@ namespace MCGalaxy {
|
||||
|
||||
public byte GetTile(ushort x, ushort y, ushort z) {
|
||||
int index = PosToInt(x, y, z);
|
||||
if (index < 0 || blocks == null) return Block.Zero;
|
||||
if (index < 0 || blocks == null) return Block.Invalid;
|
||||
return blocks[index];
|
||||
}
|
||||
|
||||
@ -52,7 +52,7 @@ namespace MCGalaxy {
|
||||
|
||||
public byte GetExtTile(ushort x, ushort y, ushort z) {
|
||||
int index = PosToInt(x, y, z);
|
||||
if (index < 0 || blocks == null) return Block.Zero;
|
||||
if (index < 0 || blocks == null) return Block.Invalid;
|
||||
|
||||
int cx = x >> 4, cy = y >> 4, cz = z >> 4;
|
||||
byte[] chunk = CustomBlocks[(cy * ChunksZ + cz) * ChunksX + cx];
|
||||
@ -455,7 +455,7 @@ namespace MCGalaxy {
|
||||
return Block.Name(block);
|
||||
|
||||
BlockDefinition[] defs = CustomBlockDefs;
|
||||
for (int i = 1; i < 255; i++) {
|
||||
for (int i = 1; i < Block.Invalid; i++) {
|
||||
BlockDefinition def = defs[i];
|
||||
if (def == null) continue;
|
||||
if (def.BlockID == extBlock) return def.Name.Replace(" ", "");
|
||||
|
@ -96,7 +96,7 @@ namespace MCGalaxy {
|
||||
static bool CheckBlock(Player p, string value, string variable, ref int modify) {
|
||||
byte extBlock = 0;
|
||||
int block = DrawCmd.GetBlock(p, value, out extBlock, false);
|
||||
if (block == -1 || block == Block.Zero) return false;
|
||||
if (block == -1 || block == Block.Invalid) return false;
|
||||
if (block >= Block.CpeCount && block != Block.custom_block) {
|
||||
Player.Message(p, "Cannot use physics block ids for /env."); return false;
|
||||
}
|
||||
|
@ -73,7 +73,7 @@ namespace MCGalaxy.BlockPhysics {
|
||||
lvl.AddUpdate(index, Block.air, false, args);
|
||||
} else {
|
||||
byte oDoor = Block.odoor(b);
|
||||
if (oDoor != Block.Zero)
|
||||
if (oDoor != Block.Invalid)
|
||||
lvl.AddUpdate(index, oDoor, true);
|
||||
}
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ namespace MCGalaxy.BlockPhysics {
|
||||
|
||||
do {
|
||||
index = lvl.IntOffset(index, 0, -1, 0); //Get block below each loop
|
||||
if (lvl.GetTile(index) == Block.Zero) break;
|
||||
if (lvl.GetTile(index) == Block.Invalid) break;
|
||||
bool hitBlock = false;
|
||||
|
||||
switch (lvl.blocks[index]) {
|
||||
@ -155,7 +155,7 @@ namespace MCGalaxy.BlockPhysics {
|
||||
{
|
||||
int index = lvl.IntOffset(C.b, x, y, z);
|
||||
byte block = lvl.GetTile(index);
|
||||
if (block == Block.Zero) continue;
|
||||
if (block == Block.Invalid) continue;
|
||||
|
||||
if ((!lava && Block.Convert(block) == Block.water) || (lava && Block.Convert(block) == Block.lava))
|
||||
lvl.AddUpdate(index, Block.air);
|
||||
@ -172,7 +172,7 @@ namespace MCGalaxy.BlockPhysics {
|
||||
{
|
||||
int index = lvl.IntOffset(b, x, y, z);
|
||||
byte block = lvl.GetTile(index);
|
||||
if (block == Block.Zero) continue;
|
||||
if (block == Block.Invalid) continue;
|
||||
|
||||
if ((!lava && Block.Convert(block) == Block.water) || (lava && Block.Convert(block) == Block.lava))
|
||||
lvl.AddCheck(index);
|
||||
|
@ -37,7 +37,7 @@ namespace MCGalaxy.BlockPhysics {
|
||||
if (rocketTail != Block.lava_fire) continue;
|
||||
|
||||
int headIndex = lvl.PosToInt((ushort)(x - cx), (ushort)(y - cy), (ushort)(z - cz));
|
||||
byte rocketHead = headIndex < 0 ? Block.Zero : lvl.blocks[headIndex];
|
||||
byte rocketHead = headIndex < 0 ? Block.Invalid : lvl.blocks[headIndex];
|
||||
bool unblocked = !lvl.listUpdateExists.Get(x, y, z) &&
|
||||
(headIndex < 0 || !lvl.listUpdateExists.Get(x - cx, y - cy, z - cz));
|
||||
|
||||
|
@ -48,7 +48,7 @@ namespace MCGalaxy {
|
||||
public void ManualChange(ushort x, ushort y, ushort z, byte action,
|
||||
byte block, byte extBlock, bool checkPlaceDist) {
|
||||
byte old = level.GetTile(x, y, z);
|
||||
if (old == Block.Zero) return;
|
||||
if (old == Block.Invalid) return;
|
||||
if (jailed || !agreed || !canBuild) { RevertBlock(x, y, z); return; }
|
||||
if (level.IsMuseum && Blockchange == null) return;
|
||||
if (action > 1) { Leave("Unknown block action!", true); return; }
|
||||
@ -703,7 +703,7 @@ namespace MCGalaxy {
|
||||
|
||||
Command command = Command.all.Find(cmd);
|
||||
if (command == null) {
|
||||
if (Block.Byte(cmd) != Block.Zero) {
|
||||
if (Block.Byte(cmd) != Block.Invalid) {
|
||||
cmdArgs = cmd.ToLower(); cmd = "mode";
|
||||
command = Command.all.Find("mode");
|
||||
} else {
|
||||
|
@ -73,8 +73,8 @@ namespace MCGalaxy {
|
||||
byte head = level.GetTile(x, y, z);
|
||||
byte feet = level.GetTile(x, (ushort)(y - 1), z);
|
||||
|
||||
return !(Block.Walkthrough(Block.Convert(head)) || head == Block.Zero)
|
||||
&& !(Block.Walkthrough(Block.Convert(feet)) || feet == Block.Zero);
|
||||
return !(Block.Walkthrough(Block.Convert(head)) || head == Block.Invalid)
|
||||
&& !(Block.Walkthrough(Block.Convert(feet)) || feet == Block.Invalid);
|
||||
}
|
||||
static int sessionCounter;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user