Skip to content

Commit

Permalink
server/block: Use breakBlock where appropriate
Browse files Browse the repository at this point in the history
  • Loading branch information
DaPigGuy committed Jan 13, 2025
1 parent be5ab40 commit 104f6d8
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 12 deletions.
2 changes: 1 addition & 1 deletion server/block/cocoa_bean.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

Expand Down
4 changes: 2 additions & 2 deletions server/block/kelp.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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)
}
}
}
Expand Down
6 changes: 2 additions & 4 deletions server/block/lantern.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion server/block/nether_sprouts.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

Expand Down
2 changes: 1 addition & 1 deletion server/block/nether_wart.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

Expand Down
3 changes: 1 addition & 2 deletions server/block/torch.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

Expand Down
2 changes: 1 addition & 1 deletion server/block/vine.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 104f6d8

Please sign in to comment.