Skip to content

Commit

Permalink
Merge branch 'master' into unbreakable-item
Browse files Browse the repository at this point in the history
  • Loading branch information
AkmalFairuz authored Jan 18, 2025
2 parents 445c6af + 6fbcb9e commit 8d9c346
Show file tree
Hide file tree
Showing 10 changed files with 23 additions and 24 deletions.
5 changes: 5 additions & 0 deletions server/block/banner.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 1 addition & 4 deletions server/block/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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))
Expand Down
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
5 changes: 5 additions & 0 deletions server/block/decorated_pot.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
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
13 changes: 4 additions & 9 deletions server/block/vine.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 ...
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 8d9c346

Please sign in to comment.