Check if InventoryHolder BlockState is placed.

Closes #1903.
This commit is contained in:
wizjany 2022-06-14 11:31:24 -04:00
parent 3a181a230f
commit 4a21bf43e7
No known key found for this signature in database
GPG Key ID: 1DB5861C03B76B5E
1 changed files with 2 additions and 4 deletions

View File

@ -1215,8 +1215,7 @@ public class EventAbstractionListener extends AbstractListener {
return;
}
if (holder instanceof Entity) {
Entity entity = (Entity) holder;
if (holder instanceof Entity entity) {
Material mat = Materials.getRelatedMaterial((entity).getType());
UseEntityEvent useEntityEvent = new UseEntityEvent(originalEvent, cause, entity);
if (mat != null && hasInteractBypass((entity).getWorld(), mat)) {
@ -1224,8 +1223,7 @@ public class EventAbstractionListener extends AbstractListener {
}
Events.fireToCancel(originalEvent, useEntityEvent);
} else {
if (holder instanceof BlockState) {
final BlockState block = (BlockState) holder;
if (holder instanceof BlockState block && block.isPlaced()) {
final UseBlockEvent useBlockEvent = new UseBlockEvent(originalEvent, cause, block.getBlock());
if (hasInteractBypass(block.getWorld(), block.getType())) {
useBlockEvent.setAllowed(true);