Fixed hand swing condition in <= 1.14.4

This commit is contained in:
RaphiMC 2024-04-01 00:14:20 +02:00
parent 4c5d58347b
commit 4f611e93ea
No known key found for this signature in database
GPG Key ID: 0F6BB0657A03AC94
3 changed files with 46 additions and 1 deletions

View File

@ -0,0 +1,44 @@
/*
* This file is part of ViaFabricPlus - https://github.com/FlorianMichael/ViaFabricPlus
* Copyright (C) 2021-2024 FlorianMichael/EnZaXD <florian.michael07@gmail.com> and RK_01/RaphiMC
* Copyright (C) 2023-2024 contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.viafabricplus.protocoltranslator.ProtocolTranslator;
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.callback.CallbackInfoReturnable;
@Mixin(ActionResult.class)
public abstract class MixinActionResult {
@Shadow
public abstract boolean isAccepted();
@Inject(method = "shouldSwingHand", at = @At("HEAD"), cancellable = true)
private void swingWhenConsume(CallbackInfoReturnable<Boolean> cir) {
if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_14_4)) {
cir.setReturnValue(this.isAccepted());
}
}
}

View File

@ -99,7 +99,7 @@ public abstract class MixinMinecraftClient {
@WrapWithCondition(method = "handleInputEvents", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;swingHand(Lnet/minecraft/util/Hand;)V"))
private boolean disableSwing(ClientPlayerEntity instance, Hand hand) {
return ProtocolTranslator.getTargetVersion().newerThan(ProtocolVersion.v1_14_4);
return ProtocolTranslator.getTargetVersion().newerThanOrEqualTo(ProtocolVersion.v1_15);
}
@Inject(method = "tick",

View File

@ -33,6 +33,7 @@
"compat.lithium.MixinEntity",
"fixes.authlib.MixinKeyPairResponse",
"fixes.authlib.MixinYggdrasilUserApiService",
"fixes.minecraft.MixinActionResult",
"fixes.minecraft.MixinAllowedAddressResolver",
"fixes.minecraft.MixinBuiltChunk",
"fixes.minecraft.MixinCamera",