MineSharp.Bot
0.1.4
See the version list below for details.
dotnet add package MineSharp.Bot --version 0.1.4
NuGet\Install-Package MineSharp.Bot -Version 0.1.4
<PackageReference Include="MineSharp.Bot" Version="0.1.4" />
paket add MineSharp.Bot --version 0.1.4
#r "nuget: MineSharp.Bot, 0.1.4"
// Install MineSharp.Bot as a Cake Addin #addin nuget:?package=MineSharp.Bot&version=0.1.4 // Install MineSharp.Bot as a Cake Tool #tool nuget:?package=MineSharp.Bot&version=0.1.4
MineSharp.Bot
Connect and interact with Minecraft servers.
A MineSharpBot
uses a MinecraftClient
(see MineSharp.Protocol) to connect to a Minecraft Server.
The bot can have multiple plugins. Each plugin can handle some packets sent by the server and/or provide methods to interact with the world.
Creating Bots
A bot can be created using a MinecraftClient
.
To help out, you can use the BotBuilder
class to fluently create a bot.
Bot Builder
.Host()
configure the hostname.Port()
configure the port (default = 25565).Data()
configure theMinecraftData
instance.AutoDetectData()
(default) auto detect minecraft data version if none was configured.Session()
configure the session object.OfflineSession()
configure session to be an offline session.OnlineSession()
configure session to be an online session (login happens when callingCreate()
orCreateAsync()
).WithPlugin<T>()
add Plugin of typeT
.ExcludeDefaultPlugins()
do not add default plugins (listed below).AutoConnect()
automatically connect to the server when creating the bot.WithProxy()
configure a proxy.CreateAsync()
create a new bot with the configuration.Create()
equivalent ofCreateAsync().Result
Plugins
A plugin can handle packets sent by the server and/or provide methods to interact with the server.
Currently, these are the plugins enabled by default:
- Chat Plugin (Read and Write chat messages)
- Crafting Plugin (Craft items)
- Entity Plugin (Keeps track of entities)
- Physics Plugin (Simulate player physics)
- Player Plugin (Keeps track of the bot himself as well as other players and the weather)
- Window Plugin (Bot's inventory and open chests or other blocks)
- World Plugin (Keep track of the world)
Other plugins not enabled by default:
- Auto Respawn (Automatically respawn when dead)
To add a plugin to the bot, bot.LoadPlugin(plugin)
can be used.
To access a plugin, use bot.GetPlugin<>()
Chat Plugin
- Handles all chat packets and provides abstraction for different minecraft versions
- Handle and parse the CommandTree
- โก
OnChatMessageReceived
event. Fired when any chat message or game information message is received - ๐จ
SendChat()
method. Send a chat message to the server. - ๐ง
SendCommand()
method. Send a '/' command to the server. Only for mc >= 1.19
Crafting Plugin
- ๐
FindRecipes()
. Find recipes for a given item that can be crafted with the items in the bots inventory - ๐
FindRecipe()
. Equivalent ofFindRecipes().FirstOrDefault()
- ๐ข
CraftableAmount()
. Calculate how often a recipe can be crafting with the items in the bots inventory. - ๐ช
Craft()
. Craft the given recipen
times.
Entity Plugin
- Handles all packets regarding entities (position, effects, etc..)
- โก
OnEntitySpawn
. Fired when an entity spawned - โก
OnEntityDespawned
. Fired when an entity despawned - โก
OnEntityMoved
. Fired when an entity moved - ๐ท
Entities
. Dictionary mapping all entities from their numerical server id to theEntity
object
Physics Plugin
- Update the bots position on the server
- โก
BotMoved
. Fired when the bot moved - โก
PhysicsTick
. Fired after each tick of the physics simulation - ๐ฎ
InputControls
. Input controls used to control movement - ๐ช
Engine
. The underlying physics simulation / engine - โณ
WaitForTicks()
. Wait until a number of physics ticks are completed - โฐ๏ธ
WaitForOnGround()
. Wait until the bot is on the ground - ๐
ForceSetRotation()
. Set the bots rotation in a single tick - ๐
ForceLookAt()
. Look at the given position in a single tick - ๐
Look()
. Slowly transition to the given rotation - ๐
LookAt()
. Slowly look at the given position - ๐ซ
Raycast()
. Returns the block the bot is currently looking at
Player Plugin
- Handles packets regarding the Bot entity and other players on the server
- โก
OnHealthChanged
. Fired when the bots health, food or saturation was updated. - โก
OnRespawed
. Fired when the bot respawned or changed the dimension. - โก
OnDied
. Fired when the bot died. - โก
OnPlayerJoined
. Fired when another player joined the server - โก
OnPlayerLeft
. Fired when another player left the server - โก
OnPlayerLoaded
. Fired when another player came into the visible range of the bot and their entity was loaded. - โก
OnWeatherChanged
. Fired when the weather has changed. (TODO: Move to WorldPlugin) - ๐ค
Self
. TheMinecraftPlayer
representing the bot itself - ๐ค
Entity
. TheEntity
representing the bot itself (equivalent ofSelf.Entity
) - ๐จโ๐งโ๐ฆ
Players
. A dictionary mapping all player's uuids to theirMinecraftPlayer
object - ๐จโ๐งโ๐ฆ
PlayerMap
. A dictionary mapping all player's numerical server id to theirMinecraftPlayer
object. - ๐
Health
. Health of the Bot (value between 0.0 - 20.0) - ๐
Saturation
. The Saturation level of the bot - ๐
Food
. The food level of the bot - ๐
Dimension
. The name of the dimension the bot is currently in - ๐
IsAlive
. Boolean indicating whether the bot is alive - ๐ง๏ธ
IsRaining
. Boolean indicating whether it is raining - โ
RainLevel
. Float indicating how much it is raining - โ๏ธ
ThunderLevel
. The thunder level - โ๏ธ
Respawn()
. Respawn the bot if it is dead. - ๐ช
SwingArm()
. Plays the swing arm animation. - ๐คบ
Attack()
. Attack the given entity
Window Plugin
- Handles packets regarding windows
- โก
OnWindowOpened
. Fired when a window opened - โก
OnHeldItemChanged
. Fired when the held item changed - ๐ฆ
Inventory
. The Window representing the bots inventory - ๐ช
CurrentlyOpenedWindow
. The window which is currently open. - ๐
HeldItem
. The Item the bot is currently holding in the main hand - ๐
SelectedHotbarIndex
. The index of the selected hotbar slot - โ
WaitForInventory()
. Wait until the inventory's item are loaded - ๐งฐ
OpenContainer()
. Try to open the given block (eg. chest, crafting table, ...) - โ
CloseWindow()
. Close the window - ๐
SelectHotbarIndex()
. Set the selected hotbar index - ๐
UseItem()
. Use the item the bot is currently holding - ๐จโ๐ง
EquipItem()
. Find and equip an item
World Plugin
- Handles all block and chunk packets
- ๐
World
. The world of the minecraft server - โณ
WaitForChunks()
. Wait until all chunks in a radius around the bot are loaded - โจ๏ธ
UpdateCommandBlock()
. Update a command block - โ๏ธ
MineBlock()
. Mine the given block - ๐ท
PlaceBlock()
. Place a block at the given position
Auto Respawn
- Automatically respawns the bot when it died
- โฐ๏ธ
RespawnDelay
. Delay before respawning
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net7.0
- MineSharp.Commands (>= 0.1.4)
- MineSharp.Physics (>= 0.1.4)
- MineSharp.Protocol (>= 0.1.4)
- MineSharp.Windows (>= 0.1.4)
- MineSharp.World (>= 0.1.4)
- starksoft.aspen (>= 1.1.8)
-
net8.0
- MineSharp.Commands (>= 0.1.4)
- MineSharp.Physics (>= 0.1.4)
- MineSharp.Protocol (>= 0.1.4)
- MineSharp.Windows (>= 0.1.4)
- MineSharp.World (>= 0.1.4)
- starksoft.aspen (>= 1.1.8)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.