Use correct placed block position for sound (#12410)
Previously the server attempted to compute the block placed by using the BlockPlaceContext. This approach however fails on replacable blocks, as the BlockPlaceContext computes this during its construction, which happened after the actual world modification. The commit reworks this approach and now stores metadata in the InteractionResult which can later be read. The diff is structured to allow for easy future expansion of the tracked metadata.
This commit is contained in:
@@ -56,6 +56,15 @@
|
||||
level.playSound(
|
||||
player,
|
||||
clickedPos,
|
||||
@@ -88,7 +_,7 @@
|
||||
);
|
||||
level.gameEvent(GameEvent.BLOCK_PLACE, clickedPos, GameEvent.Context.of(player, blockState));
|
||||
itemInHand.consume(1, player);
|
||||
- return InteractionResult.SUCCESS;
|
||||
+ return InteractionResult.SUCCESS.configurePaper(e -> e.placedBlockAt(clickedPos.immutable())); // Paper - track placed block position from block item
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -137,8 +_,19 @@
|
||||
|
||||
protected boolean canPlace(BlockPlaceContext context, BlockState state) {
|
||||
|
||||
Reference in New Issue
Block a user