mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-23 12:42:22 -04:00
Don't sent blockdefs > client max supported block
This commit is contained in:
parent
b3e49e0010
commit
9f7913081e
@ -178,7 +178,7 @@ namespace MCGalaxy {
|
|||||||
Player[] players = PlayerInfo.Online.Items;
|
Player[] players = PlayerInfo.Online.Items;
|
||||||
foreach (Player pl in players) {
|
foreach (Player pl in players) {
|
||||||
if (!global && pl.level != level) continue;
|
if (!global && pl.level != level) continue;
|
||||||
if (!pl.hasBlockDefs) continue;
|
if (!pl.hasBlockDefs || def.BlockID > pl.MaxRawBlock) continue;
|
||||||
if (global && pl.level.CustomBlockDefs[block] != GlobalDefs[block]) continue;
|
if (global && pl.level.CustomBlockDefs[block] != GlobalDefs[block]) continue;
|
||||||
|
|
||||||
pl.Send(def.MakeDefinePacket(pl));
|
pl.Send(def.MakeDefinePacket(pl));
|
||||||
@ -199,7 +199,7 @@ namespace MCGalaxy {
|
|||||||
Player[] players = PlayerInfo.Online.Items;
|
Player[] players = PlayerInfo.Online.Items;
|
||||||
foreach (Player pl in players) {
|
foreach (Player pl in players) {
|
||||||
if (!global && pl.level != level) continue;
|
if (!global && pl.level != level) continue;
|
||||||
if (!pl.hasBlockDefs) continue;
|
if (!pl.hasBlockDefs || def.BlockID > pl.MaxRawBlock) continue;
|
||||||
if (global && pl.level.CustomBlockDefs[block] != null) continue;
|
if (global && pl.level.CustomBlockDefs[block] != null) continue;
|
||||||
|
|
||||||
pl.Send(Packet.UndefineBlock(def, pl.hasExtBlocks));
|
pl.Send(Packet.UndefineBlock(def, pl.hasExtBlocks));
|
||||||
@ -216,7 +216,7 @@ namespace MCGalaxy {
|
|||||||
if (!global && pl.level != level) continue;
|
if (!global && pl.level != level) continue;
|
||||||
if (global && pl.level.CustomBlockDefs[block] != GlobalDefs[block]) continue;
|
if (global && pl.level.CustomBlockDefs[block] != GlobalDefs[block]) continue;
|
||||||
|
|
||||||
if (!pl.Supports(CpeExt.InventoryOrder)) continue;
|
if (!pl.Supports(CpeExt.InventoryOrder) || def.BlockID > pl.MaxRawBlock) continue;
|
||||||
pl.Send(Packet.SetInventoryOrder(def, pl.hasExtBlocks));
|
pl.Send(Packet.SetInventoryOrder(def, pl.hasExtBlocks));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -242,17 +242,21 @@ namespace MCGalaxy {
|
|||||||
|
|
||||||
internal static void SendLevelCustomBlocks(Player pl) {
|
internal static void SendLevelCustomBlocks(Player pl) {
|
||||||
BlockDefinition[] defs = pl.level.CustomBlockDefs;
|
BlockDefinition[] defs = pl.level.CustomBlockDefs;
|
||||||
|
BlockID_ maxRaw = pl.MaxRawBlock;
|
||||||
for (int i = 0; i < defs.Length; i++) {
|
for (int i = 0; i < defs.Length; i++) {
|
||||||
BlockDefinition def = defs[i];
|
BlockDefinition def = defs[i];
|
||||||
if (def != null) pl.Send(def.MakeDefinePacket(pl));
|
if (def == null || def.BlockID > maxRaw) continue;
|
||||||
|
pl.Send(def.MakeDefinePacket(pl));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static void SendLevelInventoryOrder(Player pl) {
|
internal static void SendLevelInventoryOrder(Player pl) {
|
||||||
BlockDefinition[] defs = pl.level.CustomBlockDefs;
|
BlockDefinition[] defs = pl.level.CustomBlockDefs;
|
||||||
|
BlockID_ maxRaw = pl.MaxRawBlock;
|
||||||
for (int b = 0; b < defs.Length; b++) {
|
for (int b = 0; b < defs.Length; b++) {
|
||||||
BlockDefinition def = defs[b];
|
BlockDefinition def = defs[b];
|
||||||
if (def != null && def.InventoryOrder >= 0) {
|
if (def == null || def.BlockID > maxRaw) continue;
|
||||||
|
if (def.InventoryOrder >= 0) {
|
||||||
pl.Send(Packet.SetInventoryOrder(def, pl.hasExtBlocks));
|
pl.Send(Packet.SetInventoryOrder(def, pl.hasExtBlocks));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -234,7 +234,8 @@ namespace MCGalaxy {
|
|||||||
BlockDefinition[] defs = oldLevel.CustomBlockDefs;
|
BlockDefinition[] defs = oldLevel.CustomBlockDefs;
|
||||||
for (int i = 0; i < defs.Length; i++) {
|
for (int i = 0; i < defs.Length; i++) {
|
||||||
BlockDefinition def = defs[i];
|
BlockDefinition def = defs[i];
|
||||||
if (def == BlockDefinition.GlobalDefs[i]) continue;
|
if (def == BlockDefinition.GlobalDefs[i]) continue;
|
||||||
|
if (def.BlockID > MaxRawBlock) continue;
|
||||||
Send(Packet.UndefineBlock(def, hasExtBlocks));
|
Send(Packet.UndefineBlock(def, hasExtBlocks));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -278,7 +279,7 @@ namespace MCGalaxy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!hasCustomBlocks) block = Block.ConvertCPE((BlockRaw)block); // doesn't support CPE blocks
|
if (!hasCustomBlocks) block = Block.ConvertCPE((BlockRaw)block); // doesn't support CPE blocks
|
||||||
NetUtils.WriteBlock(block, buffer, 7, hasExtBlocks);
|
NetUtils.WriteBlock(block, buffer, 7, hasExtBlocks);
|
||||||
Socket.SendLowPriority(buffer);
|
Socket.SendLowPriority(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -158,14 +158,8 @@ namespace MCGalaxy {
|
|||||||
SendAllBlockPermissions();
|
SendAllBlockPermissions();
|
||||||
}
|
}
|
||||||
|
|
||||||
int NumBlockPermissions() {
|
|
||||||
if (hasExtBlocks) return Block.MaxRaw + 1;
|
|
||||||
if (hasBlockDefs) return Block.Count;
|
|
||||||
return hasCustomBlocks ? Block.CpeCount : Block.OriginalCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
void SendAllBlockPermissions() {
|
void SendAllBlockPermissions() {
|
||||||
int count = NumBlockPermissions();
|
int count = MaxRawBlock + 1;
|
||||||
int size = hasExtBlocks ? 5 : 4;
|
int size = hasExtBlocks ? 5 : 4;
|
||||||
byte[] bulk = new byte[count * size];
|
byte[] bulk = new byte[count * size];
|
||||||
|
|
||||||
|
@ -58,6 +58,13 @@ namespace MCGalaxy {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public BlockID MaxRawBlock { get {
|
||||||
|
if (hasExtBlocks) return 767;
|
||||||
|
if (hasBlockDefs) return 255;
|
||||||
|
return hasCustomBlocks ? Block.CpeMaxBlock : Block.OriginalMaxBlock;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
internal void Connect(Socket s) {
|
internal void Connect(Socket s) {
|
||||||
try {
|
try {
|
||||||
Socket = new TcpSocket(this, s);
|
Socket = new TcpSocket(this, s);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user