Skip to content

Commit a6bfa63

Browse files
committed
server/block: Don't allow liquid removable blocks to replace liquids
1 parent 4e265ee commit a6bfa63

File tree

3 files changed

+25
-2
lines changed

3 files changed

+25
-2
lines changed

server/block/lava.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import (
1212
// Lava is a light-emitting fluid block that causes fire damage.
1313
type Lava struct {
1414
empty
15-
replaceable
1615

1716
// Still makes the lava not spread whenever it is updated. Still lava cannot be acquired in the game
1817
// without world editing.
@@ -35,6 +34,16 @@ func neighboursLavaFlammable(pos cube.Pos, tx *world.Tx) bool {
3534
return false
3635
}
3736

37+
// ReplaceableBy ...
38+
func (l Lava) ReplaceableBy(b world.Block) bool {
39+
if _, ok := b.(LiquidRemovable); ok {
40+
_, displacer := b.(world.LiquidDisplacer)
41+
_, liquid := b.(world.Liquid)
42+
return displacer || liquid
43+
}
44+
return true
45+
}
46+
3847
// EntityInside ...
3948
func (l Lava) EntityInside(_ cube.Pos, _ *world.Tx, e world.Entity) {
4049
if fallEntity, ok := e.(fallDistanceEntity); ok {

server/block/sea_pickle.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ func (SeaPickle) canSurvive(pos cube.Pos, tx *world.Tx) bool {
2929
if !below.Model().FaceSolid(pos.Side(cube.FaceDown), cube.FaceUp, tx) {
3030
return false
3131
}
32+
if liquid, ok := tx.Liquid(pos); ok {
33+
if _, ok = liquid.(Water); !ok || liquid.LiquidDepth() != 8 {
34+
return false
35+
}
36+
}
3237
if emitter, ok := below.(LightDiffuser); ok && emitter.LightDiffusionLevel() != 15 {
3338
return false
3439
}

server/block/water.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import (
1414
// Water is a natural fluid that generates abundantly in the world.
1515
type Water struct {
1616
empty
17-
replaceable
1817

1918
// Still makes the water appear as if it is not flowing.
2019
Still bool
@@ -26,6 +25,16 @@ type Water struct {
2625
Falling bool
2726
}
2827

28+
// ReplaceableBy ...
29+
func (w Water) ReplaceableBy(b world.Block) bool {
30+
if _, ok := b.(LiquidRemovable); ok {
31+
_, displacer := b.(world.LiquidDisplacer)
32+
_, liquid := b.(world.Liquid)
33+
return displacer || liquid
34+
}
35+
return true
36+
}
37+
2938
// EntityInside ...
3039
func (w Water) EntityInside(_ cube.Pos, _ *world.Tx, e world.Entity) {
3140
if fallEntity, ok := e.(fallDistanceEntity); ok {

0 commit comments

Comments
 (0)