[SPIGOT-1478] Getting drops for certain blocks not returning correct values. Created: 08/Feb/16  Updated: 23/Apr/19  Resolved: 23/Apr/19

Status: Resolved
Project: Spigot
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: Camden b Assignee: md_5
Resolution: Fixed Votes: 4
Labels: blocks, bug, event, spigot
Environment:

Linux Centos, 1 gb ram, Java 1.8.0_71, Latest Build of spigot (Right from Build tools)


Plugin: AutoHarvest (Custom)

 Description   

Basically it doesn't return any items for Cocoa (Yes tested a ton of times), Returns not the normal items when you break Crops (No Seeds) And it doesn't support Nether_Wart (No items returned)

    @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
    public void onHarvest(BlockBreakEvent event) {
        Player player = event.getPlayer();
        Block block = event.getBlock();
        Bukkit.broadcastMessage(block.getType().name() + plants.contains(block.getType()));
        if (!plants.contains(block.getType()) || autoHarvest.getPlayerManager().hasPlayer(player)) return;
        Location location = block.getLocation();
        Collection<ItemStack> drops = block.getDrops();
        if(block.getType() == Material.CROPS) drops.add(new ItemStack(Material.SEEDS, 2));
        for(ItemStack itemStack : drops) Bukkit.broadcastMessage(itemStack.getType().name());
        HashMap<Integer, ItemStack> stack = player.getInventory().addItem(drops.toArray(new ItemStack[drops.size()]));
        block.setType(Material.AIR);
        if (stack.size() != 0) {
            for (int i : stack.keySet()) location.getWorld().dropItem(location, stack.get(i));
            player.sendMessage(chatUtils.format(message));
        }
    }

Method I used ^

Any help would be nice



 Comments   
Comment by md_5 [ 23/Apr/19 ]

Resolved in 1.14

Comment by Senmori [ 06/Jan/18 ]

Just wanted to comment to say I'm working on this and to re-confirm it's broken.

Broken:

  • Nether wart
  • Wheat
  • Carrots
  • Potatoes
  • Beetroot
  • Cocoa

If I've missed any farming blocks please let me know so I can fix them all now.

I have a PR up now that fixes this issue. It also allows the use of silk touch of blocks that are able to be silk touched.

Comment by Blacky Paw [ 14/Feb/16 ]

Fixed this issue for cocoa beans, wheat and nether warts via a rather patchy workaround (see here: https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/pull-requests/190/overview). It might be that other blocks have similar issues too.

Generated at Fri Mar 14 09:35:34 UTC 2025 using Jira 10.3.3#10030003-sha1:d220e3fefc8dfc6d47f522d3b9a20c1455e12b7b.