[MECH] PDrill v0.4 - Programmable drill [1000]

Discussion in 'Inactive/Unsupported Plugins' started by devcom, Jul 13, 2011.

  1. PDrill - The programmable drill plugin for bukkit
    Version: v0.4

    This plugin was made beacause I wanted this kind of functionality, which is programmable drills that do dirty job for you, since I started playing minecraft.

    Features:
    * Allows players to use furnace as drill.
    * Allows to create custom fuels for drills with many options
    * Drills can do user defined / predefined scripts

    <Edit by Moderator: Redacted mediafire url>
    Source

    How to use:
    Place standard furnace then left click on it with stick in your hands and your drill is activated, it also tells you id of your drill to use commands on it. Then put fuel in standard fuel slot and it should be ready to go.

    Commands:

    Show Spoiler
    /pdscript <drillId> <script>
    /pdload <drillId> <script_name>
    /pdmake <what> <drillId> [optional]
    now only:
    /pdmake room <drillId> <forward> <up> <right>
    so /pdmake room 0 5 -5 5 will make 5x5x5 room with drill id 0 (notice it will dig downward as <up> is negative, same work for any other direction)
    /pdcreate fuel <name> [id] [airSpeed] [blockSpeed] [blockCount] [fuelCount]
    default: -1 1 1 1 1
    example: /pdcreate fuel test 50 2 3 will make new fuel named test with blockCount and fuelCount defaulted to 1
    /pdcreate script <name> [script]
    default: ""
    <drillId> can be one or more drill ids:
    12
    1,2,3,4,20
    0,...,40,56 - this will send script to drills with id from 0 to 40 and with id 56
    and combination of those above
    /pdlink <drillId> <fuel_name>
    Links drills to use as one. All of linked drills must use fuel_name from config file.
    /pddelink <drillId>
    Delinks linked drills.
    /pdplace <drillId> <place_interval> <place_direction>
    Adds new place job to drill to place block after place_interval blocks at place_direction side.
    Blocks to place are taken from 'to smelt' slot in furnace. Note that furnace will not stop if there are no blocks to place.
    /pdlist <script | fuel | drill>
    Lists scripts | fuels | drills


    Default config:

    Show Spoiler
    Code:
    config:
        dropItemNaturally: true
        speed: 0.1
        stopBlocks:
        - 61
        - 62
        - 54
        - 7
        dropItemList:
        - 1
        - 3
        dropItemChange:
        - 1;4
        - 2;3
        itemPlaceCost:
        - 264;0
        - 263;4
        checkItemChange: false
    script:
        test:
            script: f10
    fuel:
        coalFuel:
            fuelId: 263
            drillAirSpeed: 3
            drillBlockSpeed: 5
            fuelConsumptionBlockCount: 2
            fuelConsumptionFuelCount: 1
        diamondFuel:
            fuelId: 264
            drillAirSpeed: 1
            drillBlockSpeed: 1
            fuelConsumptionBlockCount: 100
            fuelConsumptionFuelCount: 1
    


    Config explanation:

    Show Spoiler
    dropItemNaturally - will drill drop breaked blocks ?
    speed - how fast server will update drills (in seconds)
    stopBlocks - list of blocks at which drill will stop and wait for their deletion
    dropItemList - what block will drill drop (empty for all)
    dropItemChange - changes dropped item, format - from_block;to_block
    itemPlaceCost - how much fuel will placing block cost
    checkItemChange - will changed drop will be checked in dropItemList

    testScript - must be unique for each script
    script - script that will be loaded
    script is made of [jobs] separated with space
    a job is created from two things:
    direction:
    f - forward
    b - backward
    r - right
    l - left
    u - up
    d - down
    and length as integer
    exaple job: f12 that will move drill 12 blocks
    from where it is in forward direction
    example script: f12 r3
    LOOPS:
    LOOP<how many loops>( <body> )
    ex1: LOOP3( r1 f1 u1 )
    will create script r1 f1 u1 r1 f1 u1 r1 f1 u1
    ex2: LOOP2( f1 LOOP3( u1 r5 ) )
    VARIABLES:
    (<var_id>)
    ex1: f(0) r(1)
    ex1 2 5
    will create script f2 r5
    ex2: f1 LOOP(0)( (1)(2) )
    ex2 2 f 3
    will create script f1 LOOP2( f3 )
    ( note i may suck at explanation so feel free to test it yourself, will try to explain more if its too dificult to understand )

    coalFuel - fuel name: must be unique for each fuel
    fuelId - fuel block id
    drillAirSpeed - how fast will drill move thru air ?
    drillBlockSpeed - how fast will drill move thru blocks
    1 in speed equals 0.2 sec
    so drillAirSpeed: 5 means that drill will move to air block in 1 sec

    fuelConsumptionBlockCount: 3
    fuelConsumptionFuelCount: 1
    This means that for each 3 blocks that drill move 1 fuel will be used



    TODO:

    Show Spoiler
    * Add [create / delete / change] for fuels and scripts on server.
    * Add local directions for drills
    * Add automatic default config creation
    * Add automatic block placement after X blocks (needs chest fallowing drill ??)
    * Add loop for script (?)
    * Add variables for scripts (like /pdload 0 sum_script 10 3 10)
    * Add /list command for [scripts / fuels / drills]
    * Linking for drills to make one big drill
    * Make speed configurable
    * Add color messages
    * More error checking
    * Redesign thread
    * Whatever i forgot


    Changelog:
    Version 0.3.2.2 - 0.4
    * loops added

    - * loops in loops added
    - fixed link drill
    - small code changes
    - added /pddelink
    - preparation for permissions
    - variables for scripts

    Version 0.3.2.2
    * Fixed empty fuel slot crash
    * Added explanation of /pdlist


    Show Spoiler
    Version 0.3.2.1
    * Error checking
    * Added checkItemChange

    Version 0.3, 0.3.1, 0.3.2
    * Added linking for drills
    * Added /pdlist command
    * Added ability for drills to place blocks
    * Added place cost in fuel
    * More error checking
    * Each drill now has local directions
    * Added stop blocks
    * Speed is now configurable

    Version 0.2
    * Added creation for scripts / fuels in game
    * Added /pdmake command
    * Drills now tell you if they run out of fuel
    * Changed 1 speed equals 0.1 sec instead of 0.2
    * Changed configuration file
    * Added source link
    * Fixed bugs.
    * Code cleanup

    Version 0.1
    * First release


    Please post any problems and ideas, thanks!
     
    Last edited by a moderator: Nov 27, 2016
  2. Offline

    plwjr2000

    cool plugin this is going on my server
     
  3. Offline

    sonata82

    Love the idea of the scripting, makes drilling much more fun!

    Any chance of releasing the source code to github? I'd love to expand the idea, maybe let another drill create a ladder or setting light sources every x blocks..

    Bugs I've encountered with version 0.1:
    • Two Drills crossing eachother gives an Exception:
      2011-07-19 12:40:02 [WARNING] Task of 'PDrill' generated an exception
      java.lang.ClassCastException: org.bukkit.craftbukkit.block.CraftBlockState cannot be cast to org.bukkit.block.Furnace
      at me.devcom.pdrill.FuelManager.furnaceFuel(FuelManager.java:25)
      at me.devcom.pdrill.FuelManager.furnaceFuelId(FuelManager.java:31)
      at me.devcom.pdrill.FuelManager.fuel(FuelManager.java:20)
      at me.devcom.pdrill.Job.moveBlock(Job.java:47)
      at me.devcom.pdrill.Job.process(Job.java:35)
      at me.devcom.pdrill.JobManager.doJob(JobManager.java:49)
      at me.devcom.pdrill.Drill.update(Drill.java:104)
      at me.devcom.pdrill.DrillManager.updateDrills(DrillManager.java:21)
      at me.devcom.pdrill.PDrill$1.run(PDrill.java:50)
      at org.bukkit.craftbukkit.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:137)
      at net.minecraft.server.MinecraftServer.h(MinecraftServer.java:438)
      at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:361)
      at net.minecraft.server.ThreadServerApplication.run(SourceFile:422)
    • Drill can go beyond Bedrock and create holes in the map
     
  4. @sonata82
    When this exception occured ?
    Also ill add configurable blocks at which drill stops
     
  5. Offline

    sonata82

    The exception is thrown when one drill changes the type of another drill: put two furnaces 5 blocks apart, hit them both, drill 0 and 1 are activated. Now make drill 0 go thru drill 1, the furnace is destroyed, but the drill still remains active. Giving any directions to the destroyed drill 1 throws the exception..

    Yeah, configurable stop blocks would be cool. But I think "end of the map" should always halt the drill.
     
  6. Offline

    sonata82

    I did some minor improvements (ant build file, one error check that happened to me frequently) and changed the way the directions were determined: depending on which side you hit the furnace, forward becomes going in the same direction, backwards opposite. Left and right are based accordingly, up and down are always just up and down.

    I created a pull request with all my changes, feel free to use them. Sorry about not creating a topic branch, still getting used to github :) Next time I'll commit properly.
     
  7. Offline

    Forecaster

    Awesome concept! I would love to have this!

    I've tested it on my 1.7.3 rb1000 server.

    I tried the room command and it worked perfectly. Some things did not work perfectly though.

    I noticed that it dropped dirt when it encountered it, and that dirt was in the drop list, but it did not drop stone despite it being in the list as well.

    No idea why this is though. Just using the drill generated no errors at all.

    While I looked forward to the scripting part it did not perform well at all unfortunately.
    I created a script directly in the config, and then one using the command, but trying to use either of these and then the default test script. They all generated a "Script compiling failed!" message in-game and nothing else.

    Using the "/pdlist" command results in an internal error and a null command error such as follows:
    Show Error (open)
    12:42:09 [SEVERE] null
    org.bukkit.command.CommandException: Unhandled exception executing command 'pdlist' in plugin PDrill v0.3.2
    at org.bukkit.command.PluginCommand.execute(PluginCommand.java:37)
    at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:129)
    at org.bukkit.craftbukkit.CraftServer.dispatchCommand(CraftServer.java:320)
    at net.minecraft.server.NetServerHandler.handleCommand(NetServerHandler.java:713)
    at net.minecraft.server.NetServerHandler.chat(NetServerHandler.java:677)
    at net.minecraft.server.NetServerHandler.a(NetServerHandler.java:670)
    at net.minecraft.server.Packet3Chat.a(Packet3Chat.java:33)
    at net.minecraft.server.NetworkManager.b(NetworkManager.java:226)
    at net.minecraft.server.NetServerHandler.a(NetServerHandler.java:85)
    at net.minecraft.server.NetworkListenThread.a(SourceFile:105)
    at net.minecraft.server.MinecraftServer.h(MinecraftServer.java:451)
    at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:361)
    at net.minecraft.server.ThreadServerApplication.run(SourceFile:422)
    Caused by: java.lang.ArrayIndexOutOfBoundsException: 0
    at me.devcom.pdrill.PDrill.onCommand(PDrill.java:220)
    at org.bukkit.command.PluginCommand.execute(PluginCommand.java:35)
    ... 12 more


    Another thing I found was that when one of my drill stopped because it ran out of fuel. When I tried to open it to refuel it my client crashed. This happened each time I re-connected and tried to open it again.

    I wonder if the current task is canceled when the fuel runs out or if it is just paused and would continue if the fuel was refilled.

    I would also like to suggest some things that I would like to see concerning the scripting:

    - Variables, when starting a script values can be entered that would be used by variables within the script which ties into the next one:
    - Loops, have it repeat the script or part of the script x number of times before stopping.
     
  8. @Forecaster can you show me how your scripts look ? Also /pdlist takes one argument, script or drill or fuel. So to list all scripts you do '/pdlist script' command.

    About not dropping stone, it was working good because smooth stone got changed into cobblestone which is not in lost of items to drop. Ive added checkItemChange to enable / disable such behavior, default is disabled so any item that got changed will not be checked in drop list.

    vars and loops are in my todo list, i think they will be added into next version.

    Anyway thanks for info!
     
  9. Offline

    Forecaster

    I see, that makes sense, I thought pdlist would list all active drills in the world.

    You should change the list command to provide the syntax when entered without arguments.

    Here's the scripts:
    This was written directly into the config by me:
    tunnel10:
    script: u1 l1 d3 r3 u3 l1 f1 l1 d3 r3 u3 l1 f1 l1 d3 r3 u3 l1 f1 l1 d3 r3 u3 l1 f1 l1 d3 r3 u3 l1 f1 l1 d3 r3 u3 l1 f1 l1 d3 r3 u3 l1 f1 l1 d3 r3 u3 l1 f1 l1 d3 r3 u3 l1 f1 l1 d3 r3 u3 l1 f1

    This was done using the command:
    tunnel5:
    script: u1 r1 d2 l2 u2 r1 f1 r1 d2 l2 u2 r1 f1 r1 d2 l2 u2 r1 d1

    Note that not even the unchanged default script worked.
     
  10. @Forecaster i did the same as you and all your scripts worked, i dont know what cause them to not compile. Also i fixed crash when drill has no fuel.
     
  11. Offline

    Forecaster

    I shall update and test again later today ^^

    Thanks!

    The scripts still wont compile. Not even the default test script.

    Refueling now works!

    I found another command exception which occur when you enter the /pdmake command with too few parameters.

    I will try to reset the config and see if default values work.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 17, 2016
  12. Offline

    PAPABEAR1010

    i would just like to thankyou for this , everything works great ,love it ,much appreciated
     
  13. Offline

    Clucky

    Are there permissions on this plugin or no? Nonetheless great pluign :D definitely going to use :D
     
  14. @Clucky not yet, but what permissions you want to see ? btw i have'nt updated this thread to newest version which you can find on git yet

    edit:
    what permisssion system you would like me to use ?
     
  15. Offline

    Clucky

    Mainly permissions on who can create scripts, who can use drills, and who can change the types of fuels, the speed, and anything else I may have missed that could be important. I am currently using the permissions system: permissions, I think its called... Lol, Anyways, thanks. If you can get around to it, would you also mind making this Residence compatable? Residence is a plugin that protects peoples residences in case you don't know what it is. They have an API that you can link into. Its just an idea :)
     
  16. v0.4 uploaded, btw updates will happen slower now cos im on vacations, if theres any bug please post it heare and ill fix it asap
     

Share This Page