diff --git a/server/block/banner.go b/server/block/banner.go index f0252679c..97bd8b32c 100644 --- a/server/block/banner.go +++ b/server/block/banner.go @@ -24,6 +24,11 @@ type Banner struct { Illager bool } +// Pick ... +func (b Banner) Pick() item.Stack { + return item.NewStack(Banner{Colour: b.Colour, Patterns: b.Patterns, Illager: b.Illager}, 1) +} + // MaxCount ... func (Banner) MaxCount() int { return 16 diff --git a/server/block/block.go b/server/block/block.go index 8a541eed4..a9736cd57 100644 --- a/server/block/block.go +++ b/server/block/block.go @@ -3,7 +3,6 @@ package block import ( "github.com/df-mc/dragonfly/server/block/cube" "github.com/df-mc/dragonfly/server/block/customblock" - "github.com/df-mc/dragonfly/server/block/model" "github.com/df-mc/dragonfly/server/item" "github.com/df-mc/dragonfly/server/world" "github.com/df-mc/dragonfly/server/world/sound" @@ -224,9 +223,7 @@ func (g gravityAffected) Solidifies(cube.Pos, *world.Tx) bool { // fall spawns a falling block entity at the given position. func (g gravityAffected) fall(b world.Block, pos cube.Pos, tx *world.Tx) { - _, air := tx.Block(pos.Side(cube.FaceDown)).Model().(model.Empty) - _, liquid := tx.Liquid(pos.Side(cube.FaceDown)) - if air || liquid { + if replaceableWith(tx, pos.Side(cube.FaceDown), b) { tx.SetBlock(pos, nil, nil) opts := world.EntitySpawnOpts{Position: pos.Vec3Centre()} tx.AddEntity(tx.World().EntityRegistry().Config().FallingBlock(opts, b)) 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/decorated_pot.go b/server/block/decorated_pot.go index 958249510..9ffcc0a7d 100644 --- a/server/block/decorated_pot.go +++ b/server/block/decorated_pot.go @@ -33,6 +33,11 @@ type DecoratedPot struct { Decorations [4]PotDecoration } +// SideClosed ... +func (p DecoratedPot) SideClosed(cube.Pos, cube.Pos, *world.Tx) bool { + return false +} + // ProjectileHit ... func (p DecoratedPot) ProjectileHit(pos cube.Pos, tx *world.Tx, _ world.Entity, _ cube.Face) { for _, d := range p.Decorations { 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 1fe2b9560..c753b9b00 100644 --- a/server/block/vine.go +++ b/server/block/vine.go @@ -48,14 +48,9 @@ func (Vines) FlammabilityInfo() FlammabilityInfo { // BreakInfo ... func (v Vines) BreakInfo() BreakInfo { - return newBreakInfo(0.2, alwaysHarvestable, func(t item.Tool) bool { - return t.ToolType() == item.TypeShears || t.ToolType() == item.TypeAxe - }, func(t item.Tool, enchantments []item.Enchantment) []item.Stack { - if t.ToolType() == item.TypeShears { - return []item.Stack{item.NewStack(v, 1)} - } - return nil - }) + return newBreakInfo(0.2, func(t item.Tool) bool { + return t.ToolType() == item.TypeShears + }, axeEffective, oneOf(v)) } // EntityInside ... @@ -145,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)