Documentation
¶
Index ¶
- func FuncIOSlice[T any, S ~*[]T](r IO, x S, f func(IO, *T))
- func FuncIOSliceOfLen[T any, S ~*[]T](r IO, l uint32, x S, f func(IO, *T))
- func FuncIOSliceUint32Length[T any, S ~*[]T](r IO, x S, f func(IO, *T))
- func FuncSlice[T any, S ~*[]T](r IO, x S, f func(*T))
- func FuncSliceOfLen[T any, S ~*[]T](r IO, l uint32, x S, f func(*T))
- func FuncSliceUint16Length[T any, S ~*[]T](r IO, x S, f func(*T))
- func FuncSliceUint32Length[T any, S ~*[]T](r IO, x S, f func(*T))
- func FuncSliceVarint32Length[T any, S ~*[]T](r IO, x S, f func(*T))
- func IDOrXFunc[T any](r IO, x *IDOrX[T], f func(*T))
- func IDOrXMarshaler[T any, A PtrMarshaler[T]](r IO, x *IDOrX[T])
- func OptionalFunc[T any](r IO, x *Optional[T], f func(*T)) any
- func OptionalFuncIO[T any](r IO, x *Optional[T], f func(IO, *T)) any
- func OptionalMarshaler[T any, A PtrMarshaler[T]](r IO, x *Optional[T])
- func OptionalPointerMarshaler[T any, A PtrMarshaler[T]](r IO, x *Optional[*T])
- func OptionalSlice[T any, S ~[]T](r IO, x *Optional[S], f func(*T)) any
- func OptionalSliceMarshaler[T any, S ~[]T, A PtrMarshaler[T]](r IO, x *Optional[S]) any
- func Single[T any, S PtrMarshaler[T]](r IO, x S)
- func Slice[T any, S ~*[]T, A PtrMarshaler[T]](r IO, x S)
- func SliceOfLen[T any, S ~*[]T, A PtrMarshaler[T]](r IO, l uint32, x S)
- func SliceUint16Length[T any, S ~*[]T, A PtrMarshaler[T]](r IO, x S)
- func SliceUint32Length[T any, S ~*[]T, A PtrMarshaler[T]](r IO, x S)
- func SliceUint8Length[T any, S *[]T, A PtrMarshaler[T]](r IO, x S)
- func SliceVarint32Length[T any, S ~*[]T, A PtrMarshaler[T]](r IO, x S)
- type ChestSlot
- type CommandBlockData
- type IDOrX
- type IO
- type Marshaler
- type Optional
- type PtrMarshaler
- type Reader
- func (r *Reader) Angle(x *float32)
- func (r *Reader) Bool(x *bool)
- func (r *Reader) Bytes(p *[]byte)
- func (r *Reader) CString(x *string)
- func (r *Reader) InvalidValue(value any, forField, reason string)
- func (r *Reader) NBT(m *map[string]any, encoding nbt.Encoding)
- func (r *Reader) NBTList(m *[]any, encoding nbt.Encoding)
- func (r *Reader) NBTString(s *string, encoding nbt.Encoding)
- func (r *Reader) RGB(x *color.RGBA)
- func (r *Reader) RGBA(x *color.RGBA)
- func (r *Reader) String(x *string)
- func (r *Reader) UUID(x *uuid.UUID)
- func (r *Reader) UnknownEnumOption(value any, enum string)
- func (r *Reader) Vec3(x *mgl32.Vec3)
- func (r *Reader) Vec4(x *mgl32.Vec4)
- type Writer
- func (w *Writer) Angle(x *float32)
- func (w *Writer) Bool(x *bool)
- func (w *Writer) Bytes(x *[]byte)
- func (w *Writer) CString(x *string)
- func (w *Writer) InvalidValue(value any, forField, reason string)
- func (w *Writer) NBT(x *map[string]any, encoding nbt.Encoding)
- func (w *Writer) NBTList(x *[]any, encoding nbt.Encoding)
- func (w *Writer) NBTString(x *string, encoding nbt.Encoding)
- func (w *Writer) RGB(x *color.RGBA)
- func (w *Writer) RGBA(x *color.RGBA)
- func (w *Writer) String(x *string)
- func (w *Writer) UUID(x *uuid.UUID)
- func (w *Writer) UnknownEnumOption(value any, enum string)
- func (w *Writer) Vec3(x *mgl32.Vec3)
- func (w *Writer) Vec4(x *mgl32.Vec4)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FuncIOSlice ¶
FuncIOSlice reads/writes a slice of T using a function f with a varuint32 length prefix.
func FuncIOSliceOfLen ¶
FuncIOSliceOfLen reads/writes the elements of a slice of type T with length l using func f.
func FuncIOSliceUint32Length ¶
FuncIOSliceUint32Length reads/writes a slice of T using a function with a uint32 length prefix.
func FuncSlice ¶
FuncSlice reads/writes a slice of T using function f with a varuint32 length prefix.
func FuncSliceOfLen ¶
FuncSliceOfLen reads/writes the elements of a slice of type T with length l using func f.
func FuncSliceUint16Length ¶
FuncSliceUint16Length reads/writes a slice of T using function f with a uint16 length prefix.
func FuncSliceUint32Length ¶
FuncSliceUint32Length reads/writes a slice of T using function f with a uint32 length prefix.
func FuncSliceVarint32Length ¶
FuncSliceVarint32Length reads/writes a slice of T with a varint32 prefix.
func IDOrXMarshaler ¶
func IDOrXMarshaler[T any, A PtrMarshaler[T]](r IO, x *IDOrX[T])
IDOrXMarshaler reads/writes an Optional assuming *T implements Marshaler.
func OptionalFunc ¶
OptionalFunc reads/writes an Optional[T].
func OptionalFuncIO ¶
OptionalFuncIO reads/writes an Optional[T].
func OptionalMarshaler ¶
func OptionalMarshaler[T any, A PtrMarshaler[T]](r IO, x *Optional[T])
OptionalMarshaler reads/writes an Optional assuming *T implements Marshaler.
func OptionalPointerMarshaler ¶
func OptionalPointerMarshaler[T any, A PtrMarshaler[T]](r IO, x *Optional[*T])
OptionalPointerMarshaler reads/writes an Optional assuming *T implements Marshaler.
func OptionalSlice ¶
OptionalSlice reads/writes an Optional[S]. Note that:
- S must be a slice that satisfy []T.
- f is used to read/write T.
func OptionalSliceMarshaler ¶
func OptionalSliceMarshaler[T any, S ~[]T, A PtrMarshaler[T]](r IO, x *Optional[S]) any
OptionalSliceFunc reads/writes an Optional[S]. Note that:
- S must be a slice that satisfy []T.
- T must have implements Marshaler.
func Single ¶
func Single[T any, S PtrMarshaler[T]](r IO, x S)
Single reads/writes a single Marshaler x.
func Slice ¶
func Slice[T any, S ~*[]T, A PtrMarshaler[T]](r IO, x S)
Slice reads/writes a slice of T with a varuint32 prefix.
func SliceOfLen ¶
func SliceOfLen[T any, S ~*[]T, A PtrMarshaler[T]](r IO, l uint32, x S)
SliceOfLen reads/writes the elements of a slice of type T with length l.
func SliceUint16Length ¶
func SliceUint16Length[T any, S ~*[]T, A PtrMarshaler[T]](r IO, x S)
SliceUint16Length reads/writes a slice of T with a uint16 prefix.
func SliceUint32Length ¶
func SliceUint32Length[T any, S ~*[]T, A PtrMarshaler[T]](r IO, x S)
SliceUint32Length reads/writes a slice of T with a uint32 prefix.
func SliceUint8Length ¶
func SliceUint8Length[T any, S *[]T, A PtrMarshaler[T]](r IO, x S)
SliceUint8Length reads/writes a slice of T with a uint8 prefix.
func SliceVarint32Length ¶
func SliceVarint32Length[T any, S ~*[]T, A PtrMarshaler[T]](r IO, x S)
SliceVarint32Length reads/writes a slice of T with a varint32 prefix.
Types ¶
type CommandBlockData ¶
type CommandBlockData struct {
Mode uint32
Command string
CustomName string
LastOutput string
TickDelay int32
ExecuteOnFirstTick bool
TrackOutput bool
Conditional bool
NeedsRedstone bool
}
CommandBlockData ..
func (*CommandBlockData) Marshal ¶
func (c *CommandBlockData) Marshal(io IO)
type IDOrX ¶
type IDOrX[T any] struct { // 0 if value of type X is given inline; // otherwise registry ID + 1. ID int32 // Only present if ID is 0. Value T }
IDOrX is `ID or X` data type in the protocol.
type IO ¶
type IO interface {
Uint32(x *uint32)
Uint64(x *uint64)
Varuint64(x *uint64)
Varuint32(x *uint32)
Varuint16(x *uint16)
Varint16(x *int16)
Bool(x *bool)
Int8(x *int8)
Uint8(x *uint8)
Int16(x *int16)
Uint16(x *uint16)
Int32(x *int32)
Int64(x *int64)
Float32(x *float32)
Float64(x *float64)
String(x *string)
CString(x *string)
Varint32(x *int32)
Varint64(x *int64)
Angle(x *float32)
UUID(x *uuid.UUID)
NBT(m *map[string]any, encoding nbt.Encoding)
NBTList(m *[]any, encoding nbt.Encoding)
NBTString(s *string, encoding nbt.Encoding)
Vec3(x *mgl32.Vec3)
Vec4(x *mgl32.Vec4)
RGB(x *color.RGBA)
RGBA(x *color.RGBA)
Bytes(x *[]byte)
UnknownEnumOption(value any, enum string)
InvalidValue(value any, forField, reason string)
}
IO represents a packet IO direction that based on BasicIO.
Implementations of this interface are Reader and Writer.
Reader reads data from the input stream into the pointers passed, whereas Writer writes the values the pointers point point to the output stream.
type Marshaler ¶
type Marshaler interface {
Marshal(r IO)
}
Marshaler is a type that can be written to or read from an IO.
type Optional ¶
type Optional[T any] struct { // contains filtered or unexported fields }
Optional is an optional type in the protocol. If not set, only a false bool is written. If set, a true bool is written and the Marshaler.
type PtrMarshaler ¶
PtrMarshaler represents a type that implements Marshaler for its pointer.
type Reader ¶
type Reader struct {
*basic_encoding.BasicReader
}
Reader implements reading operations for reading types from Minecraft packets.
Each Packet implementation has one passed to it.
Reader's uses should always be encapsulated with a deferred recovery. Reader panics on invalid data.
func NewReader ¶
func NewReader(r interface {
io.Reader
io.ByteReader
}) *Reader
NewReader creates a new Reader using the io.ByteReader passed as underlying source to read bytes from.
func (*Reader) CString ¶
CString reads a C string which ended with byte 0 from the underlying buffer.
func (*Reader) InvalidValue ¶
InvalidValue panics with an error indicating that the value passed is not valid for a specific field.
func (*Reader) UnknownEnumOption ¶
UnknownEnumOption panics with an unknown enum option error.
type Writer ¶
type Writer struct {
*basic_encoding.BasicWriter
}
Writer implements writing methods for data types from Minecraft packets.
Each Packet implementation has one passed to it when writing.
Writer implements methods where values are passed using a pointer, so that Reader and Writer have a synonymous interface and both implement the IO interface.
func NewWriter ¶
NewWriter creates a new initialised Writer with an underlying io.ByteWriter to write to.
func (*Writer) CString ¶
CString writes a C string, which ended with byte 0, to the underlying buffer.
func (*Writer) InvalidValue ¶
InvalidValue panics with an invalid value error.
func (*Writer) NBTList ¶
NBTList writes a slice as NBT to the underlying buffer using the encoding passed.
func (*Writer) NBTString ¶
NBTString writes a string as NBT to the underlying buffer using the encoding passed.
func (*Writer) UnknownEnumOption ¶
UnknownEnumOption panics with an unknown enum option error.