-
Bug
-
Resolution: Unresolved
-
None
-
1.21.10.21 Preview
-
Confirmed
-
Multiple
-
1246351
Following on from MCPE-176244 I am experiencing a similar issue.
The event playerInteractWithBlock is called multiple times when a player interacts with a block. This applies to both world's BeforeEvents and AfterEvents.
I have used this script to show the problem:
import { world, system, BlockPermutation } from "@minecraft/server"; let i = 0; world.beforeEvents.playerInteractWithBlock.subscribe((event) => { world.sendMessage("Before Event " + (i++)); }); world.afterEvents.playerInteractWithBlock.subscribe((event) => { world.sendMessage("After Event " + (i++)); });
Steps to Recreate
- Create a world with the attached Behavior Pack and Beta APIs enabled.
- Interact with any block.
- The Before Event message appears a few times (between 3-7)
- Not as expected - expectation is this message appears only once.
- The After Event message appears a few times (between 3-7)
- Not as expected - expectation is this message appears only once.
- Point at at any block and hold down the interact button - I was using the right-mouse button to observe this.
- The Before and After Event messages appear multiple times, in batches of 3 or 4 each. They do not stop until the button is released.
- Not as expected - expectation is one Before message followed by one After message, and no more.
- Place an object that has an interaction, for example a Door.
- Interact with the object.
- One Before message appears, followed by one After message.
- Working as expected.