Skip to content
Permalink
Browse files

Fire off block place for items that modify blocks.

  • Loading branch information...
wizjany committed Jun 2, 2019
1 parent 903a831 commit 426a709e430a67f3a76d41dbfc56cc1ada1474eb
@@ -423,7 +423,9 @@ public void onPlayerInteract(PlayerInteractEvent event) {
placed = clicked.getRelative(event.getBlockFace());

// Only fire events for blocks that are modified when right clicked
modifiesWorld = isBlockModifiedOnClick(clicked, event.getAction() == Action.RIGHT_CLICK_BLOCK) || (item != null && isItemAppliedToBlock(item, clicked));
final boolean hasItemInteraction = item != null && isItemAppliedToBlock(item, clicked);
modifiesWorld = isBlockModifiedOnClick(clicked, event.getAction() == Action.RIGHT_CLICK_BLOCK)
|| hasItemInteraction;

if (Events.fireAndTestCancel(new UseBlockEvent(event, cause, clicked).setAllowed(!modifiesWorld))) {
event.setUseInteractedBlock(Result.DENY);
@@ -437,6 +439,12 @@ public void onPlayerInteract(PlayerInteractEvent event) {
}
}

if (hasItemInteraction) {
if (Events.fireAndTestCancel(new PlaceBlockEvent(event, cause, clicked.getLocation(), clicked.getType()))) {
event.setUseItemInHand(Result.DENY);
}
}

// Special handling of putting out fires
if (event.getAction() == Action.LEFT_CLICK_BLOCK && placed.getType() == Material.FIRE) {
if (Events.fireAndTestCancel(new BreakBlockEvent(event, create(event.getPlayer()), placed))) {

0 comments on commit 426a709

Please sign in to comment.
You can’t perform that action at this time.