github.com/df-mc/dragonfly@v0.9.13/server/block/light.go (about) 1 package block 2 3 import ( 4 "github.com/df-mc/dragonfly/server/block/cube" 5 "github.com/df-mc/dragonfly/server/world" 6 ) 7 8 // Light is an invisible block that can produce any light level. 9 type Light struct { 10 empty 11 replaceable 12 transparent 13 flowingWaterDisplacer 14 15 // Level is the light level that the light block produces. It is a number from 0-15, where 15 is the 16 // brightest and 0 is no light at all. 17 Level int 18 } 19 20 // SideClosed ... 21 func (Light) SideClosed(cube.Pos, cube.Pos, *world.World) bool { 22 return false 23 } 24 25 // EncodeItem ... 26 func (l Light) EncodeItem() (name string, meta int16) { 27 return "minecraft:light_block", int16(l.Level) 28 } 29 30 // LightEmissionLevel ... 31 func (l Light) LightEmissionLevel() uint8 { 32 return uint8(l.Level) 33 } 34 35 // EncodeBlock ... 36 func (l Light) EncodeBlock() (name string, properties map[string]any) { 37 return "minecraft:light_block", map[string]any{"block_light_level": int32(l.Level)} 38 } 39 40 // allLight returns all possible light blocks. 41 func allLight() []world.Block { 42 m := make([]world.Block, 0, 16) 43 for i := 0; i < 16; i++ { 44 m = append(m, Light{Level: i}) 45 } 46 return m 47 }