MCPcopy Create free account
hub / github.com/ZeppelinMC/Zeppelin / SetSkylightLevel

Method SetSkylightLevel

server/world/chunk/section/section.go:163–184  ·  view source on GitHub ↗
(x, y, z int, level byte)

Source from the content-addressed store, hash-verified

161}
162
163func (s *Section) SetSkylightLevel(x, y, z int, level byte) error {
164 if level > 0x0F {
165 return fmt.Errorf("light level must not exceed 4 bits (15)")
166 }
167 index := (y << 8) | (z << 4) | x
168 if index < 0 || int(index) > len(s.SkyLight) {
169 return fmt.Errorf("light index exceeds light length")
170 }
171
172 var mask uint8 = 0x0f
173 if math.Remainder(float64(index), 2) != 0 {
174 mask = 0xf0
175 level <<= 4
176 }
177
178 index /= 2
179
180 s.SkyLight[index] = s.SkyLight[index] & ^int8(mask)
181 s.SkyLight[index] |= int8(level)
182
183 return nil
184}
185
186func blockBitsPerEntry(paletteSize int) int {
187 ln := bits.Len32(uint32(paletteSize) - 1)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected