mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-21 15:41:38 +01:00
Call BlockHandler#onInteract
This commit is contained in:
parent
78898bfa9b
commit
ddba34712e
@ -13,6 +13,7 @@ import net.minestom.server.instance.Chunk;
|
||||
import net.minestom.server.instance.Instance;
|
||||
import net.minestom.server.instance.block.Block;
|
||||
import net.minestom.server.instance.block.BlockFace;
|
||||
import net.minestom.server.instance.block.BlockHandler;
|
||||
import net.minestom.server.instance.block.BlockManager;
|
||||
import net.minestom.server.instance.block.rule.BlockPlacementRule;
|
||||
import net.minestom.server.inventory.PlayerInventory;
|
||||
@ -55,6 +56,12 @@ public class BlockPlacementListener {
|
||||
// FIXME: onUseOnBlock
|
||||
PlayerBlockInteractEvent playerBlockInteractEvent = new PlayerBlockInteractEvent(player, hand, interactedBlock, blockPosition, blockFace);
|
||||
EventDispatcher.call(playerBlockInteractEvent);
|
||||
if (!playerBlockInteractEvent.isCancelled()) {
|
||||
final var handler = interactedBlock.handler();
|
||||
if (handler != null) {
|
||||
handler.onInteract(BlockHandler.Interaction.from(interactedBlock, instance, blockPosition, player, hand));
|
||||
}
|
||||
}
|
||||
if (playerBlockInteractEvent.isBlockingItemUse()) {
|
||||
return;
|
||||
}
|
||||
|
@ -62,9 +62,7 @@ public final class EntityUtils {
|
||||
// TODO: check entire bounding box
|
||||
final BlockPosition blockPosition = entityPosition.toBlockPosition().subtract(0, 1, 0);
|
||||
try {
|
||||
final Block block = chunk.getBlock(blockPosition.getX(),
|
||||
blockPosition.getY(),
|
||||
blockPosition.getZ());
|
||||
final Block block = chunk.getBlock(blockPosition);
|
||||
return block.isSolid();
|
||||
} catch (NullPointerException e) {
|
||||
// Probably an entity at the border of an unloaded chunk
|
||||
|
Loading…
Reference in New Issue
Block a user