@@ -2,7 +2,7 @@ import { Vec3 } from 'vec3'
2
2
import worldBlockProvider , { WorldBlockProvider } from 'mc-assets/dist/worldBlockProvider'
3
3
import legacyJson from '../../../../src/preflatMap.json'
4
4
import { BlockType } from '../../../playground/shared'
5
- import { World , BlockModelPartsResolved , WorldBlock as Block } from './world'
5
+ import { World , BlockModelPartsResolved , WorldBlock as Block , WorldBlock } from './world'
6
6
import { BlockElement , buildRotationMatrix , elemFaces , matmul3 , matmulmat3 , vecadd3 , vecsub3 } from './modelsGeometryCommon'
7
7
import { INVISIBLE_BLOCKS } from './worldConstants'
8
8
import { MesherGeometryOutput , HighestBlockInfo } from './shared'
@@ -103,7 +103,8 @@ function tintToGl (tint) {
103
103
return [ r / 255 , g / 255 , b / 255 ]
104
104
}
105
105
106
- function getLiquidRenderHeight ( world , block , type , pos ) {
106
+ function getLiquidRenderHeight ( world : World , block : WorldBlock | null , type : number , pos : Vec3 , isRealWater : boolean ) {
107
+ if ( ! isRealWater || ( block && isBlockWaterlogged ( block ) ) ) return 8 / 9
107
108
if ( ! block || block . type !== type ) return 1 / 9
108
109
if ( block . metadata === 0 ) { // source block
109
110
const blockAbove = world . getBlock ( pos . offset ( 0 , 1 , 0 ) )
@@ -124,12 +125,12 @@ const isCube = (block: Block) => {
124
125
} ) )
125
126
}
126
127
127
- function renderLiquid ( world : World , cursor : Vec3 , texture : any | undefined , type : number , biome : string , water : boolean , attr : Record < string , any > ) {
128
+ function renderLiquid ( world : World , cursor : Vec3 , texture : any | undefined , type : number , biome : string , water : boolean , attr : Record < string , any > , isRealWater : boolean ) {
128
129
const heights : number [ ] = [ ]
129
130
for ( let z = - 1 ; z <= 1 ; z ++ ) {
130
131
for ( let x = - 1 ; x <= 1 ; x ++ ) {
131
132
const pos = cursor . offset ( x , 0 , z )
132
- heights . push ( getLiquidRenderHeight ( world , world . getBlock ( pos ) , type , pos ) )
133
+ heights . push ( getLiquidRenderHeight ( world , world . getBlock ( pos ) , type , pos , isRealWater ) )
133
134
}
134
135
}
135
136
const cornerHeights = [
@@ -147,9 +148,8 @@ function renderLiquid (world: World, cursor: Vec3, texture: any | undefined, typ
147
148
const neighborPos = cursor . offset ( ...dir as [ number , number , number ] )
148
149
const neighbor = world . getBlock ( neighborPos )
149
150
if ( ! neighbor ) continue
150
- if ( neighbor . type === type ) continue
151
- const isGlass = neighbor . name . includes ( 'glass' )
152
- if ( ( isCube ( neighbor ) && ! isUp ) || neighbor . material === 'plant' || neighbor . getProperties ( ) . waterlogged ) continue
151
+ if ( neighbor . type === type || ( water && ( neighbor . name === 'water' || isBlockWaterlogged ( neighbor ) ) ) ) continue
152
+ if ( isCube ( neighbor ) && ! isUp ) continue
153
153
154
154
let tint = [ 1 , 1 , 1 ]
155
155
if ( water ) {
@@ -539,11 +539,11 @@ export function getSectionGeometry (sx, sy, sz, world: World) {
539
539
const pos = cursor . clone ( )
540
540
// eslint-disable-next-line @typescript-eslint/no-loop-func
541
541
delayedRender . push ( ( ) => {
542
- renderLiquid ( world , pos , blockProvider . getTextureInfo ( 'water_still' ) , block . type , biome , true , attr )
542
+ renderLiquid ( world , pos , blockProvider . getTextureInfo ( 'water_still' ) , block . type , biome , true , attr , ! isWaterlogged )
543
543
} )
544
544
attr . blocksCount ++
545
545
} else if ( block . name === 'lava' ) {
546
- renderLiquid ( world , cursor , blockProvider . getTextureInfo ( 'lava_still' ) , block . type , biome , false , attr )
546
+ renderLiquid ( world , cursor , blockProvider . getTextureInfo ( 'lava_still' ) , block . type , biome , false , attr , false )
547
547
attr . blocksCount ++
548
548
}
549
549
if ( block . name !== 'water' && block . name !== 'lava' && ! INVISIBLE_BLOCKS . has ( block . name ) ) {
0 commit comments