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

Method setBlockState

server/world/chunk/section/section.go:83–93  ·  view source on GitHub ↗

Sets the block at the position to the index in the palette. Errors if the state is bigger than the length of the palette or negative X, Y, Z should be relative to the chunk section (AKA x&0x0f, y&0x0f, z&0x0f)

(x, y, z byte, state int64)

Source from the content-addressed store, hash-verified

81// Sets the block at the position to the index in the palette. Errors if the state is bigger than the length of the palette or negative
82// X, Y, Z should be relative to the chunk section (AKA x&0x0f, y&0x0f, z&0x0f)
83func (s *Section) setBlockState(x, y, z byte, state int64) error {
84 if state < 0 || len(s.BlockStates.Data) <= int(state) {
85 return fmt.Errorf("block state not in palette")
86 }
87 long, off := s.offset(int(x), int(y), int(z))
88 mask := int64(^((1<<s.blockBitsPerEntry - 1) << off))
89
90 s.BlockStates.Data[long] &= mask
91 s.BlockStates.Data[long] |= state << off
92 return nil
93}
94
95// Sets the block at the position and returns its new state (index in the block palette). Resizes the palette if needed
96// X, Y, Z should be relative to the chunk section (AKA x&0x0f, y&0x0f, z&0x0f)

Callers 1

SetBlockMethod · 0.95

Calls 1

offsetMethod · 0.95

Tested by

no test coverage detected