Documentation ¶
Index ¶
- Constants
- type BitStorage
- type BlockPos
- type Chunk
- type Column
- type ColumnPos
- type GlobalPalette
- type IO
- type ListPalette
- type MapPalette
- type Palette
- type Reader
- func (r *Reader) Bool(x *bool)
- func (r *Reader) ByteSlice(x *[]byte)
- func (r *Reader) Bytes(b *[]byte)
- func (r *Reader) Chunk(x *Chunk)
- func (r *Reader) Float32(x *float32)
- func (r *Reader) Float64(x *float64)
- func (r *Reader) Int16(x *int16)
- func (r *Reader) Int32(x *int32)
- func (r *Reader) Int64(x *int64)
- func (r *Reader) NBT(x *map[string]interface{})
- func (r *Reader) String(x *string)
- func (r *Reader) Text(x *text.Text)
- func (r *Reader) UUID(x *uuid.UUID)
- func (r *Reader) Uint8(x *uint8)
- func (r *Reader) Varint32(x *int32)
- func (r *Reader) Varint64(x *int64)
- type Writer
- func (w *Writer) Bool(x *bool)
- func (w *Writer) ByteSlice(x *[]byte)
- func (w *Writer) Bytes(x *[]byte)
- func (w *Writer) Chunk(x *Chunk)
- func (w *Writer) Float32(x *float32)
- func (w *Writer) Float64(x *float64)
- func (w *Writer) Int16(x *int16)
- func (w *Writer) Int32(x *int32)
- func (w *Writer) Int64(x *int64)
- func (w *Writer) NBT(x *map[string]interface{})
- func (w *Writer) String(x *string)
- func (w *Writer) Text(x *text.Text)
- func (w *Writer) UUID(x *uuid.UUID)
- func (w *Writer) Uint8(x *uint8)
- func (w *Writer) Varint32(x *int32)
- func (w *Writer) Varint64(x *int64)
Constants ¶
const ( // CurrentProtocol is the current protocol version for the version below. CurrentProtocol = 756 // CurrentMinecraftVersion is the current version of Minecraft. CurrentMinecraftVersion = "1.17.1" // CurrentVersion is the current version of Expresso. CurrentVersion = "Expresso v0.1.0" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BitStorage ¶
type BitStorage struct {
// contains filtered or unexported fields
}
BitStorage implements the compacted data storage format used in chunks since Minecraft v1.16. https://wiki.vg/Chunk_Format
func NewBitStorageWithData ¶
func NewBitStorageWithData(bitsPerEntry int32, size int32, data []int64) (*BitStorage, error)
NewBitStorageWithData creates a new BitStorage instance with the provided data.
func NewEmptyBitStorage ¶
func NewEmptyBitStorage(bitsPerEntry int32, size int32) *BitStorage
NewEmptyBitStorage creates a new empty BitStorage.
func (*BitStorage) Get ¶
func (b *BitStorage) Get(index int32) (int32, error)
Get returns the value at the given index.
func (*BitStorage) Set ¶
func (b *BitStorage) Set(index, value int32) error
Set sets the value at the given index.
type Chunk ¶
type Chunk struct {
// contains filtered or unexported fields
}
Chunk is an implementation of the modern Minecraft chunk.
func (*Chunk) GetBlockState ¶
GetBlockState returns the block state at the given position.
func (*Chunk) SetBlockState ¶
SetBlockState sets the block state at the given position.
type Column ¶
type Column struct { // Position is the position of the column. Position ColumnPos // Chunks contain all chunks associated with the column. Chunks map[int32]*Chunk // Tiles contains all tile entities associated with the column. Tiles []map[string]interface{} // HeightMaps contains all height maps associated with the column. HeightMaps map[string]interface{} // Biomes contains all biomes associated with the column. Biomes []int32 }
Column represents a chunk column, which contains chunk data, the chunk position, biomes, and other useful information for the client.
func (*Column) GetBlockState ¶
GetBlockState returns the state ID of a block position.
type GlobalPalette ¶
type GlobalPalette struct{}
GlobalPalette is a global palette that maps one to one.
func NewGlobalPalette ¶
func NewGlobalPalette() *GlobalPalette
NewGlobalPalette returns a new global palette.
func (*GlobalPalette) IDToState ¶
func (*GlobalPalette) IDToState(id int32) int32
IDToState converts the storage ID to a block state. If it is not mapped, then it will return false as it's second return value.
func (*GlobalPalette) Size ¶
func (*GlobalPalette) Size() int32
Size returns the known number of block states in the palette.
func (*GlobalPalette) StateToID ¶
func (*GlobalPalette) StateToID(state int32) int32
StateToID converts the block state to a storage ID. If it is not mapped, then the palette will attempt to map it. If all else fails, it will return false as it's second return value.
type IO ¶
type IO interface { // Uint8 reads/writes an uint8 from/to the underlying buffer. Uint8(x *uint8) // Int16 reads/writes an int16 from/to the underlying buffer. Int16(x *int16) // Int32 reads/writes an int32 from/to the underlying buffer. Int32(x *int32) // Int64 reads/writes an int64 from/to the underlying buffer. Int64(x *int64) // Float32 reads/writes a float32 from/to the underlying buffer. Float32(x *float32) // Float64 reads/writes a float64 from/to the underlying buffer. Float64(x *float64) // Varint32 reads/writes a variable int32 from/to the underlying buffer. Varint32(x *int32) // Varint64 reads/writes a variable int64 from/to the underlying buffer. Varint64(x *int64) // ByteSlice reads/writes a byte slice from the underlying buffer, similarly to String. ByteSlice(x *[]byte) // Bytes reads all remaining bytes in the reader, or appends the bytes to the buffer if it is a writer. Bytes(b *[]byte) // Bool reads/writes a bool as either 0x00 or 0x01 to the underlying buffer. Bool(x *bool) // String reads/writes a string, prefixed with a variable int32, from/to the underlying buffer. String(x *string) // UUID reads/writes a UUID from/to the underlying buffer. UUID(x *uuid.UUID) // Text reads/writes Minecraft-style text from/to the underlying buffer. Text(x *text.Text) // Chunk reads/writes a chunk from/to the underlying buffer. Chunk(x *Chunk) // NBT reads/writes a map as a compound tag from/to the underlying buffer. NBT(x *map[string]interface{}) }
IO is implemented by Writer and Reader.
type ListPalette ¶
type ListPalette struct {
// contains filtered or unexported fields
}
ListPalette is a palette backed by a list.
func NewListPalette ¶
func NewListPalette(bitsPerEntry int32) *ListPalette
NewListPalette returns a new list palette.
func NewListPaletteFromReader ¶
func NewListPaletteFromReader(bitsPerEntry int32, reader *Reader) *ListPalette
NewListPaletteFromReader returns a new list palette from the given reader.
func (*ListPalette) IDToState ¶
func (p *ListPalette) IDToState(id int32) int32
IDToState converts the storage ID to a block state. If it is not mapped, then it will return false as it's second return value.
func (*ListPalette) Size ¶
func (p *ListPalette) Size() int32
Size returns the known number of block states in the palette.
func (*ListPalette) StateToID ¶
func (p *ListPalette) StateToID(state int32) (id int32)
StateToID converts the block state to a storage ID. If it is not mapped, then the palette will attempt to map it. If all else fails, it will return false as it's second return value.
type MapPalette ¶
type MapPalette struct {
// contains filtered or unexported fields
}
MapPalette is a palette backed by a map.
func NewMapPalette ¶
func NewMapPalette(bitsPerEntry int32) *MapPalette
NewMapPalette returns a new map palette.
func NewMapPaletteFromReader ¶
func NewMapPaletteFromReader(bitsPerEntry int32, reader *Reader) *MapPalette
NewMapPaletteFromReader returns a new map palette from the given reader.
func (*MapPalette) IDToState ¶
func (p *MapPalette) IDToState(id int32) int32
IDToState converts the storage ID to a block state. If it is not mapped, then it will return false as it's second return value.
func (*MapPalette) Size ¶
func (p *MapPalette) Size() int32
Size returns the known number of block states in the palette.
func (*MapPalette) StateToID ¶
func (p *MapPalette) StateToID(state int32) int32
StateToID converts the block state to a storage ID. If it is not mapped, then the palette will attempt to map it. If all else fails, it will return false as it's second return value.
type Palette ¶
type Palette interface { // Size returns the known number of block states in the palette. Size() int32 // StateToID converts the block state to a storage ID. If it is not mapped, then the palette will attempt // to map it. If all else fails, it will return -1. StateToID(state int32) int32 // IDToState converts the storage ID to a block state. If it is not mapped, then it will return -1. IDToState(id int32) int32 }
Palette is a palette implementation for mapping block states to storage IDs.
type Reader ¶
Reader is an instance of a protocol reader.
func (*Reader) ByteSlice ¶
ByteSlice reads a byte slice from the underlying buffer, similarly to String.
func (*Reader) String ¶
String reads a string, prefixed with a variable int32, from the underlying buffer.
type Writer ¶
Writer is an instance of a protocol writer.
func (*Writer) ByteSlice ¶
ByteSlice writes a []byte, prefixed with a variable int32, to the underlying buffer.
func (*Writer) String ¶
String writes a string, prefixed with a variable int32, to the underlying buffer.