File tree Expand file tree Collapse file tree 1 file changed +20
-14
lines changed
src/main/java/dev/plex/listener Expand file tree Collapse file tree 1 file changed +20
-14
lines changed Original file line number Diff line number Diff line change @@ -78,22 +78,28 @@ 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 -> {
82- for (TypedKey <BlockType > key : blockPredicate .blocks ()) {
83- if (key .equals (clicked .getType ().asBlockType ().key ())) {
84- return true ;
81+ if (item .hasData (DataComponentTypes .CAN_PLACE_ON )) {
82+ canPlace = item .getData (DataComponentTypes .CAN_PLACE_ON ).predicates ().stream ().anyMatch (blockPredicate -> {
83+ for (TypedKey <BlockType > key : blockPredicate .blocks ()) {
84+ if (key .key ().equals (clicked .getType ().asBlockType ().key ())) {
85+ return true ;
86+ }
8587 }
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 ;
88+ return false ;
89+ });
90+ }
91+
92+ if (item .hasData (DataComponentTypes .CAN_BREAK )) {
93+ canBreak = item .getData (DataComponentTypes .CAN_BREAK ).predicates ().stream ().anyMatch (blockPredicate -> {
94+ for (TypedKey <BlockType > key : blockPredicate .blocks ()) {
95+ if (key .key ().equals (clicked .getType ().asBlockType ().key ())) {
96+ return true ;
97+ }
9398 }
94- }
95- return false ;
96- }); }
99+ return false ;
100+ });
101+ }
102+ }
97103 }
98104 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 ;
99105 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