From 60cec9b000f13e803b3d1e1f8fda86393b0dd75d Mon Sep 17 00:00:00 2001 From: Alexander Date: Sun, 4 Jun 2023 18:01:49 +0300 Subject: [PATCH] Reimplement repetitive 1.14.3 START_DESTROY_BLOCK calls for same block breaking (#121) * Reimplement 1.14.3 second PlayerActionC2SPacket.Action.START_DESTROY_BLOCK calls for same block breaking * Expression simplification --- .../MixinClientPlayerInteractionManager.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/MixinClientPlayerInteractionManager.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/MixinClientPlayerInteractionManager.java index e67adb00..70b401a6 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/MixinClientPlayerInteractionManager.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/MixinClientPlayerInteractionManager.java @@ -44,6 +44,7 @@ import net.minecraft.screen.slot.SlotActionType; import net.minecraft.util.ActionResult; import net.minecraft.util.Hand; import net.minecraft.util.hit.BlockHitResult; +import net.minecraft.util.math.BlockPos; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; @@ -69,12 +70,22 @@ public abstract class MixinClientPlayerInteractionManager { @Final private ClientPlayNetworkHandler networkHandler; + @Shadow + private BlockPos currentBreakingPos; + @Unique private ItemStack viafabricplus_oldCursorStack; @Unique private List viafabricplus_oldItems; + @Inject(method = "breakBlock", at = @At("TAIL")) + public void resetBlockBreaking(BlockPos pos, CallbackInfoReturnable cir) { + if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_14_3)) { + this.currentBreakingPos = new BlockPos(this.currentBreakingPos.getX(), -1, this.currentBreakingPos.getZ()); + } + } + @Inject(method = "attackEntity", at = @At("HEAD")) private void injectAttackEntity(PlayerEntity player, Entity target, CallbackInfo ci) { if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8) && player instanceof IClientPlayerEntity) {