Skip to content

Commit 75cad59

Browse files
committed
Fixed water issue with missing water (mapcrafter#178), and the forum thread issue.
1 parent 0791ad3 commit 75cad59

File tree

4 files changed

+24
-12
lines changed

4 files changed

+24
-12
lines changed

src/mapcraftercore/mc/worldcache.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ Block::Block(const mc::BlockPos& pos, uint16_t id, uint16_t data)
3434
}
3535

3636
bool Block::isFullWater() const {
37-
return (id == 8 || id == 9) && data == 0;
37+
return (id == 8 || id == 9) && (data & 0x7) == 0;
3838
}
3939

4040
bool Block::isStairs() const {

src/mapcraftercore/renderer/blockimages.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ const int EDGE_EAST = 1 << 14;
5555
const int EDGE_BOTTOM = 1 << 15;
5656

5757
// some data values and stuff for special blocks
58+
const int FULL_WATER = DATA_NORTH;
59+
const int FULL_WATER_SOUTH = DATA_SOUTH;
60+
const int FULL_WATER_WEST = DATA_WEST;
61+
const int FULL_WATER_TOP = DATA_TOP;
5862
const int GRASS_SNOW = 16;
5963

6064
const int OPAQUE_WATER = 1 << 4;

src/mapcraftercore/renderer/renderviews/isometric/blockimages.cpp

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -347,9 +347,13 @@ uint16_t IsometricBlockImages::filterBlockData(uint16_t id, uint16_t data) const
347347

348348
if (id == 6)
349349
return data & (0xff00 | util::binary<11>::value);
350-
else if (id == 8 || id == 9) // water
350+
else if (id == 8 || id == 9) { // water
351+
// 0x8 bit means that this is a water block spreading downwards
352+
// -> return with Minecraft data 0 (full block)
353+
if (data & 0x8)
354+
data &= ~0x7;
351355
return data & (0xff00 | util::binary<11110111>::value);
352-
else if (id == 10 || id == 11) { // lava
356+
} else if (id == 10 || id == 11) { // lava
353357
// 0x8 bit means that this is a lava block spreading downwards
354358
// -> return data 0 (full block)
355359
if (data & 0x8)
@@ -623,25 +627,27 @@ void IsometricBlockImages::createWater() { // id 8, 9
623627
bool top = i & util::binary<1>::value;
624628

625629
RGBAImage block(getBlockSize(), getBlockSize());
626-
uint16_t extra_data = 0;
630+
uint16_t extra_data = FULL_WATER;
627631

628632
if (top) {
629633
blitFace(block, FACE_TOP, water, 0, 0, true, dleft, dright);
630-
extra_data |= DATA_TOP;
634+
extra_data |= FULL_WATER_TOP;
631635
}
632636

633637
if (west) {
634638
blitFace(block, FACE_WEST, water, 0, 0, true, dleft, dright);
635-
extra_data |= DATA_WEST;
639+
extra_data |= FULL_WATER_WEST;
636640
}
637641

638642
if (south) {
639643
blitFace(block, FACE_SOUTH, water, 0, 0, true, dleft, dright);
640-
extra_data |= DATA_SOUTH;
644+
extra_data |= FULL_WATER_SOUTH;
641645
}
642646

643-
setBlockImage(8, extra_data, block);
644-
setBlockImage(9, extra_data, block);
647+
if (extra_data != 0) {
648+
setBlockImage(8, extra_data, block);
649+
setBlockImage(9, extra_data, block);
650+
}
645651
}
646652
}
647653

src/mapcraftercore/renderer/tilerenderer.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,12 +140,14 @@ uint16_t TileRenderer::checkNeighbors(const mc::BlockPos& pos, uint16_t id, uint
140140
// check if the neighbors on visible faces (top, west, south) are also full water blocks
141141
// show water textures on these sides only if there is no water as neighbor too
142142
// exception for the top-face and when preblit water is used
143+
data |= FULL_WATER;
143144
if (use_preblit_water || !top.isFullWater())
144-
data |= DATA_TOP;
145+
data |= FULL_WATER_TOP;
145146
if (!west.isFullWater())
146-
data |= DATA_WEST;
147+
data |= FULL_WATER_WEST;
147148
if (!south.isFullWater())
148-
data |= DATA_SOUTH;
149+
data |= FULL_WATER_SOUTH;
150+
149151
} else if (block.isStairs()) { // stairs
150152
// corner stairs... wtf
151153
// using corner stair detection code of Minecraft Overviewer for now:

0 commit comments

Comments
 (0)