Documentation
¶
Index ¶
- type IncomingPacket
- func (p *IncomingPacket) CopyBool() bool
- func (p *IncomingPacket) CopyByte() byte
- func (p *IncomingPacket) CopyDouble() float64
- func (p *IncomingPacket) CopyFloat() float32
- func (p *IncomingPacket) CopyInt() int32
- func (p *IncomingPacket) CopyItem() *pb.Item
- func (p *IncomingPacket) CopyLong() uint64
- func (p *IncomingPacket) CopyNullString() string
- func (p *IncomingPacket) CopyPosition() (int32, int32, int32)
- func (p *IncomingPacket) CopyProtocolString() string
- func (p *IncomingPacket) CopyRemainingBytes() []byte
- func (p *IncomingPacket) CopyShort() int16
- func (p *IncomingPacket) CopyUUID() util.UUID
- func (p *IncomingPacket) CopyVarInt() int32
- func (p *IncomingPacket) ID() int32
- func (p *IncomingPacket) NewID() packet.Serverbound
- func (p *IncomingPacket) ReadBool() bool
- func (p *IncomingPacket) ReadByte() byte
- func (p *IncomingPacket) ReadBytes(num int32) []byte
- func (p *IncomingPacket) ReadDouble() float64
- func (p *IncomingPacket) ReadFloat() float32
- func (p *IncomingPacket) ReadInt() int32
- func (p *IncomingPacket) ReadItem() *pb.Item
- func (p *IncomingPacket) ReadLong() uint64
- func (p *IncomingPacket) ReadNBT() *nbt.Tag
- func (p *IncomingPacket) ReadNullString() string
- func (p *IncomingPacket) ReadPosition() (int32, int32, int32)
- func (p *IncomingPacket) ReadProtocolString() string
- func (p *IncomingPacket) ReadRemainingBytes() []byte
- func (p *IncomingPacket) ReadShort() int16
- func (p *IncomingPacket) ReadUUID() util.UUID
- func (p *IncomingPacket) ReadVarInt() int32
- func (p *IncomingPacket) SetID(id packet.Serverbound)
- func (p *IncomingPacket) SetVersion(version packet.Version)
- func (p *IncomingPacket) WriteBool(value bool)
- func (p *IncomingPacket) WriteByte(value byte)
- func (p *IncomingPacket) WriteBytes(value []byte)
- func (p *IncomingPacket) WriteDouble(value float64)
- func (p *IncomingPacket) WriteFloat(value float32)
- func (p *IncomingPacket) WriteInt(value int32)
- func (p *IncomingPacket) WriteItem(item *pb.Item)
- func (p *IncomingPacket) WriteLong(value uint64)
- func (p *IncomingPacket) WriteNullString(value string)
- func (p *IncomingPacket) WritePosition(x, y, z int32)
- func (p *IncomingPacket) WriteProtocolString(value string)
- func (p *IncomingPacket) WriteShort(value int16)
- func (p *IncomingPacket) WriteUUID(value util.UUID)
- type OutgoingPacket
- func (p *OutgoingPacket) GetData(zlib_writer *zlib.Writer, compression int32) ([]byte, error)
- func (p *OutgoingPacket) ID() packet.Clientbound
- func (p *OutgoingPacket) OldID() int32
- func (p *OutgoingPacket) SetVersion(v packet.Version)
- func (p *OutgoingPacket) WriteBool(v bool)
- func (p *OutgoingPacket) WriteByte(v byte)
- func (p *OutgoingPacket) WriteByteArray(v []byte)
- func (p *OutgoingPacket) WriteDouble(v float64)
- func (p *OutgoingPacket) WriteFixedFloat(v float64)
- func (p *OutgoingPacket) WriteFloat(v float32)
- func (p *OutgoingPacket) WriteInt(v int32)
- func (p *OutgoingPacket) WriteItem(value *pb.Item)
- func (p *OutgoingPacket) WriteLong(v uint64)
- func (p *OutgoingPacket) WriteNullString(v string)
- func (p *OutgoingPacket) WritePosition(v uint64)
- func (p *OutgoingPacket) WriteShort(v uint16)
- func (p *OutgoingPacket) WriteString(v string)
- func (p *OutgoingPacket) WriteUUID(v util.UUID)
- func (p *OutgoingPacket) WriteVarInt(v int32)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type IncomingPacket ¶
type IncomingPacket struct { // Protobuf that this packet represents Proto *pb.Packet // Will be set if anything goes wrong Err error // contains filtered or unexported fields }
func NewIncomingPacket ¶
func NewIncomingPacket(data []byte) *IncomingPacket
This takes in a packet, without the length varint. It is assumed that data is the entire packet, as this function does not know the length of the packet. Data should include the varint for the id at the start. This means that this function should be used for both compressed and uncompressed packets; other code should deal with decompression.
func (*IncomingPacket) CopyBool ¶
func (p *IncomingPacket) CopyBool() bool
func (*IncomingPacket) CopyByte ¶
func (p *IncomingPacket) CopyByte() byte
func (*IncomingPacket) CopyDouble ¶
func (p *IncomingPacket) CopyDouble() float64
func (*IncomingPacket) CopyFloat ¶
func (p *IncomingPacket) CopyFloat() float32
func (*IncomingPacket) CopyInt ¶
func (p *IncomingPacket) CopyInt() int32
func (*IncomingPacket) CopyItem ¶
func (p *IncomingPacket) CopyItem() *pb.Item
func (*IncomingPacket) CopyLong ¶
func (p *IncomingPacket) CopyLong() uint64
func (*IncomingPacket) CopyNullString ¶
func (p *IncomingPacket) CopyNullString() string
func (*IncomingPacket) CopyPosition ¶
func (p *IncomingPacket) CopyPosition() (int32, int32, int32)
func (*IncomingPacket) CopyProtocolString ¶
func (p *IncomingPacket) CopyProtocolString() string
func (*IncomingPacket) CopyRemainingBytes ¶
func (p *IncomingPacket) CopyRemainingBytes() []byte
func (*IncomingPacket) CopyShort ¶
func (p *IncomingPacket) CopyShort() int16
func (*IncomingPacket) CopyUUID ¶
func (p *IncomingPacket) CopyUUID() util.UUID
func (*IncomingPacket) CopyVarInt ¶
func (p *IncomingPacket) CopyVarInt() int32
func (*IncomingPacket) ID ¶
func (p *IncomingPacket) ID() int32
Returns old packet id. Should be converted using a packet.Spec.
func (*IncomingPacket) NewID ¶
func (p *IncomingPacket) NewID() packet.Serverbound
Returns the grpc packet id. Will return 0 if SetID has not been called.
func (*IncomingPacket) ReadBool ¶
func (p *IncomingPacket) ReadBool() bool
func (*IncomingPacket) ReadByte ¶
func (p *IncomingPacket) ReadByte() byte
func (*IncomingPacket) ReadBytes ¶
func (p *IncomingPacket) ReadBytes(num int32) []byte
func (*IncomingPacket) ReadDouble ¶
func (p *IncomingPacket) ReadDouble() float64
func (*IncomingPacket) ReadFloat ¶
func (p *IncomingPacket) ReadFloat() float32
func (*IncomingPacket) ReadInt ¶
func (p *IncomingPacket) ReadInt() int32
func (*IncomingPacket) ReadItem ¶
func (p *IncomingPacket) ReadItem() *pb.Item
func (*IncomingPacket) ReadLong ¶
func (p *IncomingPacket) ReadLong() uint64
func (*IncomingPacket) ReadNBT ¶
func (p *IncomingPacket) ReadNBT() *nbt.Tag
func (*IncomingPacket) ReadNullString ¶
func (p *IncomingPacket) ReadNullString() string
func (*IncomingPacket) ReadPosition ¶
func (p *IncomingPacket) ReadPosition() (int32, int32, int32)
func (*IncomingPacket) ReadProtocolString ¶
func (p *IncomingPacket) ReadProtocolString() string
func (*IncomingPacket) ReadRemainingBytes ¶
func (p *IncomingPacket) ReadRemainingBytes() []byte
func (*IncomingPacket) ReadShort ¶
func (p *IncomingPacket) ReadShort() int16
func (*IncomingPacket) ReadUUID ¶
func (p *IncomingPacket) ReadUUID() util.UUID
func (*IncomingPacket) ReadVarInt ¶
func (p *IncomingPacket) ReadVarInt() int32
func (*IncomingPacket) SetID ¶
func (p *IncomingPacket) SetID(id packet.Serverbound)
Should be used rarely. This will change the packet id that the server recieves. This should only be used when a packet can be parsed as seperate packets. For example, in 1.8, a block place packet can be a use item packet, depending on the fields. This is the only situation this should be used. Other than that, you should rely on the registry to set the packet ids.
func (*IncomingPacket) SetVersion ¶
func (p *IncomingPacket) SetVersion(version packet.Version)
Changes the way some values are parsed. Specifically, positions and items have changed between versions.
func (*IncomingPacket) WriteBool ¶
func (p *IncomingPacket) WriteBool(value bool)
func (*IncomingPacket) WriteByte ¶
func (p *IncomingPacket) WriteByte(value byte)
func (*IncomingPacket) WriteBytes ¶
func (p *IncomingPacket) WriteBytes(value []byte)
func (*IncomingPacket) WriteDouble ¶
func (p *IncomingPacket) WriteDouble(value float64)
func (*IncomingPacket) WriteFloat ¶
func (p *IncomingPacket) WriteFloat(value float32)
func (*IncomingPacket) WriteInt ¶
func (p *IncomingPacket) WriteInt(value int32)
func (*IncomingPacket) WriteItem ¶
func (p *IncomingPacket) WriteItem(item *pb.Item)
func (*IncomingPacket) WriteLong ¶
func (p *IncomingPacket) WriteLong(value uint64)
func (*IncomingPacket) WriteNullString ¶
func (p *IncomingPacket) WriteNullString(value string)
func (*IncomingPacket) WritePosition ¶
func (p *IncomingPacket) WritePosition(x, y, z int32)
func (*IncomingPacket) WriteProtocolString ¶
func (p *IncomingPacket) WriteProtocolString(value string)
func (*IncomingPacket) WriteShort ¶
func (p *IncomingPacket) WriteShort(value int16)
func (*IncomingPacket) WriteUUID ¶
func (p *IncomingPacket) WriteUUID(value util.UUID)
type OutgoingPacket ¶
type OutgoingPacket struct { GarbageBuffer []byte // contains filtered or unexported fields }
func NewOutgoingPacketFromSlice ¶
func NewOutgoingPacketFromSlice(buffer []byte) *OutgoingPacket
func NewOutgoingPacketFromSliceID ¶
func NewOutgoingPacketFromSliceID(buffer []byte, id packet.Clientbound, old_id int32) *OutgoingPacket
func (*OutgoingPacket) ID ¶
func (p *OutgoingPacket) ID() packet.Clientbound
This returns the packets id. NOTE: Will not always be set. Will be Clientbound_None if not set.
func (*OutgoingPacket) OldID ¶
func (p *OutgoingPacket) OldID() int32
This returns the packets id. NOTE: Will not always be set. Will be -1 if not set.
func (*OutgoingPacket) SetVersion ¶
func (p *OutgoingPacket) SetVersion(v packet.Version)
Sets the packet's version. This slightly changes how certain values are written; see WritePosition and WriteItem.
func (*OutgoingPacket) WriteBool ¶
func (p *OutgoingPacket) WriteBool(v bool)
func (*OutgoingPacket) WriteByte ¶
func (p *OutgoingPacket) WriteByte(v byte)
func (*OutgoingPacket) WriteByteArray ¶
func (p *OutgoingPacket) WriteByteArray(v []byte)
func (*OutgoingPacket) WriteDouble ¶
func (p *OutgoingPacket) WriteDouble(v float64)
func (*OutgoingPacket) WriteFixedFloat ¶
func (p *OutgoingPacket) WriteFixedFloat(v float64)
This is a fixed point float. It takes the double, multiplies it by 32, and rounds it to an int. It then writes that int into the packet, encoded as an int (not varint). This is only used in 1.8, but in 1.8, it is used any time an entity position is reference.
func (*OutgoingPacket) WriteFloat ¶
func (p *OutgoingPacket) WriteFloat(v float32)
func (*OutgoingPacket) WriteInt ¶
func (p *OutgoingPacket) WriteInt(v int32)
func (*OutgoingPacket) WriteItem ¶
func (p *OutgoingPacket) WriteItem(value *pb.Item)
This writes a minecraft item. For versions 1.13.2 and up, it starts with a bool, for whether it exists. If it does exist, then it is followed byte the item id. That is followed by the number of items in the stack. That is then followed by an NBT tag, or a null byte if there is none. For versions 1.13 and 1.13.1, there is no bool. The item id is set to -1, and no data follows. Otherwise, it there is an item, the same data as above follows. For versions 1.12.2 and below, there is an extra field: right after the item count, there is a short, which is the item's data value.
func (*OutgoingPacket) WriteLong ¶
func (p *OutgoingPacket) WriteLong(v uint64)
func (*OutgoingPacket) WriteNullString ¶
func (p *OutgoingPacket) WriteNullString(v string)
func (*OutgoingPacket) WritePosition ¶
func (p *OutgoingPacket) WritePosition(v uint64)
This parses a postition from a grpc packet (always new format), and then writes the long back into the buffer, with either the new or old format.
func (*OutgoingPacket) WriteShort ¶
func (p *OutgoingPacket) WriteShort(v uint16)
func (*OutgoingPacket) WriteString ¶
func (p *OutgoingPacket) WriteString(v string)
func (*OutgoingPacket) WriteUUID ¶
func (p *OutgoingPacket) WriteUUID(v util.UUID)
func (*OutgoingPacket) WriteVarInt ¶
func (p *OutgoingPacket) WriteVarInt(v int32)