@@ -345,39 +345,29 @@ default int getTotalHarvestLevel(ItemStack stack) {
345345
346346 if (!player .isShiftKeyDown ()) {
347347 ServerPlayer serverPlayer = (ServerPlayer ) player ;
348- int result = -1 ;
349- if (isTool (stack , GTToolType .SHEARS )) {
350- result = shearBlockRoutine (serverPlayer , stack , pos );
351- }
352- if (result != 0 ) {
353- // prevent exploits with instantly breakable blocks
354- BlockState state = player .level ().getBlockState (pos );
355- boolean effective = false ;
356- for (GTToolType type : getToolClasses (stack )) {
357- if (type .harvestTags .stream ().anyMatch (state ::is )) {
358- effective = true ;
359- break ;
360- }
348+ // prevent exploits with instantly breakable blocks
349+ BlockState state = player .level ().getBlockState (pos );
350+ boolean effective = false ;
351+ for (GTToolType type : getToolClasses (stack )) {
352+ if (type .harvestTags .stream ().anyMatch (state ::is )) {
353+ effective = true ;
354+ break ;
361355 }
356+ }
362357
363- effective |= isToolEffective (state , getToolClasses (stack ), getTotalHarvestLevel (stack ));
364-
365- if (effective ) {
366- if (areaOfEffectBlockBreakRoutine (stack , serverPlayer , pos )) {
367- if (playSoundOnBlockDestroy ()) playSound (player );
368- } else {
369- if (result == -1 ) {
370- var tag = getBehaviorsTag (stack );
371- if (tag .getBoolean (TREE_FELLING_KEY ) &&
372- !tag .getBoolean (DISABLE_TREE_FELLING_KEY ) &&
373- state .is (BlockTags .LOGS )) {
374- TreeFellingHelper .fellTree (stack , player .level (), state , pos , player );
375- }
376- if (playSoundOnBlockDestroy ()) playSound (player );
377- } else {
378- return true ;
379- }
358+ effective |= isToolEffective (state , getToolClasses (stack ), getTotalHarvestLevel (stack ));
359+
360+ if (effective ) {
361+ if (areaOfEffectBlockBreakRoutine (stack , serverPlayer , pos )) {
362+ if (playSoundOnBlockDestroy ()) playSound (player );
363+ } else {
364+ var tag = getBehaviorsTag (stack );
365+ if (tag .getBoolean (TREE_FELLING_KEY ) &&
366+ !tag .getBoolean (DISABLE_TREE_FELLING_KEY ) &&
367+ state .is (BlockTags .LOGS )) {
368+ TreeFellingHelper .fellTree (stack , player .level (), state , pos , player );
380369 }
370+ if (playSoundOnBlockDestroy ()) playSound (player );
381371 }
382372 }
383373 }
@@ -390,7 +380,8 @@ default int getTotalHarvestLevel(ItemStack stack) {
390380 getToolStats ().getBehaviors ()
391381 .forEach (behavior -> behavior .onBlockDestroyed (stack , worldIn , state , pos , entityLiving ));
392382
393- if ((double ) state .getDestroySpeed (worldIn , pos ) != 0.0D ) {
383+ if ((double ) state .getDestroySpeed (worldIn , pos ) != 0.0D ||
384+ getToolType ().harvestTags .stream ().anyMatch (state ::is )) {
394385 ToolHelper .damageItem (stack , entityLiving , getToolStats ().getToolDamagePerBlockBreak (stack ));
395386 }
396387 if (entityLiving instanceof Player && playSoundOnBlockDestroy ()) {
@@ -646,6 +637,18 @@ default Map<Enchantment, Integer> getDefaultEnchantments(ItemStack stack) {
646637 return InteractionResultHolder .pass (heldItem );
647638 }
648639
640+ default InteractionResult definition$interactLivingEntity (ItemStack stack , Player player ,
641+ LivingEntity interactionTarget ,
642+ InteractionHand usedHand ) {
643+ for (IToolBehavior behavior : getToolStats ().getBehaviors ()) {
644+ if (behavior .onInteractLivingEntity (stack , player , interactionTarget , usedHand ) ==
645+ InteractionResult .SUCCESS ) {
646+ return InteractionResult .SUCCESS ;
647+ }
648+ }
649+ return InteractionResult .PASS ;
650+ }
651+
649652 default boolean definition$shouldOpenUIAfterUse (UseOnContext context ) {
650653 for (IToolBehavior behavior : getToolStats ().getBehaviors ()) {
651654 if (!behavior .shouldOpenUIAfterUse (context )) {
0 commit comments