I have decided to sunset Hivemine as an open-source bot. Hivemine is being rewritten and will be closed-source for the forseeable future. If you are interested in joining the project, please shoot me an email.
a server-dominating Minecraft bot, powered by Mineflayer
- Acquire resources
- Keep eachother alive
- Craft tools
- Expand the Hive
- Expand building grid
- Spread banners
- Carve out terrain below
- Switch roles on the fly:
- Lumberjack, Fisherman, Miner, etc.
- Cooperate on a task
- Building, Mining, Sorting, etc.
- Use server mechanics
- Buying/selling items, Factions, etc.
This is where all the Agent logic will go - task management, utilities, etc.
This is where all the different role
types will be stored.
This is the brains behind the operation - it will create and manage bots.
This example is written with Fluture in mind - just an idea, subject to change.
# Get a free Agent, an even higher level wrapper of mineflayer
Agent = Hivemine.findFreeAgent()
if Agent
# Have the bot craft a pickaxe and then deposit it into a labeled chest
Agent.createItem('iron_pickaxe').chain (Item) -> # 'chain' an action if craftItem succeeds
# Deposit pickaxe into closest chest with sign '[tools]'
Agent.depositIntoLabeledChest Item, '[tools]'
# Request an iron pickaxe to a chest labeled '[miningcamp]'. Returns a job id to listen for.
RequestId = Hivemine.requestItemToLabeledChest 'iron_pickaxe', '[miningcamp]'
Hivemine.once RequestId, (Status) ->
# Status has properties related to the delivery, like 'delivered', 'item', and 'chest'
if Status.delivered
# Item was delivered, have Agent take it from chest
Agent.withdrawFromChest Status.item, Status.chest
# Alternative function:
Agent.claimDelivery Status
Agent.changeRole 'fisherman'
# Bot would finish their current role's task and begin a new role
class Fisherman extends Role
constructor: -> super 'fisherman' # Give the role a name
onEnter: (Agent) => # Called when the bot joins the role
# Call super before we do anything, sets @Agent, @Hivemine, and Agent.Role
super Agent
@Agent.withdrawFromLabeledChest('fishing_rod', '[fisher]').chain ->
@Agent.walkToSign('[fishin spot]').chain ->
@startFishing()
onCaughtFish: => # Could report it to Hivemine, deposit it, eat it, etc.
@startFishing()
stopFishing: =>
return if not @fishing
@Agent.activateItem()
@fishing = false
onCollect: (Player, Entity) =>
if Entity.kind == 'Drops' and Player === Agent.entity
@Agent.removeListener 'playerCollect', @onCollect
@onCaughtFish()
canFish: => Agent.hasItem 'fishing_rod'
startFishing: =>
return if @fishing
if @canFish()
@Agent.fish (Err) -> @fishing = false
@Agent.on 'playerCollect', @onCollect
onExit: => # Called when the bot has to leave its role
# Stop fishing if we are
@stopFishing()
# Deposit items
@Agent.depositIntoLabeledChest('*', '[fisher]').chain -> # '*' wildcard to deposit all items
super() # Call when done