mirror of
https://github.com/Minestom/Minestom.git
synced 2025-02-14 19:32:17 +01:00
fix custom block state id being ignored in PlayerBlockPlaceEvent
This commit is contained in:
parent
bde027432a
commit
5ffd44449d
@ -95,7 +95,7 @@ public class BlockPlacementListener {
|
|||||||
|
|
||||||
blockPosition.add(offsetX, offsetY, offsetZ);
|
blockPosition.add(offsetX, offsetY, offsetZ);
|
||||||
|
|
||||||
if(!canPlaceBlock) {
|
if (!canPlaceBlock) {
|
||||||
//Send a block change with AIR as block to keep the client in sync,
|
//Send a block change with AIR as block to keep the client in sync,
|
||||||
//using refreshChunk results in the client not being in sync
|
//using refreshChunk results in the client not being in sync
|
||||||
//after rapid invalid block placements
|
//after rapid invalid block placements
|
||||||
@ -143,10 +143,13 @@ public class BlockPlacementListener {
|
|||||||
if (!playerBlockPlaceEvent.isCancelled()) {
|
if (!playerBlockPlaceEvent.isCancelled()) {
|
||||||
|
|
||||||
// BlockPlacementRule check
|
// BlockPlacementRule check
|
||||||
final Block resultBlock = Block.fromStateId(playerBlockPlaceEvent.getBlockStateId());
|
short blockStateId = playerBlockPlaceEvent.getBlockStateId();
|
||||||
|
final Block resultBlock = Block.fromStateId(blockStateId);
|
||||||
final BlockPlacementRule blockPlacementRule = BLOCK_MANAGER.getBlockPlacementRule(resultBlock);
|
final BlockPlacementRule blockPlacementRule = BLOCK_MANAGER.getBlockPlacementRule(resultBlock);
|
||||||
final short blockStateId = blockPlacementRule == null ? resultBlock.getBlockId() :
|
if (blockPlacementRule != null) {
|
||||||
blockPlacementRule.blockPlace(instance, resultBlock, blockFace, blockPosition, player);
|
// Get id from block placement rule instead of the event
|
||||||
|
blockStateId = blockPlacementRule.blockPlace(instance, resultBlock, blockFace, blockPosition, player);
|
||||||
|
}
|
||||||
final boolean placementRuleCheck = blockStateId != BlockPlacementRule.CANCEL_CODE;
|
final boolean placementRuleCheck = blockStateId != BlockPlacementRule.CANCEL_CODE;
|
||||||
|
|
||||||
if (placementRuleCheck) {
|
if (placementRuleCheck) {
|
||||||
|
Loading…
Reference in New Issue
Block a user