How to break block with item?

Discussion in 'Spigot Plugin Development' started by KuramaStone, Sep 10, 2017.

  1. I am trying to break a block with a pickaxe and have said pickaxe's enchantments apply to said breaking. I tried using Block#breakNaturally(Itemstack item), but it merely dropped cobblestone when the pickaxe being used had the Silktouch enchantment.

    How would I do such a thing?
     
  2. sothatsit

    Patron

    I would report this as a bug, as the documentation states that the Block#breakNaturally(Itemstack item) method should function as you stated.
     
  3. Perhaps my version of Spigot 1.8.8 is simply flawed. I shall re-download the final release of it and try again.
     
  4. I have just downloaded and tried it (Downloaded using Buildtools) and it is still not working.

    Here is the code I'm using to break it:

    Code (Text):
        private void breakNaturally(BlockPosition blockposition) {
            org.bukkit.block.Block localBlock = GolemUtils.toLocation(this.c.world.getWorld(), blockposition).getBlock();
            Bukkit.broadcastMessage(localBlock.getType().toString() + " " + localBlock.getLocation().getBlockX() + " " + localBlock.getLocation().getBlockY() + " " + localBlock.getLocation().getBlockZ());
            localBlock.breakNaturally(CraftItemStack.asBukkitCopy(this.c.getEquipment(0)));
            Bukkit.broadcastMessage(this.c.getEquipment(0).getName());
        }
    Using the broadcasts I confirmed that it was indeed hitting the correct block and that I was using the silktouch pickaxe. Here is what the broadcasts gave:
    Code (Text):
    STONE -101 254 1
    Diamond Pickaxe
     
  5. Yes i found a bug in that version i tried using World#spawn but it never stopped giving me errors.
     
    • Informative Informative x 1