github.com/df-mc/dragonfly@v0.9.13/server/block/lit_pumpkin.go (about)

     1  package block
     2  
     3  import (
     4  	"github.com/df-mc/dragonfly/server/block/cube"
     5  	"github.com/df-mc/dragonfly/server/item"
     6  	"github.com/df-mc/dragonfly/server/world"
     7  	"github.com/go-gl/mathgl/mgl64"
     8  )
     9  
    10  // LitPumpkin is a decorative light emitting block crafted with a Carved Pumpkin & Torch
    11  type LitPumpkin struct {
    12  	solid
    13  
    14  	// Facing is the direction the pumpkin is facing.
    15  	Facing cube.Direction
    16  }
    17  
    18  // LightEmissionLevel ...
    19  func (l LitPumpkin) LightEmissionLevel() uint8 {
    20  	return 15
    21  }
    22  
    23  // UseOnBlock ...
    24  func (l LitPumpkin) UseOnBlock(pos cube.Pos, face cube.Face, _ mgl64.Vec3, w *world.World, user item.User, ctx *item.UseContext) (used bool) {
    25  	pos, _, used = firstReplaceable(w, pos, face, l)
    26  	if !used {
    27  		return
    28  	}
    29  	l.Facing = user.Rotation().Direction().Opposite()
    30  
    31  	place(w, pos, l, user, ctx)
    32  	return placed(ctx)
    33  }
    34  
    35  // BreakInfo ...
    36  func (l LitPumpkin) BreakInfo() BreakInfo {
    37  	return newBreakInfo(1, alwaysHarvestable, axeEffective, oneOf(l))
    38  }
    39  
    40  // EncodeItem ...
    41  func (l LitPumpkin) EncodeItem() (name string, meta int16) {
    42  	return "minecraft:lit_pumpkin", 0
    43  }
    44  
    45  // EncodeBlock ...
    46  func (l LitPumpkin) EncodeBlock() (name string, properties map[string]any) {
    47  	return "minecraft:lit_pumpkin", map[string]any{"minecraft:cardinal_direction": l.Facing.String()}
    48  }
    49  
    50  func allLitPumpkins() (pumpkins []world.Block) {
    51  	for i := cube.Direction(0); i <= 3; i++ {
    52  		pumpkins = append(pumpkins, LitPumpkin{Facing: i})
    53  	}
    54  	return
    55  }