File tree Expand file tree Collapse file tree
src/main/java/dev/plex/listener Expand file tree Collapse file tree Original file line number Diff line number Diff 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 ()))
You can’t perform that action at this time.
0 commit comments