Solved Change Block Break Speed

Discussion in 'Plugin Development' started by Ub1, May 17, 2020.

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

    Ub1

    Hi, so I am working on a plugin that implements the use of the breakNaturally event. I have it so that when the player moves, the block under their feet is destroyed, by breakNaturally. The problem is that it happens instantly. I have looked around but I can't find anything that changes the BreakNaturally speed from creative to survival. I was wondering if anyone had an idea how I could implement it.

    Code if you need it:

    Code:
     
     Location loc = p.getLocation();
     loc.setY(loc.getY() - 1);
    Material b = loc.getBlock().getType();
    if ( b != Material.BEDROCK &&  b != Material.END_PORTAL_FRAME  &&  b != Material.END_PORTAL &&  b != Material.OBSIDIAN && b != Material.WATER && b != Material.SPAWNER && b != Material.NETHER_PORTAL && b != null) {
         
    loc.getBlock().breakNaturally();
    
    }
     
    Last edited: May 17, 2020
  2. Offline

    Tango_

    #breakNaturally is referring to the moment the block drops, not the animation of the block breaking.

    If you want to delay the block breaking you could schedule delayed bukkit tasks, but if you want the actual breaking animation you will probably need to look into packets.
     
  3. Offline

    Ub1

    Ok, I have been looking around at Bukkit Runnable before I posted this but I couldn't get it to work. Would you have any idea of something that would slowly destroy the block under the players feet?
     
  4. Offline

    wand555

    Slowly destroying the brock is not possible with Bukkit/Spigot and therefore are Bukkit Runnables not your problem. You need to lock into packets (significantly harder than having a Runnable that just removes the block after some ticks).
    EDIT: This is probably what you're looking for, but I cannot help you any further.
     
    Ub1 likes this.
  5. Offline

    Ub1

    Ok thank you

    EDIT: I spent an entire week looking to slow it down, and the issue with bukkit runnable was that I hadn't properly linked my OnEnable extends JavaPlugin file to the main one. I hate myself. Thank you anyway.
     
    Last edited: May 19, 2020
Thread Status:
Not open for further replies.

Share This Page