mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-16 18:57:26 -04:00
Fix duplicate block IDs in blocks list in GUI and in /blocks [rank] all
Also fixes all possible custom block IDs being in /blocks [rank] all, even if the ID wasn't actually defined to be anything
This commit is contained in:
parent
85552e227b
commit
ded6752f90
@ -46,7 +46,7 @@ namespace MCGalaxy.Gui {
|
|||||||
blockPropsChanged[b].ChangedScope = 0;
|
blockPropsChanged[b].ChangedScope = 0;
|
||||||
|
|
||||||
BlockID block = (BlockID)b;
|
BlockID block = (BlockID)b;
|
||||||
if (!BlockExists(block)) continue;
|
if (!Block.ExistsGlobal(block)) continue;
|
||||||
|
|
||||||
string name = Block.GetName(null, block);
|
string name = Block.GetName(null, block);
|
||||||
blk_list.Items.Add(name);
|
blk_list.Items.Add(name);
|
||||||
@ -58,12 +58,6 @@ namespace MCGalaxy.Gui {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BlockExists(BlockID b) {
|
|
||||||
if (b < Block.Count) return !Block.Undefined(b);
|
|
||||||
BlockRaw raw = (BlockRaw)b;
|
|
||||||
return BlockDefinition.GlobalDefs[raw] != null;
|
|
||||||
}
|
|
||||||
|
|
||||||
void SaveBlocks() {
|
void SaveBlocks() {
|
||||||
if (!BlocksChanged()) { LoadBlocks(); return; }
|
if (!BlocksChanged()) { LoadBlocks(); return; }
|
||||||
|
|
||||||
|
@ -25,6 +25,14 @@ namespace MCGalaxy {
|
|||||||
internal static string[] coreNames = new string[Block.Count];
|
internal static string[] coreNames = new string[Block.Count];
|
||||||
public static bool Undefined(BlockID block) { return IsPhysicsType(block) && coreNames[block].CaselessEq("unknown"); }
|
public static bool Undefined(BlockID block) { return IsPhysicsType(block) && coreNames[block].CaselessEq("unknown"); }
|
||||||
|
|
||||||
|
public static bool ExistsGlobal(BlockID b) {
|
||||||
|
if (b < Block.Count) return !Undefined(b);
|
||||||
|
if (b >= Block.Extended && b < Block.Extended + Block.CpeCount) return false;
|
||||||
|
|
||||||
|
BlockRaw raw = (BlockRaw)b;
|
||||||
|
return BlockDefinition.GlobalDefs[raw] != null;
|
||||||
|
}
|
||||||
|
|
||||||
public static byte Byte(string type) {
|
public static byte Byte(string type) {
|
||||||
byte block;
|
byte block;
|
||||||
if (byte.TryParse(type, out block) && block < CpeCount)
|
if (byte.TryParse(type, out block) && block < CpeCount)
|
||||||
|
@ -68,7 +68,7 @@ namespace MCGalaxy.Commands.Info {
|
|||||||
static List<BlockID> ComplexBlocks() {
|
static List<BlockID> ComplexBlocks() {
|
||||||
List<BlockID> blocks = new List<BlockID>(Block.Count);
|
List<BlockID> blocks = new List<BlockID>(Block.Count);
|
||||||
for (BlockID block = Block.CpeCount; block < Block.Count; block++) {
|
for (BlockID block = Block.CpeCount; block < Block.Count; block++) {
|
||||||
if (!Block.Undefined(block)) blocks.Add(block);
|
if (Block.ExistsGlobal(block)) blocks.Add(block);
|
||||||
}
|
}
|
||||||
return blocks;
|
return blocks;
|
||||||
}
|
}
|
||||||
@ -77,7 +77,7 @@ namespace MCGalaxy.Commands.Info {
|
|||||||
List<BlockID> blocks = new List<BlockID>(Block.Count);
|
List<BlockID> blocks = new List<BlockID>(Block.Count);
|
||||||
foreach (BlockPerms perms in BlockPerms.List) {
|
foreach (BlockPerms perms in BlockPerms.List) {
|
||||||
if (!BlockPerms.UsableBy(perm, perms.ID)) continue;
|
if (!BlockPerms.UsableBy(perm, perms.ID)) continue;
|
||||||
if (Block.Undefined(perms.ID)) continue;
|
if (!Block.ExistsGlobal(perms.ID)) continue;
|
||||||
blocks.Add(perms.ID);
|
blocks.Add(perms.ID);
|
||||||
}
|
}
|
||||||
return blocks;
|
return blocks;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user