Skip to content

Commit 50ed84e

Browse files
authored
Fix scythe not breaking items in an AOE (#4207)
1 parent 6894266 commit 50ed84e

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

src/main/java/com/gregtechceu/gtceu/api/item/tool/GTToolType.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ public class GTToolType {
113113
.durabilityMultiplier(3.0F)
114114
.behaviors(AOEConfigUIBehavior.INSTANCE, GrassPathBehavior.INSTANCE,
115115
DouseCampfireBehavior.INSTANCE))
116+
.constructor(GTShovelItem::new)
116117
.toolClasses(GTToolType.SHOVEL)
117118
.defaultActions(ToolActions.SHOVEL_DIG)
118119
.materialAmount(3 * GTValues.M)

src/main/java/com/gregtechceu/gtceu/api/item/tool/ToolHelper.java

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)