mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-16 02:37:41 -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;
|
||||
|
||||
BlockID block = (BlockID)b;
|
||||
if (!BlockExists(block)) continue;
|
||||
if (!Block.ExistsGlobal(block)) continue;
|
||||
|
||||
string name = Block.GetName(null, block);
|
||||
blk_list.Items.Add(name);
|
||||
@ -57,12 +57,6 @@ namespace MCGalaxy.Gui {
|
||||
blk_list.SelectedIndex = 0;
|
||||
}
|
||||
}
|
||||
|
||||
bool BlockExists(BlockID b) {
|
||||
if (b < Block.Count) return !Block.Undefined(b);
|
||||
BlockRaw raw = (BlockRaw)b;
|
||||
return BlockDefinition.GlobalDefs[raw] != null;
|
||||
}
|
||||
|
||||
void SaveBlocks() {
|
||||
if (!BlocksChanged()) { LoadBlocks(); return; }
|
||||
|
@ -25,6 +25,14 @@ namespace MCGalaxy {
|
||||
internal static string[] coreNames = new string[Block.Count];
|
||||
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) {
|
||||
byte block;
|
||||
if (byte.TryParse(type, out block) && block < CpeCount)
|
||||
|
@ -123,7 +123,7 @@ namespace MCGalaxy.Blocks.Physics {
|
||||
BlockID block = C.Block;
|
||||
LiquidPhysics.PhysWater(lvl, (ushort)(x + 1), y, z, block);
|
||||
LiquidPhysics.PhysWater(lvl, (ushort)(x - 1), y, z, block);
|
||||
LiquidPhysics.PhysWater(lvl, x, y, (ushort)(z + 1),block);
|
||||
LiquidPhysics.PhysWater(lvl, x, y, (ushort)(z + 1), block);
|
||||
LiquidPhysics.PhysWater(lvl, x, y, (ushort)(z - 1), block);
|
||||
if (!C.Data.HasWait) C.Data.Data = PhysicsArgs.RemoveFromChecks;
|
||||
break;
|
||||
|
@ -68,7 +68,7 @@ namespace MCGalaxy.Commands.Info {
|
||||
static List<BlockID> ComplexBlocks() {
|
||||
List<BlockID> blocks = new List<BlockID>(Block.Count);
|
||||
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;
|
||||
}
|
||||
@ -77,7 +77,7 @@ namespace MCGalaxy.Commands.Info {
|
||||
List<BlockID> blocks = new List<BlockID>(Block.Count);
|
||||
foreach (BlockPerms perms in BlockPerms.List) {
|
||||
if (!BlockPerms.UsableBy(perm, perms.ID)) continue;
|
||||
if (Block.Undefined(perms.ID)) continue;
|
||||
if (!Block.ExistsGlobal(perms.ID)) continue;
|
||||
blocks.Add(perms.ID);
|
||||
}
|
||||
return blocks;
|
||||
|
Loading…
x
Reference in New Issue
Block a user