Skip to content

Commit 50f061a

Browse files
committed
Update PlayerListener.java
1 parent e6141ff commit 50f061a

1 file changed

Lines changed: 16 additions & 3 deletions

File tree

src/main/java/dev/plex/listener/PlayerListener.java

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,22 @@ private void onBlock(PlayerInteractEvent event)
7878
ItemStack item = event.getItem();
7979
if (item != null)
8080
{
81-
canPlace = item.getData(DataComponentTypes.CAN_PLACE_ON).predicates().stream().anyMatch(blockPredicate -> blockPredicate.blocks().contains((TypedKey<BlockType>) clicked.getType().asBlockType().getKey().key()));
82-
canBreak = item.getData(DataComponentTypes.CAN_BREAK).predicates().stream().anyMatch(blockPredicate -> blockPredicate.blocks().contains((TypedKey<BlockType>) clicked.getType().asBlockType().getKey().key()));
83-
}
81+
canPlace = item.getData(DataComponentTypes.CAN_PLACE_ON).predicates().stream().anyMatch(blockPredicate -> {
82+
for (TypedKey<BlockType> key : blockPredicate.blocks()) {
83+
if (key.equals(clicked.getType().asBlockType().key())) {
84+
return true;
85+
}
86+
}
87+
return false;
88+
});
89+
canBreak = item.getData(DataComponentTypes.CAN_BREAK).predicates().stream().anyMatch(blockPredicate -> {
90+
for (TypedKey<BlockType> key : blockPredicate.blocks()) {
91+
if (key.equals(clicked.getType().asBlockType().key())) {
92+
return true;
93+
}
94+
}
95+
return false;
96+
}); }
8497
}
8598
boolean clickedTargetBlock = clicked.getType() == Material.COMMAND_BLOCK || clicked.getType() == Material.CHAIN_COMMAND_BLOCK || clicked.getType() == Material.REPEATING_COMMAND_BLOCK || clicked.getType() == Material.STRUCTURE_BLOCK || clicked.getType() == Material.JIGSAW;
8699
if (event.getAction() == Action.RIGHT_CLICK_BLOCK && (type == Material.COMMAND_BLOCK || type == Material.CHAIN_COMMAND_BLOCK || type == Material.REPEATING_COMMAND_BLOCK || type == Material.STRUCTURE_BLOCK || type == Material.JIGSAW) && (!clickedTargetBlock || player.isSneaking()))

0 commit comments

Comments
 (0)