Skip to content

Commit 442456b

Browse files
Show Z min/max in /gb info, use better name than Block.MaxLegalBlockType / Block.MaxCustomBlockType
1 parent ebafc64 commit 442456b

File tree

5 files changed

+20
-21
lines changed

5 files changed

+20
-21
lines changed

fCraft/Commands/CpeCommands.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1414,8 +1414,8 @@ static void CustomBlockInfoHandler(Player p, CommandReader cmd, bool global, Blo
14141414
def.Shape, def.BlockDraw, def.FogDensity);
14151415
p.Message(" &3Fog Red: &a{0}&3, Fog Green: &a{1}&3, Fog Blue: &a{2}",
14161416
def.FogR, def.FogG, def.FogB);
1417-
p.Message(" &3Min X: &a{0}&3, Max X: &a{1}&3, Min Y: &a{2}&3, Max Y: &a{3}",
1418-
def.MinX, def.MaxX, def.MinY, def.MaxY);
1417+
p.Message(" &3Min: (&a{0}&3, &a{1}&3, &a{2}&3), Max: (&a{3}&3, &a{4}&3, &a{5}&3)",
1418+
def.MinX, def.MinY, def.MinZ, def.MaxX, def.MaxY, def.MaxZ);
14191419
}
14201420

14211421
static void CustomBlockListHandler(Player p, CommandReader cmd, bool global, BlockDefinition[] defs) {
@@ -1633,7 +1633,7 @@ static void CustomBlockDefineHandler(Player p, string args, bool global, BlockDe
16331633
default:
16341634
Block block;
16351635
if (Map.GetBlockByName(p.World, args, false, out block)) {
1636-
if (block > Map.MaxCustomBlockType) {
1636+
if (block > Map.MaxCPEBlock) {
16371637
p.Message("&cThe fallback block must be an original block, " +
16381638
"or a block defined in the CustomBlocks extension.");
16391639
break;
@@ -1670,7 +1670,7 @@ static void CustomBlockDuplicateHandler(Player p, CommandReader cmd, bool global
16701670
}
16711671

16721672
BlockDefinition srcDef = GetCustomBlock(global, defs, (byte)srcBlock);
1673-
if (srcDef == null && srcBlock <= Map.MaxCustomBlockType)
1673+
if (srcDef == null && srcBlock <= Map.MaxCPEBlock)
16741674
srcDef = DefaultSet.MakeCustomBlock(srcBlock);
16751675

16761676
if (srcDef == null) {
@@ -1905,7 +1905,7 @@ static void CustomBlockEditHandler(Player p, CommandReader cmd, bool global, Blo
19051905
case "block":
19061906
Block newBlock;
19071907
if (Map.GetBlockByName(p.World, args, false, out newBlock)) {
1908-
if (newBlock > Map.MaxCustomBlockType) {
1908+
if (newBlock > Map.MaxCPEBlock) {
19091909
p.Message("&cThe fallback block must be an original block, " +
19101910
"or a block defined in the CustomBlocks extension.");
19111911
break;

fCraft/Network/Heartbeat.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,13 +103,13 @@ static void SendHeartBeat() {
103103

104104
try {
105105
heartBeatRequest = CreateRequest(data.CreateUri());
106-
} catch (Exception UriFormatException) {
107-
Logger.Log(LogType.Debug, UriFormatException.ToString());
106+
} catch (Exception ex) {
107+
Logger.Log(LogType.Debug, ex.ToString());
108108
return;
109109
}
110110

111111
var state = new HeartbeatRequestState(heartBeatRequest, data);
112-
heartBeatRequest.BeginGetResponse(ResponseCallback, state);
112+
heartBeatRequest.BeginGetResponse(ResponseCallback, state);
113113
}
114114

115115

fCraft/Network/Player.Networking.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ void UpdateHeldBlock() {
378378

379379
// Holding an invalid block
380380
Block held = (Block)id;
381-
if (held > Map.MaxCustomBlockType && World.BlockDefs[id] == null) {
381+
if (held > Map.MaxCPEBlock && World.BlockDefs[id] == null) {
382382
HeldBlock = Block.Stone; return;
383383
}
384384
if (HeldBlock == held) return;
@@ -498,7 +498,7 @@ void ProcessSetBlockPacket() {
498498

499499
// if a player is using InDev or SurvivalTest client, they may try to
500500
// place blocks that are not found in MC Classic. Convert them!
501-
if( type > (byte)Map.MaxCustomBlockType && !Supports(CpeExt.BlockDefinitions)) {
501+
if( type > (byte)Map.MaxCPEBlock && !Supports(CpeExt.BlockDefinitions)) {
502502
type = MapDat.MapBlock( type );
503503
}
504504
Vector3I coords = new Vector3I( x, y, z );
@@ -1168,13 +1168,13 @@ internal bool JoinWorldNow([NotNull] World newWorld, bool doUseWorldSpawn, World
11681168

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

11741174
using (LevelChunkStream dst = new LevelChunkStream(this))
11751175
using (Stream compressor = map.CompressMapHeader(this, dst))
11761176
{
1177-
if (supportsCustomBlocks && supportsBlockDefs) {
1177+
if (supportsBlockDefs) {
11781178
map.CompressMap(dst, compressor);
11791179
} else {
11801180
map.CompressAndConvertMap((byte)maxLegal, dst, compressor);
@@ -1250,15 +1250,15 @@ internal void SendNewEntities(World world) {
12501250
}
12511251

12521252
internal void SendBlockPermissions() {
1253-
int max = supportsCustomBlocks ? (int)Map.MaxCustomBlockType : (int)Map.MaxLegalBlockType;
1253+
int max = supportsCustomBlocks ? (int)Map.MaxCPEBlock : (int)Map.MaxClassicBlock;
12541254
if (supportsBlockDefs) max = byte.MaxValue;
12551255

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

1261-
if (i > (int)Map.MaxCustomBlockType && World.BlockDefs[i] == null) continue;
1261+
if (i > (int)Map.MaxCPEBlock && World.BlockDefs[i] == null) continue;
12621262
Send(Packet.MakeSetBlockPermission(block, build, delete));
12631263
}
12641264
}

fCraft/Player/Player.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2159,11 +2159,11 @@ public bool Supports(CpeExt extension) {
21592159

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

fCraft/World/Map.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,8 @@ public unsafe sealed class Map {
3737
/// <summary> Map volume, in terms of blocks. </summary>
3838
public readonly int Volume;
3939

40-
public const Block MaxLegalBlockType = Block.Obsidian; //Highest block before CPE
41-
42-
public const Block MaxCustomBlockType = Block.StoneBrick;
40+
public const Block MaxClassicBlock = Block.Obsidian; //Highest block before CPE
41+
public const Block MaxCPEBlock = Block.StoneBrick;
4342
internal readonly static Block[] FallbackBlocks = new Block[256];
4443

4544
static void DefineFallbackBlocks()
@@ -82,7 +81,7 @@ public unsafe byte[] GetFallbackMapRanderer() {
8281
fixed (byte* ptr = translatedBlocks) {
8382
for (int i = 0; i < volume; i++) {
8483
byte block = ptr[i];
85-
if (block > (byte)MaxCustomBlockType)
84+
if (block > (byte)MaxCPEBlock)
8685
ptr[i] = fallback[block];
8786
}
8887
}
@@ -929,7 +928,7 @@ unsafe static void MakeFallbacks(byte* fallback, byte maxLegal, World world) {
929928
fallback[i] = defs[i].FallBack;
930929

931930
// Handle CPE defined fallback blocks for custom blocks
932-
if (fallback[i] > (byte)maxLegal) {
931+
if (fallback[i] > maxLegal) {
933932
fallback[i] = (byte)FallbackBlocks[fallback[i]];
934933
}
935934
}

0 commit comments

Comments
 (0)