FASTER MINING [DONE]

Discussion in 'Plugin Development' started by Samkio, Jun 15, 2011.

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

    Samkio

    Howdy Folks,
    I am in need of creating a way of producing faster mining. (Not insta-mine).
    So for instance 10seconds to mine obsidian as opposed to 15seconds.
    However i am come to a dead end and i am lack-less of ideas on how to achieve this.
    The main problem is that their are only really 2 events that can be used.
    The blockDamage and playerInteract. I have tried messing around with timers and blockDamage but i can't check to see if the block is still being destroyed by the user.

    I need someone that can think outside the box and give some ideas on how to achieve this.

    Much Thanks
    Samkio.
     
  2. Offline

    Jako

    If you could find a way to capture a mousedown and a mouseup event, that could allow you to check that... You could also see if the blockdamage event is thrown on a certain timer, then you could check how many times the blockdamage event is thrown per block. I'm not sure how that event works, but if it triggers on a time based, it might work. Just some random ideas, I will look into a way to bind a mouseup and mousedown event into minecraft.
     
  3. Offline

    CptSausage

    Maybe you can use the playerInteractEvent to "predamage" the block?
    If someone uses the picaxe you could do the first 1/3 damage to the block and mining does the rest?
     
  4. Offline

    Jako

    I think I found a way to do this... It looks like onPlayerAnimation happens once a second, so, you can check for the animation, and every time the animation happens it's another second on the tick. You store some sort of array or arraylist that contains the player, the block they are targeting, and how many animations, You create the variable when the blockDamage event happens, then every time the animation event happens you add to the tick. Once the tick hits 10 you delete the block and drop the item naturally.

    Edit: Also if the damage event occurs again, that means they have selected another block. Then you can reset their variable. I just looked, it seems the animation is not every second, but you can use a time variable to check timeElapsed etc. I guess you've got enough experience, you should be able to make something work using that.
     
  5. Offline

    Afforess

    I tried that a few months ago, it didn't really work. There is no way short of client modding. Interesting idea though, I'll mark it down to do for BukkitContrib.
     
  6. Offline

    Jako

    Just wondering, what made that not work? I might take this as a personal challenge, the faster mining could be pretty cool.
     
  7. Offline

    Afforess

    It's not adjustable, and not quite often enough. It really was a poor solution...

    You are free to look at my implementation - IDK if all the methods are still there, it was written a while back, but you can see what I was doing at any rate:

    http://dl.dropbox.com/u/49805/FasterMiningsrc.7z
     
  8. Offline

    Samkio

    He shoots he scores! :D
    Added FasterMining. Higher your level the faster you mine. Just for the record you saw this first at LevelCraft! 16/06/11


    It is achieved by 3 events. BlockDamage,BlockBreak and PlayerAnimation.
    When the player damages a block it creates an entry with the block/player/int.
    On every playeranimation the int goes up by 1. If it exceeds so much then emulate a block destruction.
    If the block is broken before this happens remove the entry. :)
    I actually managed to do this soon after i wrote this topic and i forgot to subscribe so i didn't see your posts -.-
    Thanks anyway.
    Will provide source when i have the time :)





     
  9. Offline

    Torrent

    *steals and adds to excavation* ;)
     
  10. Offline

    Samkio

    @Torrent
    Watch the wave of new Faster mining plugins ;)
     
  11. Offline

    Afforess

    2 Questions:

    1.) Is the speed configurable?
    2.) What happens if I hold the mouse, not clicking? What about clicking rapidly? Animation events do not fire consistently for those 2 cases, IIRC.
     
  12. Offline

    Samkio

    @Afforess
    1)The speed is configurable. Effectively you define how many times the user hits the block. The less hits the faster.
    2). Holding the mouse down is mining and will mine fast.
    - Clicking Rapidly will trigger a new BlockDamge* event and will therefore reset the counter and won't mine.
     
  13. Offline

    Jako

    A little bit rude, however it seems that it wasn't a bad solution... My idea sounds exactly like what samkio is using...
     
  14. Offline

    Afforess

    Rude? What is rude is you taking my posts out of context. I was talking about MY SOLUTION. It was before Samkio even posted about his.
     
  15. Offline

    Jako

    Ahh, misunderstood you.
     
  16. Offline

    Samkio

    Oh also forgot to add. on the animation event ensure the player is still looking at the block. If not they could start mining the block and then look somewhere else. Very funny when i was testing :p
     
    mbsuperstar1 likes this.
  17. Offline

    Resident Emil

    Could this be adapted to slower mining? It might sound like a strange question, but I'm exploring different ways of protecting regions by increasing mining time for players not in the team. Instead of having mining disabled like usually in protection plugins, players not in the team need to spend more time to mine.
     
  18. Offline

    Samkio

    @Resident Emil
    Yes it could be. You would have to disable the blockBreak event however. It may look ugly client side. But it is possible.
     
  19. Offline

    Resident Emil

    Hi,
    I downloaded Afforess source, but is it really the correct one? Can't find anywhere in the source that int is increased by one per playerAnimation and there is no blockBreak event (there is a setTypeId(0) followed by a dropItem).
    Are we looking at the same code?
    I began programming Bukkit plugins yesterday so it might very well be me missing something :)
     
  20. Offline

    Rednax_

    In 1.9 there will be a new way to do this. Just add and remove an echantment on and from an item that allows faster mining. Not perfect, but easier than the current implementation.

    Please note I'm just giving an other way of doing this.
    Using BlockDamage, BlockBreak and PlayerAnimation sounds like a better option to me as well.
     
    Samkio likes this.
  21. Offline

    Lolmewn Retired Staff

    Hey @Samkio , do you have the source somewhere for me? =D
     
  22. Offline

    Sleaker

Thread Status:
Not open for further replies.

Share This Page