From 104f6d8c147b03edbb99e35812816585fffebc71 Mon Sep 17 00:00:00 2001 From: DaPigGuy Date: Sun, 12 Jan 2025 22:57:20 -0800 Subject: [PATCH] server/block: Use `breakBlock` where appropriate --- server/block/cocoa_bean.go | 2 +- server/block/kelp.go | 4 ++-- server/block/lantern.go | 6 ++---- server/block/nether_sprouts.go | 2 +- server/block/nether_wart.go | 2 +- server/block/torch.go | 3 +-- server/block/vine.go | 2 +- 7 files changed, 9 insertions(+), 12 deletions(-) diff --git a/server/block/cocoa_bean.go b/server/block/cocoa_bean.go index 24bd50426..bc2a4048b 100644 --- a/server/block/cocoa_bean.go +++ b/server/block/cocoa_bean.go @@ -44,7 +44,7 @@ func (c CocoaBean) NeighbourUpdateTick(pos, _ cube.Pos, tx *world.Tx) { woodType = b.Wood } if woodType != JungleWood() { - tx.SetBlock(pos, nil, nil) + breakBlock(c, pos, tx) } } diff --git a/server/block/kelp.go b/server/block/kelp.go index 795b9c06f..27c03af13 100644 --- a/server/block/kelp.go +++ b/server/block/kelp.go @@ -104,7 +104,7 @@ func (k Kelp) UseOnBlock(pos cube.Pos, face cube.Face, _ mgl64.Vec3, tx *world.T // NeighbourUpdateTick ... func (k Kelp) NeighbourUpdateTick(pos, changedNeighbour cube.Pos, tx *world.Tx) { if _, ok := tx.Liquid(pos); !ok { - tx.SetBlock(pos, nil, nil) + breakBlock(k, pos, tx) return } if changedNeighbour[1]-1 == pos.Y() { @@ -116,7 +116,7 @@ func (k Kelp) NeighbourUpdateTick(pos, changedNeighbour cube.Pos, tx *world.Tx) belowBlock := tx.Block(below) if _, kelp := belowBlock.(Kelp); !kelp { if !belowBlock.Model().FaceSolid(below, cube.FaceUp, tx) { - tx.SetBlock(pos, nil, nil) + breakBlock(k, pos, tx) } } } diff --git a/server/block/lantern.go b/server/block/lantern.go index 047e7a7df..0e90cf296 100644 --- a/server/block/lantern.go +++ b/server/block/lantern.go @@ -29,14 +29,12 @@ func (l Lantern) NeighbourUpdateTick(pos, _ cube.Pos, tx *world.Tx) { if l.Hanging { up := pos.Side(cube.FaceUp) if _, ok := tx.Block(up).(Chain); !ok && !tx.Block(up).Model().FaceSolid(up, cube.FaceDown, tx) { - tx.SetBlock(pos, nil, nil) - dropItem(tx, item.NewStack(l, 1), pos.Vec3Centre()) + breakBlock(l, pos, tx) } } else { down := pos.Side(cube.FaceDown) if !tx.Block(down).Model().FaceSolid(down, cube.FaceUp, tx) { - tx.SetBlock(pos, nil, nil) - dropItem(tx, item.NewStack(l, 1), pos.Vec3Centre()) + breakBlock(l, pos, tx) } } } diff --git a/server/block/nether_sprouts.go b/server/block/nether_sprouts.go index 1ec33e9c4..25ab66237 100644 --- a/server/block/nether_sprouts.go +++ b/server/block/nether_sprouts.go @@ -17,7 +17,7 @@ type NetherSprouts struct { // NeighbourUpdateTick ... func (n NetherSprouts) NeighbourUpdateTick(pos, _ cube.Pos, tx *world.Tx) { if !supportsVegetation(n, tx.Block(pos.Side(cube.FaceDown))) { - tx.SetBlock(pos, nil, nil) // TODO: Nylium & mycelium + breakBlock(n, pos, tx) // TODO: Nylium & mycelium } } diff --git a/server/block/nether_wart.go b/server/block/nether_wart.go index da90ff151..40e497fd5 100644 --- a/server/block/nether_wart.go +++ b/server/block/nether_wart.go @@ -47,7 +47,7 @@ func (n NetherWart) UseOnBlock(pos cube.Pos, face cube.Face, _ mgl64.Vec3, tx *w // NeighbourUpdateTick ... func (n NetherWart) NeighbourUpdateTick(pos, _ cube.Pos, tx *world.Tx) { if _, ok := tx.Block(pos.Side(cube.FaceDown)).(SoulSand); !ok { - tx.SetBlock(pos, nil, nil) + breakBlock(n, pos, tx) } } diff --git a/server/block/torch.go b/server/block/torch.go index 8e20f780b..9fdb8660f 100644 --- a/server/block/torch.go +++ b/server/block/torch.go @@ -67,8 +67,7 @@ func (t Torch) UseOnBlock(pos cube.Pos, face cube.Face, _ mgl64.Vec3, tx *world. // NeighbourUpdateTick ... func (t Torch) NeighbourUpdateTick(pos, _ cube.Pos, tx *world.Tx) { if !tx.Block(pos.Side(t.Facing)).Model().FaceSolid(pos.Side(t.Facing), t.Facing.Opposite(), tx) { - tx.SetBlock(pos, nil, nil) - dropItem(tx, item.NewStack(t, 1), pos.Vec3Centre()) + breakBlock(t, pos, tx) } } diff --git a/server/block/vine.go b/server/block/vine.go index c16b21569..c753b9b00 100644 --- a/server/block/vine.go +++ b/server/block/vine.go @@ -140,7 +140,7 @@ func (v Vines) NeighbourUpdateTick(pos, _ cube.Pos, tx *world.Tx) { return } if len(v.Attachments()) == 0 { - tx.SetBlock(pos, nil, nil) + breakBlock(v, pos, tx) return } tx.SetBlock(pos, v, nil)