bot

package
v0.0.0-...-b47183b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 21, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

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 PublishEvent(client Client, event Event) error

func SubscribeEvent

func SubscribeEvent[T Event](client Client, handler func(event T) error)

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 ClientOptions struct {
	AuthProvider auth.Provider
}

type ConnectOptions

type ConnectOptions struct {
	FakeHost string       `json:"fake_host,omitempty" toml:"fake_host,omitempty"`
	Proxy    *ProxyConfig `json:"proxy,omitempty" toml:"proxy,omitempty"`
}

type Container

type Container interface {
	GetSlot(index int) slot.Slot
	Slots() []slot.Slot
	SlotCount() int
	FindEmpty() int16
	FindItem(itemID item.ID) int16
	Click(slot int16, mode int32, button int32) error
}

type Entity

type Entity interface {
	ID() int32
	UUID() uuid.UUID
	Type() entity.ID
	Position() mgl64.Vec3
	Rotation() mgl64.Vec2

	Metadata() map[uint8]metadata.Metadata
	Equipment() map[int8]slot.Slot

	SetPosition(pos mgl64.Vec3)
	SetRotation(rot mgl64.Vec2)
}

type Event

type Event interface {
	EventID() string
}

type EventHandler

type EventHandler interface {
	PublishEvent(event string, data any) error
	SubscribeEvent(event string, handler func(data any) error)
}

type HandlerFunc

type HandlerFunc[T client.ClientboundPacket] func(ctx context.Context, p T)

type InventoryHandler

type InventoryHandler interface {
	Inventory() Container
	Container() Container
	CurrentContainerID() int32
	Click(container int32, slot int16, mode int32, button int32) error
	Close()
}

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 ProxyConfig struct {
	Type     string `json:"type" toml:"type"`
	Host     string `json:"host" toml:"host"`
	Username string `json:"username" toml:"username"`
	Password string `json:"password" toml:"password"`
}

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
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址