-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Description
Expected behavior
After placing the fourth end crystal the ender dragon respawns and the BlockPlaceEvent is not being called because of the end portal regeneration.
Observed/Actual behavior
After placing the fourth end crystal to respawn the ender dragon while also having the following listener enabled, it gets really strange. The player gets back one end crystal because a BlockPlacEvent was triggerd due to end portal regeneration.
public class BlockPlaceListener implements Listener {
@EventHandler
public void onBlockPlace(BlockPlaceEvent event) {
final Player player = event.getPlayer();
if (player.getGameMode() != GameMode.CREATIVE && event.getBlock().getType() == Material.BEDROCK) {
event.setCancelled(true);
}
}
}Steps/models to reproduce
Register the following listener in your plugin.
public class BlockPlaceListener implements Listener {
@EventHandler
public void onBlockPlace(BlockPlaceEvent event) {
final Player player = event.getPlayer();
if (player.getGameMode() != GameMode.CREATIVE && event.getBlock().getType() == Material.BEDROCK) {
event.setCancelled(true);
}
}
}Place the four end crystals to respawn the ender dragon and look at the hotbar there should be now an end crystal.
Plugin and Datapack List
Paper version
Other
So i tried also digging deeper into this issue and it seems like the problem is caused due to the end crystal item useOn context calls the regeneration process of the end portal what causes blocks to be first replaced and than being placed again. I have found out, that before the useOn context of an itemstack interaction starts there is an boolean serverLevel.captureBlockStates that indicates if blocks that are getting placed should be saved for later to determine what BlockPlaceEvent should be called if there are any blocks that were placed. The problem is that while the fourth end crystal is getting placed this triggers the end portal regeneration which causes the blocks that are getting placed to be captured because the boolean is still true for this context and this should not be the case because the end crystal is an entity and should only trigger an EntityPlaceEvent.
I have come to the following solution TehManu/cheetah@a163783 but maybe there is a better solution to fix this.

