Documentation
¶
Index ¶
- func AddHandler[T client.ClientboundPacket](c Client, f HandlerFunc[T])
- func PublishEvent(client Client, event Event) error
- func SubscribeEvent[T Event](client Client, handler func(event T) error)
- type Client
- type ClientOptions
- type ConnectOptions
- type Container
- type Entity
- type Event
- type EventHandler
- type HandlerFunc
- type InventoryHandler
- type PacketHandler
- type Player
- type ProxyConfig
- type World
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddHandler ¶
func AddHandler[T client.ClientboundPacket](c Client, f HandlerFunc[T])
func PublishEvent ¶
func SubscribeEvent ¶
Types ¶
type Client ¶
type Client interface {
Connect(ctx context.Context, addr string, options *ConnectOptions) error
HandleGame(ctx context.Context) error
Close(ctx context.Context) error
IsConnected() bool
WritePacket(ctx context.Context, packet server.ServerboundPacket) error
PacketHandler() PacketHandler
EventHandler() EventHandler
World() World
Inventory() InventoryHandler
Player() Player
}
type ClientOptions ¶
type ConnectOptions ¶
type ConnectOptions struct {
FakeHost string `json:"fake_host,omitempty" toml:"fake_host,omitempty"`
Proxy *ProxyConfig `json:"proxy,omitempty" toml:"proxy,omitempty"`
}
type EventHandler ¶
type HandlerFunc ¶
type HandlerFunc[T client.ClientboundPacket] func(ctx context.Context, p T)
type InventoryHandler ¶
type PacketHandler ¶
type PacketHandler interface {
AddPacketHandler(id packetid.ClientboundPacketID, handler func(ctx context.Context, p client.ClientboundPacket))
AddRawPacketHandler(id packetid.ClientboundPacketID, handler func(ctx context.Context, p packet.Packet))
AddGenericPacketHandler(handler func(ctx context.Context, p client.ClientboundPacket))
HandlePacket(ctx context.Context, p client.ClientboundPacket)
}
type Player ¶
type Player interface {
StateID() int32
UpdateStateID(id int32)
Entity() Entity
FlyTo(pos mgl64.Vec3) error
WalkTo(pos mgl64.Vec3) error
LookAt(vec3 mgl64.Vec3) error
UpdateLocation()
BreakBlock(pos protocol.Position) error
PlaceBlock(pos protocol.Position) error
PlaceBlockWithArgs(pos protocol.Position, face int32, cursor mgl64.Vec3) error
OpenContainer(pos protocol.Position) (Container, error)
UseItem(hand int8) error
OpenMenu(command string) (Container, error)
Command(command string) error
Chat(message string) error
CheckServer()
}
type ProxyConfig ¶
type World ¶
type World interface {
GetBlock(pos protocol.Position) (block.Block, error)
SetBlock(pos protocol.Position, b block.Block) error
GetNearbyBlocks(pos protocol.Position, radius int32) ([]block.Block, error)
FindNearbyBlock(pos protocol.Position, radius int32, blk block.Block) (protocol.Position, error)
Entities() []Entity
GetEntity(id int32) Entity
GetNearbyEntities(radius int32) []Entity
GetEntitiesByType(entityType entity.ID) []Entity
}
Click to show internal directories.
Click to hide internal directories.