Implemented some more Elytra changes in 1.15 -> 1.14.4

Slightly fixed last commit
This commit is contained in:
FlorianMichael 2023-11-11 18:50:51 +01:00
parent 4f5ce22d0c
commit 1544364f21
No known key found for this signature in database
GPG Key ID: C2FB87E71C425126
3 changed files with 43 additions and 15 deletions

View File

@ -17,8 +17,12 @@
*/ */
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.entity; package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.entity;
import com.llamalad7.mixinextras.injector.WrapWithCondition;
import com.mojang.authlib.GameProfile; import com.mojang.authlib.GameProfile;
import de.florianmichael.viafabricplus.definition.ClientsideFixes; import de.florianmichael.viafabricplus.definition.ClientsideFixes;
import net.minecraft.client.network.ClientPlayNetworkHandler;
import net.minecraft.network.packet.Packet;
import net.minecraft.network.packet.c2s.play.ClientCommandC2SPacket;
import net.minecraft.world.GameMode; import net.minecraft.world.GameMode;
import net.raphimc.vialoader.util.VersionEnum; import net.raphimc.vialoader.util.VersionEnum;
import de.florianmichael.viafabricplus.settings.impl.DebugSettings; import de.florianmichael.viafabricplus.settings.impl.DebugSettings;
@ -36,10 +40,7 @@ import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.*;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.Slice;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@SuppressWarnings("ConstantValue") @SuppressWarnings("ConstantValue")
@ -167,14 +168,6 @@ public abstract class MixinClientPlayerEntity extends AbstractClientPlayerEntity
} }
} }
@Redirect(method = "tickMovement", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;isClimbing()Z"))
public boolean alwaysSendPacket(ClientPlayerEntity instance) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_15_1)) {
return false;
}
return isClimbing();
}
@Redirect(method = "autoJump", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/math/MathHelper;inverseSqrt(F)F")) @Redirect(method = "autoJump", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/math/MathHelper;inverseSqrt(F)F"))
public float useFastInverse(float x) { public float useFastInverse(float x) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_19_3)) { if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_19_3)) {
@ -194,10 +187,45 @@ public abstract class MixinClientPlayerEntity extends AbstractClientPlayerEntity
return instance.hasVehicle(); return instance.hasVehicle();
} }
@Redirect(method = "tickMovement", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;checkFallFlying()Z"))
public boolean removeFallFlyingCheck(ClientPlayerEntity instance) {
// Elytra movement was serverside in <= 1.14.4 and got moved to the client in 1.15
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_14_4)) {
return !this.isOnGround() && this.getVelocity().y < 0.0 && !isFallFlying();
}
return instance.checkFallFlying();
}
@Redirect(method = "tickMovement", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;isClimbing()Z"))
public boolean removeLadderCheck(ClientPlayerEntity instance) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_15_1)) {
return false;
}
return instance.isClimbing();
}
@Redirect(method = "tickMovement", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;hasVehicle()Z", ordinal = 3))
public boolean removeVehicleCheck(ClientPlayerEntity instance) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_14_4)) {
return false;
}
return instance.hasVehicle();
}
@ModifyVariable(method = "tickMovement", at = @At(value = "LOAD", ordinal = 4), ordinal = 4)
public boolean removeBl8Boolean(boolean value) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_14_4)) {
return false;
}
return value;
}
@Override @Override
public boolean isCreative() { public boolean isCreative() {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_7_6tor1_7_10)) { if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_7_6tor1_7_10)) {
if (client.interactionManager == null) return super.isCreative(); // Fixes https://github.com/ViaVersion/ViaFabricPlus/issues/216 if (client.interactionManager == null) {
return super.isCreative(); // Fixes https://github.com/ViaVersion/ViaFabricPlus/issues/216
}
return client.interactionManager.getCurrentGameMode() == GameMode.CREATIVE; return client.interactionManager.getCurrentGameMode() == GameMode.CREATIVE;
} }
return super.isCreative(); return super.isCreative();

View File

@ -211,7 +211,7 @@ public abstract class MixinLivingEntity extends Entity {
@Inject(method = "getRidingOffset", at = @At("HEAD"), cancellable = true) @Inject(method = "getRidingOffset", at = @At("HEAD"), cancellable = true)
public void replaceRidingOffset(Entity vehicle, CallbackInfoReturnable<Float> cir) { public void replaceRidingOffset(Entity vehicle, CallbackInfoReturnable<Float> cir) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_20tor1_20_1)) { if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_20tor1_20_1)) {
cir.setReturnValue((float) EntityHeightOffsetsPre1_20_2.getHeightOffset((Entity) (Object) this)); cir.setReturnValue((float) EntityHeightOffsetsPre1_20_2.getHeightOffset(this));
} }
} }

View File

@ -34,7 +34,7 @@ public class MixinItem {
@Redirect(method = { "getMaxDamage", "isDamageable", "getItemBarStep", "getItemBarColor" }, at = @At(value = "FIELD", target = "Lnet/minecraft/item/Item;maxDamage:I")) @Redirect(method = { "getMaxDamage", "isDamageable", "getItemBarStep", "getItemBarColor" }, at = @At(value = "FIELD", target = "Lnet/minecraft/item/Item;maxDamage:I"))
public int changeCrossbowDamage(Item instance) { public int changeCrossbowDamage(Item instance) {
if (instance instanceof CrossbowItem && ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_18tor1_18_1)) { if (instance instanceof CrossbowItem && ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_17_1)) {
return 326; return 326;
} }