mirror of
https://github.com/EngineHub/WorldGuard.git
synced 2025-01-24 00:51:22 +01:00
Fix ItemStack conversion on block place on MC 1.21 (#2093)
* Fix ItemStack conversion on block place This issue is present in 1.21 because some materials do not convert 1:1 to item types. This throws an exception in the ItemStack constructor. Example: WALL_TORCH is a valid block but not a valid item, only TORCH is a valid item. So, use the item in hand instead, creating a copy with quantity set to 1, for issueing the use item event. * Use ItemStack as-is. Closes #2092. --------- Co-authored-by: wizjany <wizjany@gmail.com>
This commit is contained in:
parent
2bd426baf8
commit
7783e9ae3b
@ -218,8 +218,8 @@ public void onBlockPlace(BlockPlaceEvent event) {
|
||||
Events.fireToCancel(event, new BreakBlockEvent(event, create(event.getPlayer()), previousState.getLocation(), previousState.getType()));
|
||||
}
|
||||
|
||||
if (!event.isCancelled()) {
|
||||
ItemStack itemStack = new ItemStack(event.getBlockPlaced().getType(), 1);
|
||||
ItemStack itemStack = event.getItemInHand();
|
||||
if (!event.isCancelled() && !itemStack.isEmpty()) {
|
||||
Events.fireToCancel(event, new UseItemEvent(event, create(event.getPlayer()), event.getPlayer().getWorld(), itemStack));
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user