Skip to content

Commit 0bb52c5

Browse files
committed
block/campfire.go: Do not allow items when waterlogged
1 parent 770be27 commit 0bb52c5

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

server/block/campfire.go

+20-3
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,10 @@ func (c Campfire) Activate(pos cube.Pos, _ cube.Face, tx *world.Tx, u item.User,
132132
return false
133133
}
134134

135+
if _, ok = tx.Liquid(pos); ok {
136+
return false
137+
}
138+
135139
for i, it := range c.Items {
136140
if it.Item.Empty() {
137141
c.Items[i] = CampfireItem{
@@ -197,9 +201,22 @@ func (c Campfire) Tick(_ int64, pos cube.Pos, tx *world.Tx) {
197201

198202
// NeighbourUpdateTick ...
199203
func (c Campfire) NeighbourUpdateTick(pos, _ cube.Pos, tx *world.Tx) {
200-
_, ok := tx.Liquid(pos)
201-
liquid, okTwo := tx.Liquid(pos.Side(cube.FaceUp))
202-
if (ok || (okTwo && liquid.LiquidType() == "water")) && !c.Extinguished {
204+
if _, ok := tx.Liquid(pos); ok {
205+
var updated bool
206+
for i, it := range c.Items {
207+
if !it.Item.Empty() {
208+
dropItem(tx, it.Item, pos.Vec3Centre())
209+
c.Items[i].Item, updated = item.Stack{}, true
210+
}
211+
}
212+
if !c.Extinguished {
213+
c.extinguish(pos, tx)
214+
} else if updated {
215+
tx.SetBlock(pos, c, nil)
216+
}
217+
return
218+
}
219+
if liquid, ok := tx.Liquid(pos.Side(cube.FaceUp)); ok && liquid.LiquidType() == "water" && !c.Extinguished {
203220
c.extinguish(pos, tx)
204221
}
205222
}

0 commit comments

Comments
 (0)