Documentation
¶
Index ¶
- Constants
- func ComputeBlockHash(blockName string, blockStates map[string]any) uint32
- func Fnv1a_32(data []byte) uint32
- func MarshalInternalData(key string, value any) []byte
- type BlockEntry
- type BlockRuntimeIDTable
- func (b *BlockRuntimeIDTable) AirRuntimeID() (runtimeID uint32)
- func (b *BlockRuntimeIDTable) FinaliseRegister()
- func (b *BlockRuntimeIDTable) RegisterCustomBlock(block define.BlockState) error
- func (b *BlockRuntimeIDTable) RegisterPermutation(blockName string, blockVersion int32, stateEnums []StateEnum) error
- func (b *BlockRuntimeIDTable) RuntimeIDToState(runtimeID uint32) (name string, properties map[string]any, found bool)
- func (b *BlockRuntimeIDTable) StateToRuntimeID(name string, properties map[string]any) (runtimeID uint32, found bool)
- func (b *BlockRuntimeIDTable) UseNetworkIDHashes() bool
- type StateEnum
Constants ¶
const ( FNV1_32_INIT uint32 = 0x811C9DC5 FNV1_PRIME_32 uint32 = 0x01000193 )
Variables ¶
This section is empty.
Functions ¶
func ComputeBlockHash ¶
ComputeBlockHash compute the hash of block whose name is blockName, and states is blockStates. This implement is edited from https://gist.github.com/Alemiz112/504d0f79feac7ef57eda174b668dd345.
func MarshalInternalData ¶
MarshalInternalData marshal map[string]any{key: value} to its NBT represent. Note that only the internal results are returned, and the outer ones are not included.
For example, if key is "12" whose bytes is []byte{49, 50}, and value is int32(7), then the return result is []byte{3, 2, 0, 49, 50, 7, 0, 0, 0} but not []byte{10, 0, 0, 3, 2, 0, 49, 50, 7, 0, 0, 0, 0}.
The explanation of the example:
- 3 => The type of value is TAG_Int (3)
- 2, 0 => The length of key ("12") is 2 (little endian represent)
- 49, 50 => The content of key ("12")
- 7, 0, 0, 0 => The little endian represent of value (7)
Types ¶
type BlockEntry ¶
type BlockEntry struct {
Block define.BlockState
RuntimeID uint32
}
BlockEntry holds a block with its runtime id.
type BlockRuntimeIDTable ¶
type BlockRuntimeIDTable struct {
// contains filtered or unexported fields
}
BlockRuntimeIDTable is a block runtime ID table that supports converting blocks between blocks themselves and their runtime IDs description.
func NewBlockRuntimeIDTable ¶
func NewBlockRuntimeIDTable(useNetworkIDHashes bool) *BlockRuntimeIDTable
NewBlockRuntimeIDTable returns a new BlockRuntimeIDTable. useNetworkIDHashes indicates whether the runtime IDs are the network ID hashes.
func NewBlockRuntimeIDTableFromStates ¶
func NewBlockRuntimeIDTableFromStates(blockStates []define.BlockState, useNetworkIDHashes bool) *BlockRuntimeIDTable
NewBlockRuntimeIDTableFromStates returns a new BlockRuntimeIDTable from the provided block states. The block states must be ordered by their runtime IDs. useNetworkIDHashes indicates whether the runtime IDs are the network ID hashes.
func NewEmptyBlockRuntimeIDTable ¶
func NewEmptyBlockRuntimeIDTable(useNetworkIDHashes bool) *BlockRuntimeIDTable
NewEmptyBlockRuntimeIDTable returns a new empty BlockRuntimeIDTable. useNetworkIDHashes indicates whether the runtime IDs are the network ID hashes.
func (*BlockRuntimeIDTable) AirRuntimeID ¶
func (b *BlockRuntimeIDTable) AirRuntimeID() (runtimeID uint32)
AirRuntimeID returns the runtime ID of the air block.
func (*BlockRuntimeIDTable) FinaliseRegister ¶
func (b *BlockRuntimeIDTable) FinaliseRegister()
FinaliseRegister is called after blocks have finished registering and the palette can be sorted and hashed.
func (*BlockRuntimeIDTable) RegisterCustomBlock ¶
func (b *BlockRuntimeIDTable) RegisterCustomBlock(block define.BlockState) error
RegisterCustomBlock registers a new custom block to the table. The function returns error if the block was already registered. Note that you MUST call FinaliseRegister atfer register all custom blocks.
func (*BlockRuntimeIDTable) RegisterPermutation ¶
func (b *BlockRuntimeIDTable) RegisterPermutation(blockName string, blockVersion int32, stateEnums []StateEnum) error
RegisterMultipleStates registers all block states of a custom block to the table.
stateEnums is a list of state enums that the block can have. Each element means a state key and its possible values.
The function returns error if any of the states was already registered.
Note that you MUST call FinaliseRegister after register all custom blocks.
func (*BlockRuntimeIDTable) RuntimeIDToState ¶
func (b *BlockRuntimeIDTable) RuntimeIDToState(runtimeID uint32) (name string, properties map[string]any, found bool)
RuntimeIDToState converts a runtime ID to a name and its state properties.
func (*BlockRuntimeIDTable) StateToRuntimeID ¶
func (b *BlockRuntimeIDTable) StateToRuntimeID(name string, properties map[string]any) (runtimeID uint32, found bool)
StateToRuntimeID converts a name and its state properties to a runtime ID.
func (*BlockRuntimeIDTable) UseNetworkIDHashes ¶
func (b *BlockRuntimeIDTable) UseNetworkIDHashes() bool
UseNetworkIDHashes returns if the block runtime IDs are using network hashes or not.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package intintmap is a fast int64 key -> int64 value map.
|
Package intintmap is a fast int64 key -> int64 value map. |