Skip to content

Commit 8d9c346

Browse files
authored
Merge branch 'master' into unbreakable-item
2 parents 445c6af + 6fbcb9e commit 8d9c346

File tree

10 files changed

+23
-24
lines changed

10 files changed

+23
-24
lines changed

server/block/banner.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ type Banner struct {
2424
Illager bool
2525
}
2626

27+
// Pick ...
28+
func (b Banner) Pick() item.Stack {
29+
return item.NewStack(Banner{Colour: b.Colour, Patterns: b.Patterns, Illager: b.Illager}, 1)
30+
}
31+
2732
// MaxCount ...
2833
func (Banner) MaxCount() int {
2934
return 16

server/block/block.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package block
33
import (
44
"github.com/df-mc/dragonfly/server/block/cube"
55
"github.com/df-mc/dragonfly/server/block/customblock"
6-
"github.com/df-mc/dragonfly/server/block/model"
76
"github.com/df-mc/dragonfly/server/item"
87
"github.com/df-mc/dragonfly/server/world"
98
"github.com/df-mc/dragonfly/server/world/sound"
@@ -224,9 +223,7 @@ func (g gravityAffected) Solidifies(cube.Pos, *world.Tx) bool {
224223

225224
// fall spawns a falling block entity at the given position.
226225
func (g gravityAffected) fall(b world.Block, pos cube.Pos, tx *world.Tx) {
227-
_, air := tx.Block(pos.Side(cube.FaceDown)).Model().(model.Empty)
228-
_, liquid := tx.Liquid(pos.Side(cube.FaceDown))
229-
if air || liquid {
226+
if replaceableWith(tx, pos.Side(cube.FaceDown), b) {
230227
tx.SetBlock(pos, nil, nil)
231228
opts := world.EntitySpawnOpts{Position: pos.Vec3Centre()}
232229
tx.AddEntity(tx.World().EntityRegistry().Config().FallingBlock(opts, b))

server/block/cocoa_bean.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ func (c CocoaBean) NeighbourUpdateTick(pos, _ cube.Pos, tx *world.Tx) {
4444
woodType = b.Wood
4545
}
4646
if woodType != JungleWood() {
47-
tx.SetBlock(pos, nil, nil)
47+
breakBlock(c, pos, tx)
4848
}
4949
}
5050

server/block/decorated_pot.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ type DecoratedPot struct {
3333
Decorations [4]PotDecoration
3434
}
3535

36+
// SideClosed ...
37+
func (p DecoratedPot) SideClosed(cube.Pos, cube.Pos, *world.Tx) bool {
38+
return false
39+
}
40+
3641
// ProjectileHit ...
3742
func (p DecoratedPot) ProjectileHit(pos cube.Pos, tx *world.Tx, _ world.Entity, _ cube.Face) {
3843
for _, d := range p.Decorations {

server/block/kelp.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ func (k Kelp) UseOnBlock(pos cube.Pos, face cube.Face, _ mgl64.Vec3, tx *world.T
104104
// NeighbourUpdateTick ...
105105
func (k Kelp) NeighbourUpdateTick(pos, changedNeighbour cube.Pos, tx *world.Tx) {
106106
if _, ok := tx.Liquid(pos); !ok {
107-
tx.SetBlock(pos, nil, nil)
107+
breakBlock(k, pos, tx)
108108
return
109109
}
110110
if changedNeighbour[1]-1 == pos.Y() {
@@ -116,7 +116,7 @@ func (k Kelp) NeighbourUpdateTick(pos, changedNeighbour cube.Pos, tx *world.Tx)
116116
belowBlock := tx.Block(below)
117117
if _, kelp := belowBlock.(Kelp); !kelp {
118118
if !belowBlock.Model().FaceSolid(below, cube.FaceUp, tx) {
119-
tx.SetBlock(pos, nil, nil)
119+
breakBlock(k, pos, tx)
120120
}
121121
}
122122
}

server/block/lantern.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,12 @@ func (l Lantern) NeighbourUpdateTick(pos, _ cube.Pos, tx *world.Tx) {
2929
if l.Hanging {
3030
up := pos.Side(cube.FaceUp)
3131
if _, ok := tx.Block(up).(Chain); !ok && !tx.Block(up).Model().FaceSolid(up, cube.FaceDown, tx) {
32-
tx.SetBlock(pos, nil, nil)
33-
dropItem(tx, item.NewStack(l, 1), pos.Vec3Centre())
32+
breakBlock(l, pos, tx)
3433
}
3534
} else {
3635
down := pos.Side(cube.FaceDown)
3736
if !tx.Block(down).Model().FaceSolid(down, cube.FaceUp, tx) {
38-
tx.SetBlock(pos, nil, nil)
39-
dropItem(tx, item.NewStack(l, 1), pos.Vec3Centre())
37+
breakBlock(l, pos, tx)
4038
}
4139
}
4240
}

server/block/nether_sprouts.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ type NetherSprouts struct {
1717
// NeighbourUpdateTick ...
1818
func (n NetherSprouts) NeighbourUpdateTick(pos, _ cube.Pos, tx *world.Tx) {
1919
if !supportsVegetation(n, tx.Block(pos.Side(cube.FaceDown))) {
20-
tx.SetBlock(pos, nil, nil) // TODO: Nylium & mycelium
20+
breakBlock(n, pos, tx) // TODO: Nylium & mycelium
2121
}
2222
}
2323

server/block/nether_wart.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ func (n NetherWart) UseOnBlock(pos cube.Pos, face cube.Face, _ mgl64.Vec3, tx *w
4747
// NeighbourUpdateTick ...
4848
func (n NetherWart) NeighbourUpdateTick(pos, _ cube.Pos, tx *world.Tx) {
4949
if _, ok := tx.Block(pos.Side(cube.FaceDown)).(SoulSand); !ok {
50-
tx.SetBlock(pos, nil, nil)
50+
breakBlock(n, pos, tx)
5151
}
5252
}
5353

server/block/torch.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,7 @@ func (t Torch) UseOnBlock(pos cube.Pos, face cube.Face, _ mgl64.Vec3, tx *world.
6767
// NeighbourUpdateTick ...
6868
func (t Torch) NeighbourUpdateTick(pos, _ cube.Pos, tx *world.Tx) {
6969
if !tx.Block(pos.Side(t.Facing)).Model().FaceSolid(pos.Side(t.Facing), t.Facing.Opposite(), tx) {
70-
tx.SetBlock(pos, nil, nil)
71-
dropItem(tx, item.NewStack(t, 1), pos.Vec3Centre())
70+
breakBlock(t, pos, tx)
7271
}
7372
}
7473

server/block/vine.go

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,9 @@ func (Vines) FlammabilityInfo() FlammabilityInfo {
4848

4949
// BreakInfo ...
5050
func (v Vines) BreakInfo() BreakInfo {
51-
return newBreakInfo(0.2, alwaysHarvestable, func(t item.Tool) bool {
52-
return t.ToolType() == item.TypeShears || t.ToolType() == item.TypeAxe
53-
}, func(t item.Tool, enchantments []item.Enchantment) []item.Stack {
54-
if t.ToolType() == item.TypeShears {
55-
return []item.Stack{item.NewStack(v, 1)}
56-
}
57-
return nil
58-
})
51+
return newBreakInfo(0.2, func(t item.Tool) bool {
52+
return t.ToolType() == item.TypeShears
53+
}, axeEffective, oneOf(v))
5954
}
6055

6156
// EntityInside ...
@@ -145,7 +140,7 @@ func (v Vines) NeighbourUpdateTick(pos, _ cube.Pos, tx *world.Tx) {
145140
return
146141
}
147142
if len(v.Attachments()) == 0 {
148-
tx.SetBlock(pos, nil, nil)
143+
breakBlock(v, pos, tx)
149144
return
150145
}
151146
tx.SetBlock(pos, v, nil)

0 commit comments

Comments
 (0)