diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/network/MixinClientPlayerInteractionManager.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/network/MixinClientPlayerInteractionManager.java index 06b32949..dde83dae 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/network/MixinClientPlayerInteractionManager.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/network/MixinClientPlayerInteractionManager.java @@ -57,6 +57,7 @@ import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket; import net.minecraft.screen.slot.SlotActionType; import net.minecraft.util.ActionResult; import net.minecraft.util.Hand; +import net.minecraft.util.TypedActionResult; import net.minecraft.util.hit.BlockHitResult; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Direction; @@ -228,6 +229,23 @@ public abstract class MixinClientPlayerInteractionManager implements IClientPlay } } + @Redirect(method = "method_41929", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/TypedActionResult;getResult()Lnet/minecraft/util/ActionResult;")) + private ActionResult eitherSuccessOrPass(TypedActionResult instance, @Local(ordinal = 0) ItemStack itemStack) { + if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_8)) { + // In <= 1.8, ActionResult weren't a thing and interactItem simply returned either true or false + // depending on if the input and output item are equal or not + final boolean accepted = instance.getValue() != itemStack; + + if (instance.getResult().isAccepted() == accepted) { + return instance.getResult(); + } else { + return accepted ? ActionResult.SUCCESS : ActionResult.PASS; + } + } else { + return instance.getResult(); + } + } + @Inject(method = "method_41929", at = @At("HEAD")) private void trackLastUsedItem(Hand hand, PlayerEntity playerEntity, MutableObject mutableObject, int sequence, CallbackInfoReturnable> cir) { if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_8)) {