@@ -548,21 +548,26 @@ public static boolean removeBlockRoutine(@Nullable BlockState state, Level world
548548 return successful ;
549549 }
550550
551+ /**
552+ * Calculates the harvestable blocks, used for tool AoE harvesting
553+ *
554+ * @param player the player clicking the item
555+ * @param stack the item that was used
556+ *
557+ * @return listOfBlockPositions or empty list if none
558+ */
551559 public static List <BlockPos > getHarvestableBlocks (ItemStack stack , Player player ) {
552- if (!hasBehaviorsTag (stack )) return List .of ();
560+ final List <BlockPos > NO_BLOCKS = List .of ();
561+
562+ if (!hasBehaviorsTag (stack )) return NO_BLOCKS ;
553563
554564 var aoeDefinition = getAoEDefinition (stack );
555565 if (aoeDefinition .isZero ()) {
556- return List . of () ;
566+ return NO_BLOCKS ;
557567 }
558568
569+ InteractionHand hand = InteractionHand .MAIN_HAND ;
559570 BlockHitResult hitResult = getPlayerDefaultRaytrace (player );
560- var toolType = player .getItemInHand (InteractionHand .MAIN_HAND ).getItem () instanceof GTToolItem toolItem ?
561- toolItem .toolType : null ;
562- if (toolType == null ) return Collections .emptyList ();
563- var hand = is (player .getItemInHand (InteractionHand .MAIN_HAND ), toolType ) ?
564- InteractionHand .MAIN_HAND : null ;
565- if (hand == null ) return Collections .emptyList ();
566571 UseOnContext context = new UseOnContext (player , hand , hitResult );
567572 return getHarvestableBlocks (aoeDefinition , context );
568573 }
0 commit comments