mirror of
https://github.com/EngineHub/WorldGuard.git
synced 2024-11-10 12:59:34 +01:00
Fire off block place for items that modify blocks.
This commit is contained in:
parent
903a831248
commit
426a709e43
@ -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))) {
|
||||
|
Loading…
Reference in New Issue
Block a user