Documentation ¶
Overview ¶
Package provider bot implements a simple Minecraft client that can join a server or just ping it for getting information.
Runnable example could be found at examples/ .
Index ¶
- Constants
- func Advancements(c *Client, p pk.Packet, cancel context.CancelFunc) error
- func AttachEntity(c *Client, p pk.Packet, cancel context.CancelFunc) error
- func AwardStatistics(c *Client, p pk.Packet, cancel context.CancelFunc) error
- func BlockAction(c *Client, p pk.Packet, cancel context.CancelFunc) error
- func BlockChange(c *Client, p pk.Packet, cancel context.CancelFunc) error
- func BlockEntityData(c *Client, p pk.Packet, cancel context.CancelFunc) error
- func BossBar(c *Client, p pk.Packet, cancel context.CancelFunc) error
- func Camera(c *Client, p pk.Packet, cancel context.CancelFunc) error
- func ChangeGameState(c *Client, p pk.Packet, cancel context.CancelFunc) error
- func ChatMessage(c *Client, p pk.Packet, cancel context.CancelFunc) error
- func ChunkData(c *Client, p pk.Packet, cancel context.CancelFunc) error
- func CloseContainer(c *Client, p pk.Packet, cancel context.CancelFunc) error
- func CloseWindow(c *Client, p pk.Packet, cancel context.CancelFunc) error
- func CollectItem(c *Client, p pk.Packet, cancel context.CancelFunc) error
- func CombatEvent(c *Client, p pk.Packet, cancel context.CancelFunc) error
- func CraftRecipeResponse(c *Client, p pk.Packet, cancel context.CancelFunc) error
- func DestroyEntities(c *Client, p pk.Packet, cancel context.CancelFunc) error
- func Disconnect(c *Client, p pk.Packet, cancel context.CancelFunc) error
- func DisplayScoreboard(c *Client, p pk.Packet, cancel context.CancelFunc) error
- func Effect(c *Client, p pk.Packet, cancel context.CancelFunc) error
- func Entity(c *Client, p pk.Packet, cancel context.CancelFunc) error
- func EntityAnimation(c *Client, p pk.Packet, cancel context.CancelFunc) error
- func EntityEffect(c *Client, p pk.Packet, cancel context.CancelFunc) error
- func EntityEquipment(c *Client, p pk.Packet, cancel context.CancelFunc) error
- func EntityHeadRotation(c *Client, p pk.Packet, cancel context.CancelFunc) error
- func EntityPosition(c *Client, p pk.Packet, cancel context.CancelFunc) error
- func EntityPositionRotation(c *Client, p pk.Packet, cancel context.CancelFunc) error
- func EntityProperties(c *Client, p pk.Packet, cancel context.CancelFunc) error
- func EntityRotation(c *Client, p pk.Packet, cancel context.CancelFunc) error
- func EntityStatus(c *Client, p pk.Packet, cancel context.CancelFunc) error
- func EntityTeleport(c *Client, p pk.Packet, cancel context.CancelFunc) error
- func EntityVelocity(c *Client, p pk.Packet, cancel context.CancelFunc) error
- func Explosion(c *Client, p pk.Packet, cancel context.CancelFunc) error
- func InitializeBorder(c *Client, p pk.Packet, cancel context.CancelFunc) error
- func JoinGame(c *Client, p pk.Packet, cancel context.CancelFunc) error
- func KeepAlive(c *Client, p pk.Packet, cancel context.CancelFunc) error
- func LookAt(client *Client, p pk.Packet, cancel context.CancelFunc) error
- func Map(c *Client, p pk.Packet, cancel context.CancelFunc) error
- func MultiBlockChange(c *Client, p pk.Packet, cancel context.CancelFunc) error
- func NamedSoundEffect(c *Client, p pk.Packet, cancel context.CancelFunc) error
- func OpenSignEditor(c *Client, p pk.Packet, cancel context.CancelFunc) error
- func Particle(c *Client, p pk.Packet, cancel context.CancelFunc) error
- func PlayerAbilities(c *Client, p pk.Packet, cancel context.CancelFunc) error
- func PlayerInfoRemove(c *Client, p pk.Packet, cancel context.CancelFunc) error
- func PlayerInfoUpdate(c *Client, p pk.Packet, cancel context.CancelFunc) error
- func PlayerListHeaderAndFooter(c *Client, p pk.Packet, cancel context.CancelFunc) error
- func PluginMessage(c *Client, p pk.Packet, cancel context.CancelFunc) error
- func RemoveEntityEffect(c *Client, p pk.Packet, cancel context.CancelFunc) error
- func ResourcePackSend(c *Client, p pk.Packet, cancel context.CancelFunc) error
- func Respawn(c *Client, p pk.Packet, cancel context.CancelFunc) error
- func RunTransactions(c *Client, cancel context.CancelFunc) error
- func ScoreboardObjective(c *Client, p pk.Packet, cancel context.CancelFunc) error
- func SelectAdvancementTab(c *Client, p pk.Packet, cancel context.CancelFunc) error
- func ServerDifficulty(c *Client, p pk.Packet) error
- func SetBlockDestroyStage(c *Client, p pk.Packet, cancel context.CancelFunc) error
- func SetContainerContent(c *Client, p pk.Packet, cancel context.CancelFunc) error
- func SetContainerProperty(c *Client, p pk.Packet, cancel context.CancelFunc) error
- func SetContainerSlot(c *Client, p pk.Packet, cancel context.CancelFunc) error
- func SetCooldown(c *Client, p pk.Packet, cancel context.CancelFunc) error
- func SetExperience(c *Client, p pk.Packet, cancel context.CancelFunc) error
- func SetHeldItem(c *Client, p pk.Packet, cancel context.CancelFunc) error
- func SetPassengers(c *Client, p pk.Packet, cancel context.CancelFunc) error
- func SoundEffect(c *Client, p pk.Packet, cancel context.CancelFunc) error
- func SpawnEntity(c *Client, p pk.Packet, cancel context.CancelFunc) error
- func SpawnExperienceOrb(c *Client, p pk.Packet, cancel context.CancelFunc) error
- func SpawnPlayer(c *Client, p pk.Packet, cancel context.CancelFunc) error
- func SpawnPosition(c *Client, p pk.Packet, cancel context.CancelFunc) error
- func Step(cl *Client, cancel context.CancelFunc) error
- func SynchronizePlayerPosition(c *Client, p pk.Packet, cancel context.CancelFunc) error
- func TabComplete(c *Client, p pk.Packet, cancel context.CancelFunc) error
- func Teams(c *Client, p pk.Packet, cancel context.CancelFunc) error
- func TimeUpdate(c *Client, p pk.Packet, cancel context.CancelFunc) error
- func Title(c *Client, p pk.Packet, cancel context.CancelFunc) error
- func UnloadChunk(c *Client, p pk.Packet, cancel context.CancelFunc) error
- func UnlockRecipes(c *Client, p pk.Packet, cancel context.CancelFunc) error
- func UpdateHealth(c *Client, p pk.Packet, cancel context.CancelFunc) error
- func UpdateScore(c *Client, p pk.Packet, cancel context.CancelFunc) error
- func VehicleMove(c *Client, p pk.Packet, cancel context.CancelFunc) error
- type Abilities
- type Client
- type Events
- type PacketHandler
- type Player
- type Status
- type TickHandler
Constants ¶
const DefaultPort = mcnet.DefaultPort
const ProtocolVersion = 763
ProtocolVersion is the protocol version number of minecraft net protocol
Variables ¶
This section is empty.
Functions ¶
func Advancements ¶
func AttachEntity ¶
func AwardStatistics ¶
func BlockAction ¶
func BlockChange ¶
func BlockEntityData ¶
func ChangeGameState ¶
func ChatMessage ¶
func CloseContainer ¶
func CloseWindow ¶
func CollectItem ¶
func CombatEvent ¶
func CraftRecipeResponse ¶
func DestroyEntities ¶
func Disconnect ¶
func DisplayScoreboard ¶
func EntityAnimation ¶
func EntityEffect ¶
func EntityEquipment ¶
func EntityHeadRotation ¶
func EntityPosition ¶
func EntityPositionRotation ¶
func EntityProperties ¶
func EntityRotation ¶
func EntityStatus ¶
func EntityTeleport ¶
func EntityVelocity ¶
func InitializeBorder ¶
func MultiBlockChange ¶
func NamedSoundEffect ¶
func OpenSignEditor ¶
func PlayerAbilities ¶
func PlayerInfoRemove ¶
func PlayerInfoUpdate ¶
Since Mojang has done an horrible job at designing this, I will simply ignore it until I need it, fuck off
func PluginMessage ¶
func RemoveEntityEffect ¶
func ResourcePackSend ¶
func RunTransactions ¶
func RunTransactions(c *Client, cancel context.CancelFunc) error
func ScoreboardObjective ¶
func SelectAdvancementTab ¶
func SetBlockDestroyStage ¶
func SetContainerContent ¶
func SetContainerProperty ¶
func SetContainerSlot ¶
func SetCooldown ¶
func SetExperience ¶
func SetHeldItem ¶
func SetPassengers ¶
func SoundEffect ¶
func SpawnEntity ¶
func SpawnExperienceOrb ¶
func SpawnPlayer ¶
func SpawnPosition ¶
func Step ¶
func Step(cl *Client, cancel context.CancelFunc) error
Step is called every tick I don't have to code all the physic by myself thx minecrossoft 🙏
func TabComplete ¶
func TimeUpdate ¶
func UnloadChunk ¶
func UnlockRecipes ¶
func UpdateHealth ¶
func UpdateScore ¶
func VehicleMove ¶
Types ¶
type Abilities ¶
type Abilities struct { Invulnerable bool Flying bool AllowFlying bool InstantBreak bool CanBuild bool FlyingSpeed float64 WalkingSpeed float64 }
func NewAbilities ¶
func NewAbilities() *Abilities
type Client ¶
type Client struct { Conn *net.Conn Auth data.Auth World *world.World PlayerList *core.PlayerList Player *Player Events Events[Client] LoginPlugin map[string]func(data []byte) ([]byte, error) }
Client is used to access Minecraft server
+--------------------------------+-------------------------------+ | Client framework | +--------------------------------+-------------------------------+ | World | PlayerList | Player | +-------------------+------------+-------------------------------+
func NewClient ¶
NewClient creates a new Client If you wish to use online-mode, refer to microsoft.LoginFromCache and microsoft.MinecraftLogin
func (*Client) HandleGame ¶
HandleGame receive server packet and response them correctly. Note that HandleGame will block if you don't receive from Events.
func (*Client) JoinServer ¶
JoinServer connect a Minecraft server for playing the game. Using roughly the same way to parse address as minecraft.
type Events ¶
type Events[T any] struct { // contains filtered or unexported fields }
func (*Events[T]) AddListener ¶
func (e *Events[T]) AddListener(listeners ...PacketHandler[T])
AddListener adds a listener to the event. The listener will be called when the packet with the same ID is received. The listener will be called in the order of priority. The listeners cannot have multiple same ID.
func (*Events[T]) AddTicker ¶
func (e *Events[T]) AddTicker(tickers ...TickHandler[T])
type PacketHandler ¶
type Player ¶
type Player struct { Settings basic.Settings World *world.World Controller *core.Controller Manager *screen.Manager PlayerInfo world.PlayerInfo WorldInfo world.WorldInfo EntityPlayer *core.EntityPlayer Transactions *util.Queue[[]*transactions.SlotAction] Abilities *Abilities // Player info ExpBar float64 TotalExp int32 Level int32 IsSpawn bool JumpTicks int32 JumpTriggerTime int32 JumpRidingTicks int32 JumpRidingScale float64 SprintTriggerTime int32 FallTicks float64 FallDistance float64 StepHeight float64 PositionReminder int CollidedHorizontally bool CollidedHorizontallyMinor bool CollidedVertically bool CollidedVerticallyBelow bool Collided bool UsingItem bool }
func NewPlayer ¶
NewPlayer creates a new Player The player should not have access to the Client struct but the player needs access to the world and the current authentication information
The player should not be created before the client is created.
func (*Player) RidingJumpable ¶
type Status ¶
type Status struct { Version struct { Name string `json:"name"` Protocol int `json:"protocol"` } `json:"version"` Players struct { Max int `json:"max"` Online int `json:"online"` Sample []struct { Name string `json:"name"` ID string `json:"id"` } `json:"sample"` } `json:"players"` Description chat.Message `json:"description"` Favicon string `json:"favicon"` EnforcesSecureChat bool `json:"enforcesSecureChat"` }
func PingAndList ¶
PingAndList check server status and list online player. Returns a JSON data with server status, and the delay.
For more information for JSON format, see https://wiki.vg/Server_List_Ping#Response
func PingAndListContext ¶
type TickHandler ¶
type TickHandler[T any] struct { Priority int F func(*T, context.CancelFunc) error }