Skip to content

Commit 00f3b17

Browse files
committed
fix jungle trees; fix cave mode for anvil; fix nether mode for anvil
1 parent 8f8ce01 commit 00f3b17

7 files changed

+125
-70
lines changed

colors.cpp

+4-3
Original file line numberDiff line numberDiff line change
@@ -156,11 +156,12 @@ void loadColors()
156156
SETCOLOR(122, 20,18,29,255);
157157
SETCOLORNOISE(123, 70,43,26,255, 2);
158158
SETCOLORNOISE(124, 119,89,55,255, 7);
159+
SETCOLORNOISE(PINELEAVES, 44,84,44,160, 20); // Pine leaves
160+
SETCOLORNOISE(BIRCHLEAVES, 85,124,60,170, 11); // Birch leaves
161+
SETCOLORNOISE(JUNGLELEAVES, 44,135,50,175, 11); // Birch leaves
159162
SETCOLORNOISE(SANDSTEP, 218, 210, 158, 254, 7); // Not fully opaque to prevent culling on this one
160163
SETCOLORNOISE(WOODSTEP, 157,128,79,254, 11); // Not fully opaque to prevent culling on this one
161164
SETCOLORNOISE(COBBLESTEP, 115,115,115,254, 26); // Not fully opaque to prevent culling on this one
162-
SETCOLORNOISE(PINELEAVES, 44,84,44,160, 20); // Pine leaves
163-
SETCOLORNOISE(BIRCHLEAVES, 85,124,60,170, 11); // Birch leaves
164165
SETCOLOR(238, 70,50,32, 255); // Pine trunk
165166
SETCOLORNOISE(239, 206,206,201, 255, 5); // Birch trunk
166167
SETCOLOR(240, 244,137,54, 255); // Dyed wool
@@ -245,7 +246,7 @@ bool dumpColorsToFile(const char *file)
245246
"# If you want to set alpha of grass to <255, use -blendall or you won't get what you expect.\n"
246247
"# Noise is supposed to look normal using -noise 10\n"
247248
"# Dyed wool ranges from ID 240 to 254, it's orange to black in the order described at http://www.minecraftwiki.net/wiki/Data_values#Wool\n"
248-
"# half-steps of sand, wood and cobblestone are 233 to 235\n\n");
249+
"# half-steps of sand, wood and cobblestone are 232 to 236\n\n");
249250
for (size_t i = 1; i < 255; ++i) {
250251
uint8_t *c = colors[i];
251252
if (i % 15 == 1) {

colors.h

+8-7
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,14 @@ bool loadBiomeColors(const char* path);
7777
#define NETHER_BRICK_STAIRS 114
7878
#define NETHER_WART 115
7979

80-
#define SANDSTEP 233
81-
#define WOODSTEP 234
82-
#define COBBLESTEP 235
83-
#define BRICKSTEP 236
84-
#define STONEBRICKSTEP 237
80+
#define SANDSTEP 232
81+
#define WOODSTEP 233
82+
#define COBBLESTEP 234
83+
#define BRICKSTEP 235
84+
#define STONEBRICKSTEP 236
8585

86-
#define PINELEAVES 231
87-
#define BIRCHLEAVES 232
86+
#define PINELEAVES 229
87+
#define BIRCHLEAVES 230
88+
#define JUNGLELEAVES 231
8889

8990
#endif

extractcolors.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -245,17 +245,17 @@ static const int special_sauce[256][3] = {
245245
{ -1, -1, 10 },
246246
{ -1, -1, 10 },
247247
{ -1, -1, 10 },
248-
{ -1, -1, 10 },
249-
{ -1, -1, 10 }, /* 230 */
250248
{ 4, 8, 10 }, // Pine leaves (should be darker, more green)
251-
{ 4, 3, 10 }, // Birch leaves (should be lighter)
249+
{ 4, 3, 10 }, /* 230 */ // Birch leaves (should be lighter)
250+
{ 9, 9, 10 }, // Jungle leaves
252251
{ 0, 11, 10 }, // Sandstone half step
253252
{ 4, 0, 10 }, // Wooden half step
254253
{ 0, 1, 10 }, // Cooblestone half step
255254
{ 7, 0, 10 }, // Brick half step
256255
{ 6, 3, 10 }, // Stone brick half step
257256
{ 4, 7, 10 }, // Pine trees get remapped here
258257
{ 5, 7, 10 }, // Birches get remapped here
258+
{ 4, 12, 10 }, // Jungle trees get remapped here
259259
// Dyed wool gets remapped to these block ids. Works up to the point where Notch will actually use these IDs
260260
{ 2, 13, 10 }, /* 240 */ /// Orange Wool
261261
{ 2, 12, 10 }, // Magenta

globals.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#ifndef _GLOBALS_H_
22
#define _GLOBALS_H_
33

4-
#define VERSION "2.3"
4+
#define VERSION "2.3b"
55

66
#include <stdint.h>
77
#include <cstdlib>

main.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -542,6 +542,10 @@ int main(int argc, char **argv)
542542
}
543543
}
544544

545+
if (g_WorldFormat == 2 && (g_Hell || g_ServerHell)) {
546+
uncoverNether();
547+
}
548+
545549
// Load biome data if requested
546550
if (g_UseBiomes) {
547551
loadBiomeMap(biomepath);

worldloader.cpp

+104-56
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ static bool loadRegion(const char* file, const bool mustExist, int &loadedChunks
6969
static bool loadTerrainRegion(const char *fromPath, int &loadedChunks);
7070
static bool scanWorldDirectoryRegion(const char *fromPath);
7171
static inline void assignBlock(const uint8_t &source, uint8_t* &dest, int &x, int &y, int &z, uint8_t* &justData);
72+
static inline void lightCave(const int x, const int y, const int z, const int offsetx, const int offsetz);
7273

7374
int getWorldFormat(const char *worldPath)
7475
{
@@ -461,58 +462,7 @@ static bool loadChunk(const char *streamOrFile, const size_t streamLen)
461462
if (block == TORCH) {
462463
// In underground mode, the lightmap is also used, but the values are calculated manually, to only show
463464
// caves the players have discovered yet. It's not perfect of course, but works ok.
464-
for (int ty = int(y) - 9; ty < int(y) + 9; ty+=2) { // The trick here is to only take into account
465-
const int oty = ty - (int)g_MapminY;
466-
if (oty < 0) {
467-
continue; // areas around torches.
468-
}
469-
if (oty >= int(g_MapsizeY)) {
470-
break;
471-
}
472-
for (int tz = int(z) - 18 + offsetz; tz < int(z) + 18 + offsetz; ++tz) {
473-
if (tz < CHUNKSIZE_Z) {
474-
continue;
475-
}
476-
for (int tx = int(x) - 18 + offsetx; tx < int(x) + 18 + offsetx; ++tx) {
477-
if (tx < CHUNKSIZE_X) {
478-
continue;
479-
}
480-
if (g_Orientation == East) {
481-
if (tx >= int(g_MapsizeZ)-CHUNKSIZE_Z) {
482-
break;
483-
}
484-
if (tz >= int(g_MapsizeX)-CHUNKSIZE_X) {
485-
break;
486-
}
487-
SETLIGHTEAST(tx, oty, tz) = 0xFF;
488-
} else if (g_Orientation == North) {
489-
if (tx >= int(g_MapsizeX)-CHUNKSIZE_X) {
490-
break;
491-
}
492-
if (tz >= int(g_MapsizeZ)-CHUNKSIZE_Z) {
493-
break;
494-
}
495-
SETLIGHTNORTH(tx, oty, tz) = 0xFF;
496-
} else if (g_Orientation == South) {
497-
if (tx >= int(g_MapsizeX)-CHUNKSIZE_X) {
498-
break;
499-
}
500-
if (tz >= int(g_MapsizeZ)-CHUNKSIZE_Z) {
501-
break;
502-
}
503-
SETLIGHTSOUTH(tx, oty, tz) = 0xFF;
504-
} else {
505-
if (tx >= int(g_MapsizeZ)-CHUNKSIZE_Z) {
506-
break;
507-
}
508-
if (tz >= int(g_MapsizeX)-CHUNKSIZE_X) {
509-
break;
510-
}
511-
SETLIGHTWEST(tx , oty, tz) = 0xFF;
512-
}
513-
}
514-
}
515-
}
465+
lightCave(x, y, z, offsetx, offsetz);
516466
}
517467
} else if (g_Skylight && y % 2 == 0 && y >= g_MapminY) { // copy light info too. Only every other time, since light info is 4 bits
518468
const uint8_t &light = lightdata[(y / 2) + (z + (x * CHUNKSIZE_Z)) * (CHUNKSIZE_Y / 2)];
@@ -626,7 +576,12 @@ static bool loadAnvilChunk(NBT_Tag * const level, const int32_t chunkX, const in
626576
uint8_t &block = blockdata[x + (z + (y * CHUNKSIZE_Z)) * CHUNKSIZE_X];
627577
assignBlock(block, targetBlock, x, y, z, justData);
628578
// Light
629-
if (g_Skylight && (y & 1) == 0) {
579+
if (g_Underground) {
580+
if (y < g_MapminY) continue;
581+
if (block == TORCH) {
582+
lightCave(x, y, z, offsetx, offsetz);
583+
}
584+
} else if (g_Skylight && (y & 1) == 0) {
630585
const uint8_t highlight = ((lightdata[(x + (z + ((y + 1) * CHUNKSIZE_Z)) * CHUNKSIZE_X) / 2] >> ((x & 1) * 4)) & 0x0F);
631586
const uint8_t lowlight = ((lightdata[(x + (z + (y * CHUNKSIZE_Z)) * CHUNKSIZE_X) / 2] >> ((x & 1) * 4)) & 0x0F);
632587
uint8_t highsky = ((skydata[(x + (z + ((y + 1) * CHUNKSIZE_Z)) * CHUNKSIZE_X) / 2] >> ((x & 1) * 4)) & 0x0F);
@@ -1061,13 +1016,13 @@ static inline void assignBlock(const uint8_t &block, uint8_t* &targetBlock, int
10611016
uint8_t col = (justData[(x + (z + (y * CHUNKSIZE_Z)) * CHUNKSIZE_X) / 2] >> ((x % 2) * 4)) & 0xF;
10621017
if (block == LEAVES) {
10631018
if ((col & 0x3) != 0) { // Map to pine or birch
1064-
*targetBlock++ = 230 + ((col & 0x3) - 1) % 2 + 1;
1019+
*targetBlock++ = 228 + (col & 0x3);
10651020
} else {
10661021
*targetBlock++ = block;
10671022
}
10681023
} else if (block == LOG) {
10691024
if (col != 0) { // Map to pine or birch
1070-
*targetBlock++ = 237 + col;
1025+
*targetBlock++ = 236 + (col & 0x3);
10711026
} else {
10721027
*targetBlock++ = block;
10731028
}
@@ -1079,7 +1034,7 @@ static inline void assignBlock(const uint8_t &block, uint8_t* &targetBlock, int
10791034
}
10801035
} else if (block == STEP) {
10811036
if (col != 0) {
1082-
*targetBlock++ = 232 + col;
1037+
*targetBlock++ = 231 + col;
10831038
} else {
10841039
*targetBlock++ = block;
10851040
}
@@ -1098,3 +1053,96 @@ static inline void assignBlock(const uint8_t &block, uint8_t* &targetBlock, int
10981053
*targetBlock++ = block;
10991054
}
11001055
}
1056+
1057+
static inline void lightCave(const int x, const int y, const int z, const int offsetx, const int offsetz)
1058+
{
1059+
for (int ty = int(y) - 9; ty < int(y) + 9; ty+=2) { // The trick here is to only take into account
1060+
const int oty = ty - g_MapminY;
1061+
if (oty < 0) {
1062+
continue; // areas around torches.
1063+
}
1064+
if (oty >= int(g_MapsizeY)) {
1065+
break;
1066+
}
1067+
for (int tz = int(z) - 18 + offsetz; tz < int(z) + 18 + offsetz; ++tz) {
1068+
if (tz < CHUNKSIZE_Z) {
1069+
continue;
1070+
}
1071+
for (int tx = int(x) - 18 + offsetx; tx < int(x) + 18 + offsetx; ++tx) {
1072+
if (tx < CHUNKSIZE_X) {
1073+
continue;
1074+
}
1075+
if (g_Orientation == East) {
1076+
if (tx >= int(g_MapsizeZ)-CHUNKSIZE_Z) {
1077+
break;
1078+
}
1079+
if (tz >= int(g_MapsizeX)-CHUNKSIZE_X) {
1080+
break;
1081+
}
1082+
SETLIGHTEAST(tx, oty, tz) = 0xFF;
1083+
} else if (g_Orientation == North) {
1084+
if (tx >= int(g_MapsizeX)-CHUNKSIZE_X) {
1085+
break;
1086+
}
1087+
if (tz >= int(g_MapsizeZ)-CHUNKSIZE_Z) {
1088+
break;
1089+
}
1090+
SETLIGHTNORTH(tx, oty, tz) = 0xFF;
1091+
} else if (g_Orientation == South) {
1092+
if (tx >= int(g_MapsizeX)-CHUNKSIZE_X) {
1093+
break;
1094+
}
1095+
if (tz >= int(g_MapsizeZ)-CHUNKSIZE_Z) {
1096+
break;
1097+
}
1098+
SETLIGHTSOUTH(tx, oty, tz) = 0xFF;
1099+
} else {
1100+
if (tx >= int(g_MapsizeZ)-CHUNKSIZE_Z) {
1101+
break;
1102+
}
1103+
if (tz >= int(g_MapsizeX)-CHUNKSIZE_X) {
1104+
break;
1105+
}
1106+
SETLIGHTWEST(tx , oty, tz) = 0xFF;
1107+
}
1108+
}
1109+
}
1110+
}
1111+
}
1112+
1113+
void uncoverNether()
1114+
{
1115+
const int cap = (g_MapsizeY - g_MapminY) - 57;
1116+
const int to = (g_MapsizeY - g_MapminY) - 52;
1117+
printf("Uncovering Nether...\n");
1118+
for (size_t x = CHUNKSIZE_X; x < g_MapsizeX - CHUNKSIZE_X; ++x) {
1119+
printProgress(x - CHUNKSIZE_X, g_MapsizeX);
1120+
for (size_t z = CHUNKSIZE_Z; z < g_MapsizeZ - CHUNKSIZE_Z; ++z) {
1121+
// Remove blocks on top, otherwise there is not much to see here
1122+
int massive = 0;
1123+
uint8_t *bp = g_Terrain + ((z + (x * g_MapsizeZ) + 1) * g_MapsizeY) - 1;
1124+
int i;
1125+
for (i = 0; i < to; ++i) { // Go down 74 blocks from the ceiling to see if there is anything except solid
1126+
if (massive && (*bp == AIR || *bp == LAVA || *bp == STAT_LAVA)) {
1127+
if (--massive == 0) {
1128+
break; // Ignore caves that are only 2 blocks high
1129+
}
1130+
}
1131+
if (*bp != AIR && *bp != LAVA && *bp != STAT_LAVA) {
1132+
massive = 3;
1133+
}
1134+
--bp;
1135+
}
1136+
// So there was some cave or anything before going down 70 blocks, everything above will get removed
1137+
// If not, only 45 blocks starting at the ceiling will be removed
1138+
if (i > cap) {
1139+
i = cap - 25; // TODO: Make this configurable
1140+
}
1141+
bp = g_Terrain + ((z + (x * g_MapsizeZ) + 1) * g_MapsizeY) - 1;
1142+
for (int j = 0; j < i; ++j) {
1143+
*bp-- = AIR;
1144+
}
1145+
}
1146+
}
1147+
printProgress(10, 10);
1148+
}

worldloader.h

+1
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,6 @@ uint64_t calcTerrainSize(const int chunksX, const int chunksZ);
1212
void clearLightmap();
1313
void calcBitmapOverdraw(int &left, int &right, int &top, int &bottom);
1414
void loadBiomeMap(const char* path);
15+
void uncoverNether();
1516

1617
#endif

0 commit comments

Comments
 (0)