56 lines
1.4 KiB
Go
56 lines
1.4 KiB
Go
|
|
package block
|
||
|
|
|
||
|
|
import (
|
||
|
|
"github.com/df-mc/dragonfly/server/block/cube"
|
||
|
|
"github.com/df-mc/dragonfly/server/item"
|
||
|
|
"github.com/df-mc/dragonfly/server/world"
|
||
|
|
"github.com/go-gl/mathgl/mgl64"
|
||
|
|
)
|
||
|
|
|
||
|
|
// LitPumpkin is a decorative light emitting block crafted with a Carved Pumpkin & Torch
|
||
|
|
type LitPumpkin struct {
|
||
|
|
solid
|
||
|
|
|
||
|
|
// Facing is the direction the pumpkin is facing.
|
||
|
|
Facing cube.Direction
|
||
|
|
}
|
||
|
|
|
||
|
|
// LightEmissionLevel ...
|
||
|
|
func (l LitPumpkin) LightEmissionLevel() uint8 {
|
||
|
|
return 15
|
||
|
|
}
|
||
|
|
|
||
|
|
// UseOnBlock ...
|
||
|
|
func (l LitPumpkin) UseOnBlock(pos cube.Pos, face cube.Face, _ mgl64.Vec3, tx *world.Tx, user item.User, ctx *item.UseContext) (used bool) {
|
||
|
|
pos, _, used = firstReplaceable(tx, pos, face, l)
|
||
|
|
if !used {
|
||
|
|
return
|
||
|
|
}
|
||
|
|
l.Facing = user.Rotation().Direction().Opposite()
|
||
|
|
|
||
|
|
place(tx, pos, l, user, ctx)
|
||
|
|
return placed(ctx)
|
||
|
|
}
|
||
|
|
|
||
|
|
// BreakInfo ...
|
||
|
|
func (l LitPumpkin) BreakInfo() BreakInfo {
|
||
|
|
return newBreakInfo(1, alwaysHarvestable, axeEffective, oneOf(l))
|
||
|
|
}
|
||
|
|
|
||
|
|
// EncodeItem ...
|
||
|
|
func (l LitPumpkin) EncodeItem() (name string, meta int16) {
|
||
|
|
return "minecraft:lit_pumpkin", 0
|
||
|
|
}
|
||
|
|
|
||
|
|
// EncodeBlock ...
|
||
|
|
func (l LitPumpkin) EncodeBlock() (name string, properties map[string]any) {
|
||
|
|
return "minecraft:lit_pumpkin", map[string]any{"minecraft:cardinal_direction": l.Facing.String()}
|
||
|
|
}
|
||
|
|
|
||
|
|
func allLitPumpkins() (pumpkins []world.Block) {
|
||
|
|
for i := cube.Direction(0); i <= 3; i++ {
|
||
|
|
pumpkins = append(pumpkins, LitPumpkin{Facing: i})
|
||
|
|
}
|
||
|
|
return
|
||
|
|
}
|