From ae5b490d6b944b2604dbd0c71e6d8946122b0ff0 Mon Sep 17 00:00:00 2001 From: FlorianMichael Date: Thu, 4 Jul 2024 16:27:00 +0200 Subject: [PATCH] Handle axe item change as well, update TODO --- .../viafabricplus/ViaFabricPlus.java | 26 ++++++++----------- .../fixes/minecraft/item/MixinAxeItem.java | 16 ++++++++++++ 2 files changed, 27 insertions(+), 15 deletions(-) diff --git a/src/main/java/de/florianmichael/viafabricplus/ViaFabricPlus.java b/src/main/java/de/florianmichael/viafabricplus/ViaFabricPlus.java index ecad45ed..d0876eda 100644 --- a/src/main/java/de/florianmichael/viafabricplus/ViaFabricPlus.java +++ b/src/main/java/de/florianmichael/viafabricplus/ViaFabricPlus.java @@ -42,23 +42,18 @@ import java.util.concurrent.CompletableFuture; * * TODO | Port 1.21 * - ClientPlayerEntity#tickMovement nether portal logic has new screen conditions and changed - * - horses getInvColumns behaviour - * - Wolf hasArmor -> interactions - * - HangingEntity, ItemFrame, Painting, PrimedTnt - * - Villager offers are server only now - * - Player#attack - * - Boat floating and interaction - * - Entity collide functions and interaction - * - LivingEntity#getBlockSpeedFactor, decreaseAirSupply, knockback, travel, getPreciseBodyRotation, - * - Mob interact - * - AxeItem playerHasShieldUseIntent new - * - BucketItem, ChorusFruit, FoodOnAStickItem, KnowledgeBookItem, TridentItem, - * - Jukebox overrides new interaction function - * - SignBlock creative check - * - SolidBucketItem useOn + * - Entity#interact now handles leashables interface which was previously handled in MobEntity + * - shouldCancelInteraction condition in ChestBoatEntity#interact is new + * - HangingEntity/ItemFrame/Painting bounding box calculation changed + * - PlayerEntity#attack got refactored (?) + * - LivingEntity#takeKnockback with 1.0E-5F for loop is new + * - KnowledgeBookItem#use decrementUnlessCreative is new + * - JukeboxBlock#onUse override is new (added state.get(HAS_RECORD) condition) * - HangingEntity bounding box calculation changes * - BoatEntity#updateVelocity isSpaceEmpty condition new - * - LivingEntity#remove -> activeEffects.clear + * - LivingEntity#remove -> added activeEffects.clear call + * - PlayerEntity#tickMovement getSaturationLevel/setSaturationLevel handling is new + * - Check WorldBorder bounds check * * TODO | General * - Make recipe fixes dynamic instead of a data dump in java classes @@ -66,6 +61,7 @@ import java.util.concurrent.CompletableFuture; * - Most CTS protocol features aren't supported (see https://github.com/ViaVersion/ViaFabricPlus/issues/181) * - Most CPE features aren't implemented correctly (see https://github.com/ViaVersion/ViaFabricPlus/issues/152) * - Via: 1.13 -> 1.12.2 block entities recode + * - OXYGEN_BONUS 1.21 -> 1.20.5 handling is missing (only visual) * * TODO | Movement * - Collision hit boxes has been changed (https://github.com/ViaVersion/ViaFabricPlus/issues/195) diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinAxeItem.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinAxeItem.java index d67478a1..23f71b1f 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinAxeItem.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinAxeItem.java @@ -25,13 +25,29 @@ import net.minecraft.item.AxeItem; import net.minecraft.item.ItemUsageContext; import net.minecraft.util.ActionResult; import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.Redirect; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @Mixin(AxeItem.class) public abstract class MixinAxeItem { + @Shadow + private static boolean shouldCancelStripAttempt(ItemUsageContext context) { + return false; + } + + @Redirect(method = "useOnBlock", at = @At(value = "INVOKE", target = "Lnet/minecraft/item/AxeItem;shouldCancelStripAttempt(Lnet/minecraft/item/ItemUsageContext;)Z")) + private boolean neverCancelStripAttempt(ItemUsageContext context) { + if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_20_5)) { + return false; + } else { + return shouldCancelStripAttempt(context); + } + } + @Inject(method = "useOnBlock", at = @At("HEAD"), cancellable = true) private void disableUse(ItemUsageContext context, CallbackInfoReturnable cir) { if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_12_2)) {