mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-24 05:03:34 -04:00
Fix manual place and map send for blocks > 255
This commit is contained in:
parent
9f7913081e
commit
eb9c19ca93
@ -242,20 +242,18 @@ 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 || def.BlockID > maxRaw) continue;
|
if (def == null || def.BlockID > pl.MaxRawBlock) continue;
|
||||||
pl.Send(def.MakeDefinePacket(pl));
|
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.BlockID > maxRaw) continue;
|
if (def == null || def.BlockID > pl.MaxRawBlock) continue;
|
||||||
if (def.InventoryOrder >= 0) {
|
if (def.InventoryOrder >= 0) {
|
||||||
pl.Send(Packet.SetInventoryOrder(def, pl.hasExtBlocks));
|
pl.Send(Packet.SetInventoryOrder(def, pl.hasExtBlocks));
|
||||||
}
|
}
|
||||||
|
@ -264,22 +264,23 @@ namespace MCGalaxy {
|
|||||||
NetUtils.WriteU16(y, buffer, 3);
|
NetUtils.WriteU16(y, buffer, 3);
|
||||||
NetUtils.WriteU16(z, buffer, 5);
|
NetUtils.WriteU16(z, buffer, 5);
|
||||||
|
|
||||||
|
BlockID raw;
|
||||||
if (block >= Block.Extended) {
|
if (block >= Block.Extended) {
|
||||||
block = hasBlockDefs ? Block.ToRaw(block) : level.RawFallback(block);
|
raw = Block.ToRaw(block);
|
||||||
} else {
|
} else {
|
||||||
block = Block.Convert(block);
|
raw = Block.Convert(block);
|
||||||
// Invalid block physics won't have converted form
|
if (raw >= Block.CpeCount) raw = Block.Orange;
|
||||||
if (block >= Block.CpeCount) block = Block.Orange;
|
|
||||||
}
|
}
|
||||||
|
if (raw > MaxRawBlock) raw = level.RawFallback(block);
|
||||||
|
|
||||||
// Custom block replaced a core block
|
// Custom block replaced a core block
|
||||||
if (!hasBlockDefs && block < Block.CpeCount) {
|
if (!hasBlockDefs && raw < Block.CpeCount) {
|
||||||
BlockDefinition def = level.CustomBlockDefs[block];
|
BlockDefinition def = level.CustomBlockDefs[raw];
|
||||||
if (def != null) block = def.FallBack;
|
if (def != null) raw = def.FallBack;
|
||||||
}
|
}
|
||||||
|
if (!hasCustomBlocks) raw = Block.ConvertCPE((BlockRaw)raw);
|
||||||
|
|
||||||
if (!hasCustomBlocks) block = Block.ConvertCPE((BlockRaw)block); // doesn't support CPE blocks
|
NetUtils.WriteBlock(raw, buffer, 7, hasExtBlocks);
|
||||||
NetUtils.WriteBlock(block, buffer, 7, hasExtBlocks);
|
|
||||||
Socket.SendLowPriority(buffer);
|
Socket.SendLowPriority(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,13 +97,10 @@ namespace MCGalaxy.Network {
|
|||||||
if (conv[b] > Block.CpeCount) conv[b] = Block.Orange;
|
if (conv[b] > Block.CpeCount) conv[b] = Block.Orange;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Convert custom blocks (that overwrote core blocks) to their fallbacks
|
||||||
|
#if !TEN_BIT_BLOCKS
|
||||||
if (!p.hasBlockDefs) {
|
if (!p.hasBlockDefs) {
|
||||||
// Convert custom blocks (that overwrote core blocks) to their fallbacks
|
#endif
|
||||||
for (int b = 0; b < Block.CpeCount; b++) {
|
|
||||||
BlockDefinition def = p.level.CustomBlockDefs[b];
|
|
||||||
if (def != null) conv[b] = def.FallBack;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int b = 0; b < Block.Count; b++) {
|
for (int b = 0; b < Block.Count; b++) {
|
||||||
BlockID block = Block.FromRaw((byte)b);
|
BlockID block = Block.FromRaw((byte)b);
|
||||||
BlockDefinition def = p.level.CustomBlockDefs[block];
|
BlockDefinition def = p.level.CustomBlockDefs[block];
|
||||||
@ -114,6 +111,16 @@ namespace MCGalaxy.Network {
|
|||||||
convExt[b] = def.FallBack;
|
convExt[b] = def.FallBack;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#if !TEN_BIT_BLOCKS
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Convert custom blocks (that overwrote core blocks) to their fallbacks
|
||||||
|
if (!p.hasBlockDefs) {
|
||||||
|
for (int b = 0; b < Block.CpeCount; b++) {
|
||||||
|
BlockDefinition def = p.level.CustomBlockDefs[b];
|
||||||
|
if (def != null) conv[b] = def.FallBack;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Convert CPE blocks to their fallbacks
|
// Convert CPE blocks to their fallbacks
|
||||||
@ -157,9 +164,39 @@ namespace MCGalaxy.Network {
|
|||||||
gs.Write(buffer, 0, bufferSize); bIndex = 0;
|
gs.Write(buffer, 0, bufferSize); bIndex = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else
|
} else if (p.hasBlockDefs) {
|
||||||
#endif
|
for (int i = 0; i < blocks.Length; ++i) {
|
||||||
|
byte block = blocks[i];
|
||||||
|
if (block == Block.custom_block) {
|
||||||
|
buffer[bIndex] = lvl.GetExtTile(i);
|
||||||
|
} else if (block == Block.custom_block_2 || block == Block.custom_block_3) {
|
||||||
|
buffer[bIndex] = convExt[lvl.GetExtTile(i)];
|
||||||
|
} else {
|
||||||
|
buffer[bIndex] = conv[block];
|
||||||
|
}
|
||||||
|
|
||||||
|
bIndex++;
|
||||||
|
if (bIndex == bufferSize) {
|
||||||
|
dst.position = i;
|
||||||
|
gs.Write(buffer, 0, bufferSize); bIndex = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (int i = 0; i < blocks.Length; ++i) {
|
||||||
|
byte block = blocks[i];
|
||||||
|
if (block == Block.custom_block || block == Block.custom_block_2 || block == Block.custom_block_3) {
|
||||||
|
block = convExt[lvl.GetExtTile(i)];
|
||||||
|
}
|
||||||
|
buffer[bIndex] = conv[block];
|
||||||
|
|
||||||
|
bIndex++;
|
||||||
|
if (bIndex == bufferSize) {
|
||||||
|
dst.position = i;
|
||||||
|
gs.Write(buffer, 0, bufferSize); bIndex = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#else
|
||||||
if (p.hasBlockDefs) {
|
if (p.hasBlockDefs) {
|
||||||
for (int i = 0; i < blocks.Length; ++i) {
|
for (int i = 0; i < blocks.Length; ++i) {
|
||||||
byte block = blocks[i];
|
byte block = blocks[i];
|
||||||
@ -190,6 +227,9 @@ namespace MCGalaxy.Network {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
if (bIndex > 0) gs.Write(buffer, 0, bIndex);
|
if (bIndex > 0) gs.Write(buffer, 0, bIndex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -73,6 +73,7 @@ namespace MCGalaxy {
|
|||||||
if (ext.ExtName == CpeExt.CustomBlocks) {
|
if (ext.ExtName == CpeExt.CustomBlocks) {
|
||||||
if (version == 1) Send(Packet.CustomBlockSupportLevel(1));
|
if (version == 1) Send(Packet.CustomBlockSupportLevel(1));
|
||||||
hasCustomBlocks = true;
|
hasCustomBlocks = true;
|
||||||
|
if (MaxRawBlock < Block.CpeMaxBlock) MaxRawBlock = Block.CpeMaxBlock;
|
||||||
} else if (ext.ExtName == CpeExt.ChangeModel) {
|
} else if (ext.ExtName == CpeExt.ChangeModel) {
|
||||||
hasChangeModel = true;
|
hasChangeModel = true;
|
||||||
} else if (ext.ExtName == CpeExt.FullCP437) {
|
} else if (ext.ExtName == CpeExt.FullCP437) {
|
||||||
@ -81,6 +82,7 @@ namespace MCGalaxy {
|
|||||||
hasExtList = true;
|
hasExtList = true;
|
||||||
} else if (ext.ExtName == CpeExt.BlockDefinitions) {
|
} else if (ext.ExtName == CpeExt.BlockDefinitions) {
|
||||||
hasBlockDefs = true;
|
hasBlockDefs = true;
|
||||||
|
if (MaxRawBlock < 255) MaxRawBlock = 255;
|
||||||
} else if (ext.ExtName == CpeExt.TextColors) {
|
} else if (ext.ExtName == CpeExt.TextColors) {
|
||||||
hasTextColors = true;
|
hasTextColors = true;
|
||||||
for (int i = 0; i < Colors.List.Length; i++) {
|
for (int i = 0; i < Colors.List.Length; i++) {
|
||||||
@ -97,6 +99,7 @@ namespace MCGalaxy {
|
|||||||
#if TEN_BIT_BLOCKS
|
#if TEN_BIT_BLOCKS
|
||||||
else if (ext.ExtName == CpeExt.ExtBlocks) {
|
else if (ext.ExtName == CpeExt.ExtBlocks) {
|
||||||
hasExtBlocks = true;
|
hasExtBlocks = true;
|
||||||
|
if (MaxRawBlock < 767) MaxRawBlock = 767;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -55,6 +55,7 @@ namespace MCGalaxy {
|
|||||||
internal bool nonPlayerClient = false;
|
internal bool nonPlayerClient = false;
|
||||||
public INetworkSocket Socket;
|
public INetworkSocket Socket;
|
||||||
public PingList Ping = new PingList();
|
public PingList Ping = new PingList();
|
||||||
|
public BlockID MaxRawBlock = Block.OriginalMaxBlock;
|
||||||
|
|
||||||
public DateTime LastAction, AFKCooldown;
|
public DateTime LastAction, AFKCooldown;
|
||||||
public bool IsAfk, AutoAfk;
|
public bool IsAfk, AutoAfk;
|
||||||
|
@ -58,13 +58,6 @@ 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