[INACTIVE][MECH] ToughBlocks v0.1 - Who said mining should be easy? [499]

Discussion in 'Inactive/Unsupported Plugins' started by cyklo, Feb 28, 2011.

  1. Offline

    cyklo

    ToughBlocks - Who said mining was easy?
    Version: 0.1
    Download: toughblocks_0_1.tar.gz | Source Code
    Like this plugin? Donate a buck!

    ToughBlocks is a plugin comissioned by RUtaq (thanks!), designed to make mining tougher and more of a slog for realism-style servers. When you "destroy" a block with a tool, instead of disappearing instantly you remove some of its "strength". You then have to mine the block multiple times over to finally remove it.

    As with my other plugins, ToughBlocks is a blank canvas for your customization. You can set rules in the configuration file to determine how many "destruction" iterations a block must go through before it disintegrates. In addition, you can specify that different tools do different amount of damage to the block. For example, you could have everything require eight iterations to destroy stone, except diamond picks which only take two iterations. Or even the inverse - you can say that all tools are useless except wooden and stone!

    To install, simply decompress the contents to your plugins directory. Then, copy toughblocks/config.sample.yml to toughblocks/config.yml and edit away!

    For the values you can use in your config files, use the blocks and items listed in http://cliqr.org/V (you can also use ALL and DYE)



    Example config.yml (open)

    Code:
    # Set this to "low" to reduce number of boot messages
    verbosity: normal
    
    # Try adjusting this if you have compatibility problems with other plguins.
    # Default: "lowest". Can also use "low", "normal", "high", "highest".
    priority: lowest
    
    # Do we print out progress messages?
    showprogress: true
    
    toughblocks:
    ##########
    # This is a sample configuration file for ToughBlocks
    # Configuration blocks are set out as followed:
    #
    # NAME_OF_BLOCK:
    #     - tool: NAME_OF_TOOL (or ALL for all tools, or a list of tools like this: [TOOL_A, TOOL_B, TOOL_C])
    #       damage: DAMAGE_VALUE (anything between 0 and 360)
    #
    # For lists of appropriate values for
    # blocks and tools, see: http://cliqr.org/V
    #
    # If you want to specify different tools,
    # keep adding sub-blocks, but prefix the tool
    # line with a dash, like so:
    #
    # GRASS:
    #     - tool: [GOLD_SPADE, DIAMOND_SPADE]
    #       damage: 180
    #     - tool: ALL
    #       damage: 45
    #
    # A tool: ALL statement sets the drop for any
    # tools not yet specified. Therefore, it should
    # always be the last item in a list.
    #
    # Uncomment any of the blocks below to see some example
    # behaviours
    #
    ##########
    # Make stone take twice as long
    ###
    
        STONE:
            - tool: ALL
              damage: 180
    
    ##########
    # Make grass three times harder unless using a golden spade
    ###
    
        GRASS:
            - tool: GOLD_SPADE
              damage: 360
            - tool: ALL
              damage: 120
    
    ##########
    # Make cobblestone eightr times as hard unless using a pick,
    # when it is twice as hard instead
    ###
    
        COBBLESTONE:
            - tool: [WOOD_PICKAXE, STONE_PICKAXE, IRON_PICKAXE, DIAMOND_PICKAXE, GOLD_PICKAXE]
              damage: 180
            - tool: ALL
              damage: 45
    
    ##########
    # Make Obsidian impossible!
    ###
    
        OBSIDIAN:
            - tool: ALL
              damage: 0
    


    Changelog (open)

    Version 0.1
    • First release (0.1)
     
  2. Offline

    QQCucumber

    Are you able to use this to make mining some blocks easier? I want to make Obsidian easier to mine on my server.
     
  3. Offline

    cyklo

    Afraid not. As far as I can tell, however long Minecraft says it takes to break a block, that's how long it takes. This plugin lets you set integer multiples of that value, nothing smaller.
     
  4. Offline

    QQCucumber

    That's strange because I know for a fact that there was an hmod plugin that allows you to do this, it wasn't instant breakage either.
     
  5. Offline

    cyklo

    I can only assume relevant hooks have not yet been implemented in Bukkit. ((BlockBreakEvent) event).setCancelled(true) and ((BlockInteractEvent) event).setCancelled(true) seemingly do nothing to prevent or slow down breakage. Do you know if any of the other hooks have the ability to control this behaviour?
     
  6. Offline

    Jorrdan

    Not sure why, but it isn't working for me atm. It's saying "ToughBlocks: no values found in config file!" I copied over the data from sample to the normal config file so that isn't the problem. Any idea what gives?
     
  7. Offline

    cyklo

    That error message means it can't find any block definitions in the file. Make sure that your file has the block names properly indented from the left margin by four spaces. Otherwise, copy the file to Pastebin so I can have a look.
     
  8. Offline

    fullwall

    The blockbreakevents are broken at the moment. I think to actually set the damage value, you'd have to change the durability value in net.minecraft.server.Block.byId[your block ID] (this requires adding craftbukkit as an external jars). There are probably other ways to do this, but they'd most likely be in the minecraft server code.
     
  9. Offline

    Jorrdan

    Sorry, it works great. I'm new to bukkit, and the way some plugins are configured. With a little trial and error in a new config i am now able to set things properly. Thanks for the quick reply!
     
  10. Offline

    RUtaq

    Hmm I noticed some strange behavior.

    I am reworking the harvesting mechanics for trees. I wanted to slow down the destruction of Leaves and also make a specific list of the only items that could be used to chop wood.


    Code:
        LEAVES:
            - tool: ALL
              damage: 180
    
        LOG:
            - tool: STICK
              damage: 90
            - tool: WOOD_AXE
              damage: 120
            - tool: STONE_AXE
              damage: 120
            - tool: IRON_AXE
              damage: 180
            - tool: GOLD_AXE
              damage: 180
            - tool: DIAMOND_AXE
              damage: 360
            - tool: ALL
              damage: 0


    The config.yml works fine for restricting the cutting of wood, but Leaves still break as normal no matter what I use in the config.yml, but I do see a console message " A plugin cancelled the block break event "

    Any ideas ? Are LEAVES handled differently in Minecraft than other types of Blocks ?
     
  11. Offline

    Blackstorm72

    Intersting plugin - Will go well with the RPG element i'm working on :)
    Will check it out when I'm out of college for the day...
     
  12. Offline

    IronFerret

    set obsidian to 100 breaks >:D
     
  13. Offline

    Sieabah

    Love this idea!

    I can only imagine the pain the guy is feeling if he is punching that block... Especially if my own finger is getting tired from holding down the mouse button.
     
  14. Offline

    cyklo

    Just tried your configuration and the LEAVES thing works for me. Although your LOG thing has exposed a problem that a birch log turns into regular wood. Presumably goes the same for wool and other configurable things.

    There were some problems with block breaking events a while ago, and if you've got that message popping up in your server log, you might be running one of the broken ones. I'm running #477 and it's all working fine - can you try against a newer version of CraftBukkit?
     
  15. Offline

    RUtaq

    I installed Craftbukkit verison 2277 and did some more research.

    I started out by removing all my plugins except for toughblocks. Here is my simple test of making tough LEAVES.


    Code:
    verbosity: normal
    
    priority: normal
    
    showprogress: true
    
    toughblocks:
    
        LEAVES:
            - tool: ALL
              damage: 120

    I did a quick test and this worked fine. LEAVES took three times longer to break.



    So next I began to add my plugins back, one at a time and right away found the problem was with otherblocks :(

    Here is the simple test setup for Otherblocks to make LEAVES drop nothing.

    Code:
    verbosity: normal
    
    priority: lowest
    
    otherblocks:
    
           LEAVES:
    
                - tool: ALL
                  drop: AIR
                  chance: 100
       

    So the above configs should make LEAVES take 3 times longer to break and when broken they drop nothing.

    But in testing, when running both otherblocks and toughblocks together the LEAVES will break on the first attempt no matter what the toughblock damage setting is. But when the LEAVES do break they don't drop anything.

    I tried to adjust the priority of toughblocks to make it higher than otherblocks but it didn't change the results of the test.

    My Guess is that otherlocks is maybe setting the event cancel atfer running and when otherblocks go to do it's thing it see's the cancel and exits.
     
  16. Offline

    cyklo

    Ah right... here comes the counter-intuitive part...

    Priorities are kind of backwards in Bukkit. "Lowest" priority events happen FIRST, so that higher priority events have the chance to override their result. So in this case, by OtherBlocks having the lower priority, it is converting the leaves to air before ToughBlocks gets a look-in. To get ToughBlocks to act first, you should make it the lowest, and make OtherBlocks a higher priority to come after.

    I might make up my own naming scheme to run in tandem, to make this slightly less confusing...
     
  17. Offline

    RUtaq

    Thanks Cyklo, I switched around the priority and it works fine now.
     
  18. Offline

    Xavious1987

    Hey guys,

    Im new here, Developing a server.

    1. Is there a plugin to modify tools rate of break which is the opposite to this plugins block break rate.
    2. Instead of the following using LOG as the identifier, Can we use the ID number? I ask this, as When breaking trees or leaves of different shades, it reverts it back to the boring LOG type 17, when I want LOG type 17 - 1 or 17 - 2.
    Any Suggestions or support here?

    LOG (can we do ID: 17)?:
    - tool: STICK
    damage: 90
    - tool: WOOD_AXE
    damage: 120
    - tool: STONE_AXE
    damage: 120
    - tool: IRON_AXE
    damage: 180
    - tool: GOLD_AXE
    damage: 180
    - tool: DIAMOND_AXE
    damage: 360
    - tool: ALL
    damage: 0
     
  19. Offline

    ImKharn

    The only thing I want is to be able to mine Bedrock.
    I want it to take 4 minutes per block.
    And have everything else the same as Vanilla minecraft.

    Is this possible with your plugin?
    Someone directed me here.
     
  20. Offline

    cyklo

    Yes. Looking at the minecraft wiki, it takes 15 seconds with a diamond pick, 50 seconds with all other tools

    Therefore given each block is treated as having 360 "health", you want to configure it so that:
    - a diamond pick depletes 23 health each time (takes 16 breaks (23*16 = 368), = 4 minutes)
    - all other tools deplete by 72 health (takes 5 breaks (72*5 = 360), = 4 minutes)
     
  21. Offline

    ImKharn

    Thanks for the fast response.

    But your response was for obsidian.

    I said Bedrock.

    Can your mod allow me to destroy bedrock?
     
  22. Offline

    cyklo

    Oops. Erm, no, sorry. Since no tool can cause damage at any speed, it can't slow down / speed up a rate of zero.
     
  23. Offline

    Tulips

    I cant seem to make it so iron door will become indestructible... can i get help?
     
  24. Offline

    wildshoetwt

    this is the error i get, this is the first entry of my config that seems to be causing the problem
    EDIT: SOLUTION FOUND, I had to delete lots of stuff 1 by 1 to find the error, as the obsidian was fine...

    eventually it turned out I copy and pasted your mis-spelling in the sample config....

    In fact, I had used "WOODEN" for all my tools, the correct form is "WOOD_TOOLNAME", everything works fine now... but you should change that

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

    cyklo

    The original error you posted is because the whitespace wasn't laid out correctly.

    As for the misspelling - thanks, shall fix.
     
  26. Offline

    Fright01

    Setting IRON_DOOR_BLOCK will do this. However BUG the door will remove the block you are attacking, then place the block used as the bottom of the door, into the space where you were attacking. Also, this will drop a door.

    So In the end you end up with 2 doors when before you had one.

    Also, while breaking, you end up with only half a door. So assuming I wanted to make it take any arbitray amount longer to destroy. Someone has built a iron door, and the peice above is an arbitrary easy block all other pieces obsidian. After the first iteration of attacking the bottom block, you now have a 2 block space to fit through and the iterations are not important.

    Please make it so that this will not duplicate ANY amount of doors, as well as remain FULLY intact during the breakdown.

    Using CHEST, the items will drop on first iteration.
     
  27. Offline

    Fright01

    sorry for double-posting.

    If you were interested, I did fix the issue.

    I took this:
    Code:
    if(newHealth <= 0) {
                    parent.blockHealth.remove(block.hashCode());
                } else {
                    parent.blockHealth.put(block.hashCode(), newHealth);
    
                    block.setType(Material.DIRT); // Can't set to AIR for some reason
                    block.setType(obc.original);
                    event.setCancelled(true);
    
                    if(parent.showProgress && obc.damage > 0) {
                        event.getPlayer().sendMessage("Block " + Math.round(100 * ((double) newHealth / (double) ToughBlocks.MAX_BLOCK_HEALTH)) + "% intact...");
                    }
                }
    and changed it to this:

    Code:
                if (newHealth <= 0) {
                    parent.blockHealth.remove(block.hashCode());
                } else {
                    parent.blockHealth.put(block.hashCode(), newHealth);
    
                    event.setCancelled(true);
    
                    CraftPlayer craft = (org.bukkit.craftbukkit.entity.CraftPlayer) event.getPlayer();
    
                    craft.getHandle().a.b((net.minecraft.server.Packet) new Packet53BlockChange(block.getLocation().getBlockX(), block.getLocation().getBlockY(), block.getLocation().getBlockZ(), ((CraftWorld) block.getLocation().getWorld()).getHandle()));
    
                    if (parent.showProgress && obc.damage > 0) {
                        event.getPlayer().sendMessage("Block " + Math.round(100 * ((double) newHealth / (double) ToughBlocks.MAX_BLOCK_HEALTH)) + "% intact...");
                    }
    
                }
    So removed the 2 lines you had as a quick fix for client updating. Then sent a new Packet53BlockChange().

    This achieves the same goal, but removes the issues with doors and chests (and maybe some other blocks).
     
  28. Offline

    Dangirdas

    Can you please update it? :D
     
  29. Offline

    peaced

    I'm very interested in an update too.

    Edit : just tried it, it seems that tools gets repaired when a block is broke at 0% ?

    The item get damage correctly each time the block looses %, but when the block finally disapear, the tool gets repaired.
     
  30. Offline

    peaced

    I had a look at the code and I suspect this line to be the culprit for tools damage not being registered :
    Code:
    event.setCancelled(true);


     

Share This Page