Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions server/block/hash.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions 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))) {
breakBlock(n, pos, tx) // TODO: Nylium & mycelium
breakBlock(n, pos, tx) // TODO: Mycelium
}
}

Expand All @@ -28,7 +28,7 @@ func (n NetherSprouts) UseOnBlock(pos cube.Pos, face cube.Face, _ mgl64.Vec3, tx
return false
}
if !supportsVegetation(n, tx.Block(pos.Side(cube.FaceDown))) {
return false // TODO: Nylium & mycelium
return false // TODO: Mycelium
}

place(tx, pos, n, user, ctx)
Expand Down
24 changes: 24 additions & 0 deletions server/block/netherrack.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package block

import (
"math/rand/v2"
"slices"

"github.com/df-mc/dragonfly/server/block/cube"
"github.com/df-mc/dragonfly/server/item"
"github.com/df-mc/dragonfly/server/world"
)
Expand All @@ -17,6 +21,26 @@ func (n Netherrack) SoilFor(block world.Block) bool {
return ok && flower.Type == WitherRose()
}

// BoneMeal ...
func (n Netherrack) BoneMeal(pos cube.Pos, tx *world.Tx) item.BoneMealResult {
var types []Nylium
for x := -1; x <= 1; x++ {
for z := -1; z <= 1; z++ {
if x == 0 && z == 0 {
continue
}
if nylium, ok := tx.Block(pos.Add(cube.Pos{x, 0, z})).(Nylium); ok && !slices.Contains(types, nylium) {
types = append(types, nylium)
}
}
}
if len(types) == 0 {
return item.BoneMealResultNone
}
tx.SetBlock(pos, types[rand.IntN(len(types))], nil)
return item.BoneMealResultSmall
}

// BreakInfo ...
func (n Netherrack) BreakInfo() BreakInfo {
return newBreakInfo(0.4, pickaxeHarvestable, pickaxeEffective, oneOf(n))
Expand Down
53 changes: 53 additions & 0 deletions server/block/nylium.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package block

import (
"math/rand/v2"

"github.com/df-mc/dragonfly/server/block/cube"
"github.com/df-mc/dragonfly/server/world"
)

// Nylium is a variant of netherrack that covers the floor of crimson and warped forests, on which nether
// vegetation is able to grow.
type Nylium struct {
solid
bassDrum

// Warped is the turquoise variant found in warped forests.
Warped bool
}

// SoilFor ...
func (n Nylium) SoilFor(block world.Block) bool {
_, ok := block.(NetherSprouts)
return ok
}

// RandomTick ...
func (n Nylium) RandomTick(pos cube.Pos, tx *world.Tx, _ *rand.Rand) {
above := pos.Side(cube.FaceUp)
if diffuser, ok := tx.Block(above).(LightDiffuser); !ok || diffuser.LightDiffusionLevel() == 15 {
tx.SetBlock(pos, Netherrack{}, nil)
}
}

// BreakInfo ...
func (n Nylium) BreakInfo() BreakInfo {
return newBreakInfo(0.4, pickaxeHarvestable, pickaxeEffective, silkTouchOneOf(Netherrack{}, n))
}

// EncodeItem ...
func (n Nylium) EncodeItem() (name string, meta int16) {
if n.Warped {
return "minecraft:warped_nylium", 0
}
return "minecraft:crimson_nylium", 0
}

// EncodeBlock ...
func (n Nylium) EncodeBlock() (string, map[string]any) {
if n.Warped {
return "minecraft:warped_nylium", nil
}
return "minecraft:crimson_nylium", nil
}
4 changes: 4 additions & 0 deletions server/block/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ func init() {
world.RegisterBlock(Netherite{})
world.RegisterBlock(Netherrack{})
world.RegisterBlock(Note{})
world.RegisterBlock(Nylium{Warped: true})
world.RegisterBlock(Nylium{})
world.RegisterBlock(Obsidian{Crying: true})
world.RegisterBlock(Obsidian{})
world.RegisterBlock(PackedIce{})
Expand Down Expand Up @@ -376,6 +378,8 @@ func init() {
world.RegisterItem(Netherite{})
world.RegisterItem(Netherrack{})
world.RegisterItem(Note{Pitch: 24})
world.RegisterItem(Nylium{Warped: true})
world.RegisterItem(Nylium{})
world.RegisterItem(Obsidian{Crying: true})
world.RegisterItem(Obsidian{})
world.RegisterItem(PackedIce{})
Expand Down