pmmp / PocketMine-MP

A server software for Minecraft: Bedrock Edition in PHP
https://pmmp.io
GNU Lesser General Public License v3.0
3.25k stars 1.53k forks source link

Block interactions are not executed when sneaking #5193

Open ColinHDev opened 2 years ago

ColinHDev commented 2 years ago

Issue description

Steps to reproduce the issue

  1. Take some bone meal
  2. Sneak
  3. Interact with grass blocks

OS and versions

Plugins

---

Crashdump, backtrace or other files

---

dktapps commented 2 years ago

This sounds like a bug in vanilla to me.

ColinHDev commented 2 years ago

That's what I also thought at first. But it's the same in Java Edition. And it's not limited to bone meal. It's the same case with "shovels and pathways" and "compass and lodestones" (although that's not implemented in PM anyway).

I've dug a bit around this in Java Edition's source (I'm not that experienced with IDA and more familiar with Java). Both Java and PM have use methods in item and block classes and those of the block classes are only called if the player is not sneaking. But, unlike PM, they implemented the fertilizer or "shovel" logic not in the GrassBlock class like PM, but in the respective item class, which would explain this behaviour.

dktapps commented 2 years ago

If this is correct, I'd also expect paintings, spawn eggs and other items to work while sneaking too.

ColinHDev commented 2 years ago

It does. While sneaking, you can also spawn mobs with spawn eggs or place e.g. either paintings or item frames.

IvanCraft623 commented 1 month ago

Happens thanks to this line.

This is also causing players to be unable to interact with copper doors/trapdoors to wax/unwax them or remove oxidation (They need to be sneaking to do this)

Change the line to

if((!$player->isSneaking() || $item->isNull() || !$item instanceof ItemBlock) && $blockClicked->onInteract($item, $face, $clickVector, $player, $returnedItems)){

seems to fixe it.