PocketMine-MP icon indicating copy to clipboard operation
PocketMine-MP copied to clipboard

Blocks which require tools to harvest don't drop in explosions

Open buchwasa opened this issue 7 years ago • 6 comments

Issue description

When using an explosion (TNT, explodeA(), etc.) it doesn’t drop every block it should.

  • Expected result: The explosion drops stone and other items that require tools to gather.
  • Actual result: Only blocks that didn’t require tools to drop spawned.

Steps to reproduce the issue

  1. Use any method of an explosion.
  2. Check the results on the explosion.
  3. Be amazed that only certain blocks dropped.

OS and versions

  • PocketMine-MP: fa644edef3db4abaa050cb9cb0aaa94170e132df
  • PHP: 7.2.1
  • Server OS: Windows 10
  • Game version: Both

Plugins

  • Test on a clean server without plugins: is the issue reproducible without any plugins loaded?

There are no plugins loaded. If the issue is not reproducible without plugins:

  • Have you asked for help on our forums before creating an issue?
  • Can you provide sample, minimal reproducing code for the issue? If so, paste it in the bottom section
  • Paste your list of plugins here (use the 'plugins' command in PocketMine-MP)

Crashdump, backtrace or other files

  • Do not paste crashdumps into an issue - please use our Crash Archive at https://crash.pmmp.io for submitting crash reports to not spam the issue tracker. Add links to your reports in the Crash Archive here.
  • Please use gist or anything else to add other files and add links here
  • ...

buchwasa avatar Mar 14 '18 15:03 buchwasa

might be due to this https://github.com/pmmp/PocketMine-MP/blob/master/src/pocketmine/level/Explosion.php#L201

$air = ItemFactory::get(Item::AIR);
foreach($blocks as $block){
    foreach($block->getDrops($air) as $drop){...}
}

Muqsit avatar Mar 14 '18 15:03 Muqsit

@Muqsit, a temporary fix is changing getDrops to getDropsForCompatibleTool() which doesn’t completely fix it.

buchwasa avatar Mar 14 '18 15:03 buchwasa

The problem here is that getDrops() requires a compatible tool. However circumventing the tool check is not a correct fix (this will cause tallgrass and other things to drop).

dktapps avatar Mar 17 '18 16:03 dktapps

@dktapps why not add a new function like getSilkTouchDrops, $block->getExplosionDrops()?

TheAz928 avatar Mar 26 '18 04:03 TheAz928

I would prefer not adding more methods for this if it can be reasonably avoided.

dktapps avatar Mar 26 '18 07:03 dktapps

It looks like we can fix this by having explosions pretend to be diamond pickaxes for Block->getDrops().

Out of all the blocks which require a tool to harvest, the vast majority require a pickaxe to drop. The only ones that don't which are currently implemented are these:

Cobweb requires 17, is insta break? 
Dead Bush requires 16, is insta break? 1
Double Tallgrass requires 16, is insta break? 1
Large Fern requires 16, is insta break? 1
Snow Block requires 2, is insta break? 
Snow Layer requires 2, is insta break? 
Fern requires 16, is insta break? 1
Tall Grass requires 16, is insta break? 1
Hanging Roots requires 16, is insta break? 1
Small Dripleaf requires 16, is insta break? 1

Basically all of these are "delicate" blocks which I wouldn't expect an explosion to drop the "compatible" drops for anyway. So it looks like there's no need to account for anything other than pickaxes.

dktapps avatar Sep 20 '25 17:09 dktapps