Skip to content
This repository has been archived by the owner on Sep 4, 2020. It is now read-only.
/ Hivemine Public archive

Server-dominating Minecraft bot, powered by Mineflayer

Notifications You must be signed in to change notification settings

safazi/Hivemine

Repository files navigation

THIS PROJECT HAS BEEN ARCHIVED

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.

Hivemine

a server-dominating Minecraft bot, powered by Mineflayer


Bot goals:

  • Acquire resources
    • Keep eachother alive
    • Craft tools
  • Expand the Hive
    • Expand building grid
    • Spread banners
  • Carve out terrain below

Bots should be able to:

  • 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.

Project structure

./AgentPlugin.coffee

This is where all the Agent logic will go - task management, utilities, etc.

./roles/

This is where all the different role types will be stored.

./Hivemine.coffee

This is the brains behind the operation - it will create and manage bots.


Example API

This example is written with Fluture in mind - just an idea, subject to change.

Craft and store a pickaxe

# 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]'

Have an item delivered

# 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

Force new role

Agent.changeRole 'fisherman'
# Bot would finish their current role's task and begin a new role

Role concept

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

About

Server-dominating Minecraft bot, powered by Mineflayer

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published