pmmp / PocketMine-MP

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

The place() function of the Block class seems to work as an interaction #5177

Closed ohYanoox closed 2 years ago

ohYanoox commented 2 years ago

Issue description

Steps to reproduce the issue

  1. Overwrite a block and register it, overwrite the place() function by adding some code before returning the parent _for example a vardump("hello world")
  2. In game, interact with this block in your hand with another block. Minecraft does not put the block down if the player is on the position. So place yourself on the position of the block you want to replace and right-click. Wanted: The block is not placed and the code of the place() function is executed

OS and versions

Plugins

Main class:

protected function onEnable(): void
    {
        BlockFactory::getInstance()->register(new TestBlock(new BlockIdentifier(1, 0), "Any Name", new BlockBreakInfo(1.5)), true);
    }

Block overwrite class:

class TestBlock extends Block
{
    public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null): bool
    {
        var_dump("Hello World");
        return parent::place($tx, $item, $blockReplace, $blockClicked, $face, $clickVector, $player);
    }
}

Crashdump, backtrace or other files

no crash
dktapps commented 2 years ago

place() isn't called if the block's projected collision box intersects with that of the player. That's expected behaviour.