Fix /search blocks not including global blocks from console

This commit is contained in:
UnknownShadow200 2018-03-05 10:31:28 +11:00
parent a1c455994e
commit e6e92b7ecf
3 changed files with 13 additions and 14 deletions

View File

@ -496,14 +496,14 @@ namespace MCGalaxy.Commands.CPE {
// Start from opposite ends to avoid overlap.
if (global) {
BlockDefinition[] defs = BlockDefinition.GlobalDefs;
for (int b = Block.CpeCount; b < Block.Invalid; b++) {
BlockID block = Block.FromRaw((BlockRaw)b);
for (BlockID b = Block.CpeCount; b < Block.Invalid; b++) {
BlockID block = Block.FromRaw(b);
if (defs[block] == null) return block;
}
} else {
BlockDefinition[] defs = lvl.CustomBlockDefs;
for (int b = Block.Invalid - 1; b >= Block.CpeCount; b--) {
BlockID block = Block.FromRaw((BlockRaw)b);
for (BlockID b = Block.Invalid - 1; b >= Block.CpeCount; b--) {
BlockID block = Block.FromRaw(b);
if (defs[block] == null) return block;
}
}

View File

@ -61,7 +61,7 @@ namespace MCGalaxy.Commands.Info {
static List<BlockID> BasicBlocks() {
List<BlockID> blocks = new List<BlockID>(Block.CpeCount);
for (BlockID block = 0; block < Block.CpeCount; block++) {
for (BlockID block = Block.Air; block < Block.CpeCount; block++) {
blocks.Add(block);
}
return blocks;

View File

@ -54,17 +54,16 @@ namespace MCGalaxy.Commands.Info {
static void SearchBlocks(Player p, string keyword, string modifier) {
List<BlockID> blocks = new List<BlockID>();
for (BlockID block = 0; block < Block.Count; block++) {
if (!Block.Undefined(block)) blocks.Add(block);
}
BlockDefinition[] defs = Player.IsSuper(p) ? BlockDefinition.GlobalDefs : p.level.CustomBlockDefs;
if (!Player.IsSuper(p)) {
for (int b = Block.CpeCount; b < Block.Count; b++) {
BlockID block = Block.FromRaw((BlockRaw)b);
if (p.level.CustomBlockDefs[block] == null) continue;
blocks.Add(block);
for (int b = 0; b < Block.ExtendedCount; b++) {
BlockID block = (BlockID)b;
if (Block.IsPhysicsType(block)) {
if (!Block.Undefined(block)) blocks.Add(block);
} else {
if (defs[block] != null) blocks.Add(block);
}
}
}
List<string> blockNames = FilterList(blocks, keyword,
b => Block.GetName(p, b), null,