Skip to content
Permalink
Browse files

Show Z min/max in /gb info, use better name than Block.MaxLegalBlockT…

…ype / Block.MaxCustomBlockType
  • Loading branch information...
UnknownShadow200 committed Nov 28, 2018
1 parent ebafc64 commit 442456b4e418d574410b8e600202b992ee1d44eb
@@ -1414,8 +1414,8 @@ static class CpeCommands {
def.Shape, def.BlockDraw, def.FogDensity);
p.Message(" &3Fog Red: &a{0}&3, Fog Green: &a{1}&3, Fog Blue: &a{2}",
def.FogR, def.FogG, def.FogB);
p.Message(" &3Min X: &a{0}&3, Max X: &a{1}&3, Min Y: &a{2}&3, Max Y: &a{3}",
def.MinX, def.MaxX, def.MinY, def.MaxY);
p.Message(" &3Min: (&a{0}&3, &a{1}&3, &a{2}&3), Max: (&a{3}&3, &a{4}&3, &a{5}&3)",
def.MinX, def.MinY, def.MinZ, def.MaxX, def.MaxY, def.MaxZ);
}

static void CustomBlockListHandler(Player p, CommandReader cmd, bool global, BlockDefinition[] defs) {
@@ -1633,7 +1633,7 @@ static class CpeCommands {
default:
Block block;
if (Map.GetBlockByName(p.World, args, false, out block)) {
if (block > Map.MaxCustomBlockType) {
if (block > Map.MaxCPEBlock) {
p.Message("&cThe fallback block must be an original block, " +
"or a block defined in the CustomBlocks extension.");
break;
@@ -1670,7 +1670,7 @@ static class CpeCommands {
}

BlockDefinition srcDef = GetCustomBlock(global, defs, (byte)srcBlock);
if (srcDef == null && srcBlock <= Map.MaxCustomBlockType)
if (srcDef == null && srcBlock <= Map.MaxCPEBlock)
srcDef = DefaultSet.MakeCustomBlock(srcBlock);

if (srcDef == null) {
@@ -1905,7 +1905,7 @@ static class CpeCommands {
case "block":
Block newBlock;
if (Map.GetBlockByName(p.World, args, false, out newBlock)) {
if (newBlock > Map.MaxCustomBlockType) {
if (newBlock > Map.MaxCPEBlock) {
p.Message("&cThe fallback block must be an original block, " +
"or a block defined in the CustomBlocks extension.");
break;
@@ -103,13 +103,13 @@ static void Beat([NotNull] SchedulerTask scheduledTask)

try {
heartBeatRequest = CreateRequest(data.CreateUri());
} catch (Exception UriFormatException) {
Logger.Log(LogType.Debug, UriFormatException.ToString());
} catch (Exception ex) {
Logger.Log(LogType.Debug, ex.ToString());
return;
}

var state = new HeartbeatRequestState(heartBeatRequest, data);
heartBeatRequest.BeginGetResponse(ResponseCallback, state);
heartBeatRequest.BeginGetResponse(ResponseCallback, state);
}


@@ -378,7 +378,7 @@ public sealed partial class Player {

// Holding an invalid block
Block held = (Block)id;
if (held > Map.MaxCustomBlockType && World.BlockDefs[id] == null) {
if (held > Map.MaxCPEBlock && World.BlockDefs[id] == null) {
HeldBlock = Block.Stone; return;
}
if (HeldBlock == held) return;
@@ -498,7 +498,7 @@ public sealed partial class Player {

// if a player is using InDev or SurvivalTest client, they may try to
// place blocks that are not found in MC Classic. Convert them!
if( type > (byte)Map.MaxCustomBlockType && !Supports(CpeExt.BlockDefinitions)) {
if( type > (byte)Map.MaxCPEBlock && !Supports(CpeExt.BlockDefinitions)) {
type = MapDat.MapBlock( type );
}
Vector3I coords = new Vector3I( x, y, z );
@@ -1168,13 +1168,13 @@ bool LoginSequence()

void WriteWorldData(Map map) {
// Transfer compressed map copy
Block maxLegal = supportsCustomBlocks ? Map.MaxCustomBlockType : Map.MaxLegalBlockType;
Block maxLegal = supportsCustomBlocks ? Map.MaxCPEBlock : Map.MaxClassicBlock;
Logger.Log(LogType.Debug, "Player.JoinWorldNow: Sending compressed map to {0}.", Name);

using (LevelChunkStream dst = new LevelChunkStream(this))
using (Stream compressor = map.CompressMapHeader(this, dst))
{
if (supportsCustomBlocks && supportsBlockDefs) {
if (supportsBlockDefs) {
map.CompressMap(dst, compressor);
} else {
map.CompressAndConvertMap((byte)maxLegal, dst, compressor);
@@ -1250,15 +1250,15 @@ bool LoginSequence()
}

internal void SendBlockPermissions() {
int max = supportsCustomBlocks ? (int)Map.MaxCustomBlockType : (int)Map.MaxLegalBlockType;
int max = supportsCustomBlocks ? (int)Map.MaxCPEBlock : (int)Map.MaxClassicBlock;
if (supportsBlockDefs) max = byte.MaxValue;

for (int i = (int)Block.Air; i <= max; i++) {
Block block = (Block)i;
bool build = World.Buildable && CheckPlacePerm(block);
bool delete = World.Deletable && CheckDeletePerm(block);

if (i > (int)Map.MaxCustomBlockType && World.BlockDefs[i] == null) continue;
if (i > (int)Map.MaxCPEBlock && World.BlockDefs[i] == null) continue;
Send(Packet.MakeSetBlockPermission(block, build, delete));
}
}
@@ -2159,11 +2159,11 @@ public void ResetIdleTimer()

// For non-extended players, use appropriate substitution
internal void CheckBlock(ref byte block) {
if (block > (byte) Map.MaxCustomBlockType && !supportsBlockDefs) {
if (block > (byte) Map.MaxCPEBlock && !supportsBlockDefs) {
BlockDefinition def = World.BlockDefs[block];
block = def == null ? (byte)Map.FallbackBlocks[block] : def.FallBack;
}
if (block > (byte) Map.MaxLegalBlockType && !supportsCustomBlocks)
if (block > (byte) Map.MaxClassicBlock && !supportsCustomBlocks)
block = (byte) Map.FallbackBlocks[block];
}

@@ -37,9 +37,8 @@ public unsafe sealed class Map {
/// <summary> Map volume, in terms of blocks. </summary>
public readonly int Volume;

public const Block MaxLegalBlockType = Block.Obsidian; //Highest block before CPE

public const Block MaxCustomBlockType = Block.StoneBrick;
public const Block MaxClassicBlock = Block.Obsidian; //Highest block before CPE
public const Block MaxCPEBlock = Block.StoneBrick;
internal readonly static Block[] FallbackBlocks = new Block[256];

static void DefineFallbackBlocks()
@@ -82,7 +81,7 @@ static void DefineFallbackBlocks()
fixed (byte* ptr = translatedBlocks) {
for (int i = 0; i < volume; i++) {
byte block = ptr[i];
if (block > (byte)MaxCustomBlockType)
if (block > (byte)MaxCPEBlock)
ptr[i] = fallback[block];
}
}
@@ -929,7 +928,7 @@ public void ClearUpdateQueue()
fallback[i] = defs[i].FallBack;

// Handle CPE defined fallback blocks for custom blocks
if (fallback[i] > (byte)maxLegal) {
if (fallback[i] > maxLegal) {
fallback[i] = (byte)FallbackBlocks[fallback[i]];
}
}

0 comments on commit 442456b

Please sign in to comment.
You can’t perform that action at this time.