mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-24 05:03:34 -04:00
MayHaveCustomBlocks property -> MightHaveCustomBlocks function
since really only trivial code should be in a getter, and MightHaveCustomBlocks can potentially be quite expensive
This commit is contained in:
parent
485be4a3af
commit
67d2ecba74
@ -341,7 +341,7 @@ namespace MCGalaxy {
|
||||
if (pl.hasBlockDefs) continue;
|
||||
|
||||
// if custom block is replacing core block, need to always reload for fallback
|
||||
if (block >= Block.CpeCount && !pl.level.MayHaveCustomBlocks) continue;
|
||||
if (block >= Block.CpeCount && !pl.level.MightHaveCustomBlocks()) continue;
|
||||
PlayerActions.ReloadMap(pl);
|
||||
}
|
||||
}
|
||||
|
@ -33,8 +33,8 @@ namespace MCGalaxy {
|
||||
public byte[][] CustomBlocks;
|
||||
public int ChunksX, ChunksY, ChunksZ;
|
||||
|
||||
public bool MayHaveCustomBlocks {
|
||||
get {
|
||||
/// <summary> Relatively quick guess at whether this map might use custom blocks. </summary>
|
||||
public bool MightHaveCustomBlocks() {
|
||||
byte[][] customBlocks = CustomBlocks;
|
||||
if (customBlocks == null) return false;
|
||||
|
||||
@ -43,7 +43,6 @@ namespace MCGalaxy {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary> Gets the block at the given coordinates. </summary>
|
||||
@ -390,7 +389,7 @@ namespace MCGalaxy {
|
||||
AddCheck(b, false, data);
|
||||
}
|
||||
|
||||
// Save bandwidth sending identical looking blocks, like air/op_air changes.
|
||||
// Save bandwidth not sending identical looking blocks, like air/op_air changes.
|
||||
return !Block.VisuallyEquals(old, block);
|
||||
} catch {
|
||||
return false;
|
||||
|
@ -251,10 +251,10 @@ namespace MCGalaxy {
|
||||
using (LevelChunkStream dst = new LevelChunkStream(this))
|
||||
using (Stream stream = LevelChunkStream.CompressMapHeader(this, volume, dst))
|
||||
{
|
||||
if (!level.MayHaveCustomBlocks) {
|
||||
LevelChunkStream.CompressMapSimple(this, stream, dst);
|
||||
} else {
|
||||
if (level.MightHaveCustomBlocks()) {
|
||||
LevelChunkStream.CompressMap(this, stream, dst);
|
||||
} else {
|
||||
LevelChunkStream.CompressMapSimple(this, stream, dst);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -84,14 +84,16 @@ namespace MCGalaxy.Network {
|
||||
}
|
||||
|
||||
|
||||
internal static Stream CompressMapHeader(Player player, int volume, LevelChunkStream dst) {
|
||||
public static Stream CompressMapHeader(Player p, int volume, LevelChunkStream dst) {
|
||||
Stream stream = null;
|
||||
if (player.Supports(CpeExt.FastMap)) {
|
||||
if (p.Supports(CpeExt.FastMap)) {
|
||||
stream = new DeflateStream(dst, CompressionMode.Compress, true);
|
||||
} else {
|
||||
stream = new GZipStream(dst, CompressionMode.Compress, true);
|
||||
byte[] buffer = new byte[4]; NetUtils.WriteI32(volume, buffer, 0);
|
||||
stream.Write(buffer, 0, sizeof(int));
|
||||
byte[] buffer = new byte[4];
|
||||
|
||||
NetUtils.WriteI32(volume, buffer, 0);
|
||||
stream.Write(buffer, 0, 4);
|
||||
}
|
||||
return stream;
|
||||
}
|
||||
@ -117,7 +119,7 @@ namespace MCGalaxy.Network {
|
||||
bIndex++;
|
||||
|
||||
if (bIndex == bufferSize) {
|
||||
// '0' to indicate classic blocks
|
||||
// '0' to indicate this chunk has lower 8 bits of block ids
|
||||
dst.chunkValue = p.hasExtBlocks ? (byte)0 : (byte)(i * progScale);
|
||||
stream.Write(buffer, 0, bufferSize); bIndex = 0;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user