Auto Miner

Discussion in 'Spigot Plugin Development' started by Swords123456, Apr 17, 2018.

  1. I am making a prison plugin and i want to have an auto-miner. Something like this is a quarry in the buildcraft mods.
     
  2. MiniDigger

    Supporter

    Well, did you think about how you want to do this? You need to come up with an idea first, then we can help you trying to implement that.
     
  3. I would like to use a block such as a chest, but im not sure how to get the block in front of the chest. The path of the chest should be zig zags so it can get every block and when there is no blocks to mine in about a 10 block radius it will mine downwards.
     
  4. MiniDigger

    Supporter

    well, you can get the location of the check. you can get a block on a set location. that way you can easily iterate over the coordinates and do something with every block in an area.
     
  5. tell if me if i got you idea.
    the player placing a chest. it starts to "mine" 10 blocks radius of it. if there is no blocks left, it will go down and so on?

    if so, i would make it in this way:
    first i will create an object and call it ChestMiner, the object will contain owner's uuid, an inventory variable, BukkitTask variable, chest's location and the radius(for example the player can upgrade the radius).
    then when a player places the chest it creates the object.
    we will set the player's uuid, in the inventory variable we will make new inventory and place the chest's location.
    and we will start a new time, BukkitRunnable (we will put it into the BukkitTask variable) that will run every 5 seconds.

    in the timer we will set the "mining", we will have there a counter (i will explain later why).
    now we will get a random location in the radius of the chest's location.
    if there is no block, we will add 1 to the counter and get an new location, and we will make it in a loop.
    if the counter reaches 44, it means there is no blocks. (check this link to see how much blocks there are in a circle).
    if we found a block remove it and add it to the inventory. (but if the inventory is full do nothing, maybe notify the player).
    and if there is no block, remove the chest and set it 1 block lower.

    this is the main part, you also need some Listeners, for example when the player right click a chest, you need to check if in the object the chest's location exist, if so it a mining chest, and you need to check the player's uuid and etc..

    hope i gave you an idea how to make it.
     

Share This Page