From a6bfa6308c0102b9942f467e6be42d6cc0288135 Mon Sep 17 00:00:00 2001 From: DaPigGuy Date: Sun, 26 Jan 2025 02:04:48 -0800 Subject: [PATCH] server/block: Don't allow liquid removable blocks to replace liquids --- server/block/lava.go | 11 ++++++++++- server/block/sea_pickle.go | 5 +++++ server/block/water.go | 11 ++++++++++- 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/server/block/lava.go b/server/block/lava.go index 239b0ac0e..d75571043 100644 --- a/server/block/lava.go +++ b/server/block/lava.go @@ -12,7 +12,6 @@ import ( // Lava is a light-emitting fluid block that causes fire damage. type Lava struct { empty - replaceable // Still makes the lava not spread whenever it is updated. Still lava cannot be acquired in the game // without world editing. @@ -35,6 +34,16 @@ func neighboursLavaFlammable(pos cube.Pos, tx *world.Tx) bool { return false } +// ReplaceableBy ... +func (l Lava) ReplaceableBy(b world.Block) bool { + if _, ok := b.(LiquidRemovable); ok { + _, displacer := b.(world.LiquidDisplacer) + _, liquid := b.(world.Liquid) + return displacer || liquid + } + return true +} + // EntityInside ... func (l Lava) EntityInside(_ cube.Pos, _ *world.Tx, e world.Entity) { if fallEntity, ok := e.(fallDistanceEntity); ok { diff --git a/server/block/sea_pickle.go b/server/block/sea_pickle.go index bfb7f07e6..3b6acbc87 100644 --- a/server/block/sea_pickle.go +++ b/server/block/sea_pickle.go @@ -29,6 +29,11 @@ func (SeaPickle) canSurvive(pos cube.Pos, tx *world.Tx) bool { if !below.Model().FaceSolid(pos.Side(cube.FaceDown), cube.FaceUp, tx) { return false } + if liquid, ok := tx.Liquid(pos); ok { + if _, ok = liquid.(Water); !ok || liquid.LiquidDepth() != 8 { + return false + } + } if emitter, ok := below.(LightDiffuser); ok && emitter.LightDiffusionLevel() != 15 { return false } diff --git a/server/block/water.go b/server/block/water.go index cc830d66c..783932a63 100644 --- a/server/block/water.go +++ b/server/block/water.go @@ -14,7 +14,6 @@ import ( // Water is a natural fluid that generates abundantly in the world. type Water struct { empty - replaceable // Still makes the water appear as if it is not flowing. Still bool @@ -26,6 +25,16 @@ type Water struct { Falling bool } +// ReplaceableBy ... +func (w Water) ReplaceableBy(b world.Block) bool { + if _, ok := b.(LiquidRemovable); ok { + _, displacer := b.(world.LiquidDisplacer) + _, liquid := b.(world.Liquid) + return displacer || liquid + } + return true +} + // EntityInside ... func (w Water) EntityInside(_ cube.Pos, _ *world.Tx, e world.Entity) { if fallEntity, ok := e.(fallDistanceEntity); ok {