place blocks
This commit is contained in:
@@ -19,7 +19,7 @@ const (
|
||||
// BlockAppearance describes basic appearance of a kind of block.
|
||||
type BlockAppearance struct {
|
||||
Name string // A short name, like "stone" or "dirt", used for texture lookups
|
||||
Transparent bool // Is block transparent?
|
||||
Transparent bool // Is block transparent, i.e., does not block nearby blocks in rendering?
|
||||
NotSolid bool // Is block not solid, i.e., has no hitbox at all? (this makes the zero value reasonable)
|
||||
Light int // The light level it emits, 0 is none
|
||||
|
||||
@@ -72,6 +72,9 @@ type BlockBehaviour interface {
|
||||
//
|
||||
// Return true if this block also changed state, false otherwise.
|
||||
BlockUpdate(position itype.Vec3i, aux int, data itype.Dataset, world *World) bool
|
||||
|
||||
// Break is called when the block is broken by natural means.
|
||||
Break(position itype.Vec3i, aux int, data itype.Dataset, world *World)
|
||||
}
|
||||
|
||||
type blockBehaviourStatic struct {
|
||||
@@ -87,6 +90,7 @@ func (b blockBehaviourStatic) Appearance(position itype.Vec3i, aux int, data ity
|
||||
func (blockBehaviourStatic) BlockUpdate(position itype.Vec3i, aux int, data itype.Dataset, world *World) bool {
|
||||
return false
|
||||
}
|
||||
func (blockBehaviourStatic) Break(position itype.Vec3i, aux int, data itype.Dataset, world *World) {}
|
||||
|
||||
// BlockBehaviourStatic returns a Static BlockBehaviour that has the given BlockAppearance.
|
||||
func BlockBehaviourStatic(app BlockAppearance) BlockBehaviour {
|
||||
@@ -172,6 +176,9 @@ type Block struct {
|
||||
// Appearance is a shortcut for Behaviour.Appearance().
|
||||
// It returns the Appearance of the block with the given parameters.
|
||||
func (b Block) Appearance(position itype.Vec3i) BlockAppearance {
|
||||
if b.Behaviour == nil {
|
||||
return BlockAppearance{}
|
||||
}
|
||||
app := b.Behaviour.Appearance(position, b.Aux, b.Dataset, b.World)
|
||||
if !app.NotSolid && len(app.Hitbox) == 0 {
|
||||
app.Hitbox = []itype.Boxd{{
|
||||
|
||||
Reference in New Issue
Block a user