mirror of
https://github.com/Minestom/Minestom.git
synced 2025-02-01 21:11:33 +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.Instance;
|
||||||
import net.minestom.server.instance.block.Block;
|
import net.minestom.server.instance.block.Block;
|
||||||
import net.minestom.server.instance.block.BlockFace;
|
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.BlockManager;
|
||||||
import net.minestom.server.instance.block.rule.BlockPlacementRule;
|
import net.minestom.server.instance.block.rule.BlockPlacementRule;
|
||||||
import net.minestom.server.inventory.PlayerInventory;
|
import net.minestom.server.inventory.PlayerInventory;
|
||||||
@ -55,6 +56,12 @@ public class BlockPlacementListener {
|
|||||||
// FIXME: onUseOnBlock
|
// FIXME: onUseOnBlock
|
||||||
PlayerBlockInteractEvent playerBlockInteractEvent = new PlayerBlockInteractEvent(player, hand, interactedBlock, blockPosition, blockFace);
|
PlayerBlockInteractEvent playerBlockInteractEvent = new PlayerBlockInteractEvent(player, hand, interactedBlock, blockPosition, blockFace);
|
||||||
EventDispatcher.call(playerBlockInteractEvent);
|
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()) {
|
if (playerBlockInteractEvent.isBlockingItemUse()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -62,9 +62,7 @@ public final class EntityUtils {
|
|||||||
// TODO: check entire bounding box
|
// TODO: check entire bounding box
|
||||||
final BlockPosition blockPosition = entityPosition.toBlockPosition().subtract(0, 1, 0);
|
final BlockPosition blockPosition = entityPosition.toBlockPosition().subtract(0, 1, 0);
|
||||||
try {
|
try {
|
||||||
final Block block = chunk.getBlock(blockPosition.getX(),
|
final Block block = chunk.getBlock(blockPosition);
|
||||||
blockPosition.getY(),
|
|
||||||
blockPosition.getZ());
|
|
||||||
return block.isSolid();
|
return block.isSolid();
|
||||||
} catch (NullPointerException e) {
|
} catch (NullPointerException e) {
|
||||||
// Probably an entity at the border of an unloaded chunk
|
// Probably an entity at the border of an unloaded chunk
|
||||||
|
Loading…
Reference in New Issue
Block a user