Solved Delaying Block-instant break

Discussion in 'Plugin Development' started by Lordloss, Oct 13, 2015.

Thread Status:
Not open for further replies.
  1. Offline

    Lordloss

    Hello!

    This is the first issue i cant handle alone, and there is nothing helpful at google which matches my problem.

    For my custom Spleef-Plugin i need for the players instant-break of blocks.
    So i use the BlockDamageEvent and set instant breaking to true for the players.
    But this is much too fast, with it you can break many blocks at once.
    I tried cancelling the event if there has been a block break within the last few ticks,
    but cancelling it results in the problem that the event cannot fire again until the player looks at a different block.

    Setting them to gm 1 is no option.
    i know that its possible somehow, mineplex has a spleef game which does exactly what i want for it.
    I just dont know how they made it ;)

    I appreciate every help!
     
  2. Offline

    DoggyCode™

    You can set custom durability for the block, so a obsidian takes a dirt to break for example. At least, I think you can do this. Try using packets.
     
    Last edited: Oct 13, 2015
  3. Offline

    Lordloss

    This sounds possible but what do you mean with try using packets? i never done anything with this, and i wrote many many minigames etc in the past.

    i penetrated google really hard but found nothing how i could do that. please help

    EDIT by Timtower: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Oct 15, 2015
  4. Offline

    Zombie_Striker

    @Lordloss
    Then don't set it to instant breaking and find a block that is slower (such as dirt/snow/). If mining those blocks are too slow, then give the players shovels with efficiency (you may want to try out level 7 if instant breaking is "to fast")
     
  5. Offline

    Lordloss

    the problem is it has to work with every kind of block, because the game isnt on a plain field of 1 material. the game map could be out of everything
     
  6. Offline

    Zombie_Striker

    @Lordloss
    Then another option would be the following:
    1. Create a HashMap, where the key is a Block and the value is an Integer
    2. Create an OnClickeEvemt (PlayerInteractEvent)
    3. If the player clicks on a block in that world
    4. If the hashmap does not contain the block OR if the value in the hashmap is less than (a number like 5)
    5. Put that block into the hashmap with Value+1 as the value.
    6. If the hashmap does contain the block and the value is over (number like 5)
    7. Break the block. Remove from HashMap.
     
  7. Offline

    Lordloss

    this was my first try... the interactEvent wont fire another time if the player is still looking at the same block. so the players would have to click it multiple times.
     
  8. Offline

    Lordloss

    Still no neat solution to this. :( my actual workaround is transforming every touched block into snow, and transforming it back after a short delay if its not destroyed by a player. it works quite well, but now i have to give them a shovel to do this, and its ugly and inflexible. If there are any ideas out there i would be very amazed, there must be a better way of doing this, other servers have it too.
     
  9. Offline

    Scimiguy

    @Lordloss
    Have you tried cancelling the event and breaking the block yourself?
    I.E. cancel every blockbreak and break the block yourself, you can then handle every single blockbreak manually
     
  10. Offline

    Lordloss

    if i do this and delay the block breaking a bit, you can just slide over many blocks with your mouse, and they will also break nearly at the same time. Just a bit delayed... i try around a bit more if im home from work, but dont know if this can help.
     
  11. Offline

    khave

    Instead of using the block damage event, try using the interact event and check if it's a left click block. That way it'll fire multiple times I believe.
     
  12. Offline

    Lordloss

    @khave
    still like i said :p

    but nvm, i checked again how it was made at mineplex, and they seem to just cancel the break event and remove the block delayed...

    thanks everybody for your help, problem solved!
     
  13. Offline

    Scimiguy

    @Lordloss
    I swear that's exactly what I told you to do lol

    Mark this thread as solved then
     
Thread Status:
Not open for further replies.

Share This Page