Skip to content

Commit

Permalink
Implemented some more Elytra changes in 1.15 -> 1.14.4
Browse files Browse the repository at this point in the history
Slightly fixed last commit
  • Loading branch information
FlorianMichael committed Nov 11, 2023
1 parent 4f5ce22 commit 1544364
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,12 @@
*/
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.entity;

import com.llamalad7.mixinextras.injector.WrapWithCondition;
import com.mojang.authlib.GameProfile;
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.raphimc.vialoader.util.VersionEnum;
import de.florianmichael.viafabricplus.settings.impl.DebugSettings;
Expand All @@ -36,10 +40,7 @@
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique;
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.Slice;
import org.spongepowered.asm.mixin.injection.*;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@SuppressWarnings("ConstantValue")
Expand Down Expand Up @@ -167,14 +168,6 @@ public void removeSprintingPacket(ClientPlayerEntity instance) {
}
}

@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"))
public float useFastInverse(float x) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_19_3)) {
Expand All @@ -194,10 +187,45 @@ public boolean removeVehicleRequirement(ClientPlayerEntity instance) {
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
public boolean isCreative() {
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 super.isCreative();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ private void allowGappedLadderClimb(CallbackInfoReturnable<Boolean> cir) {
@Inject(method = "getRidingOffset", at = @At("HEAD"), cancellable = true)
public void replaceRidingOffset(Entity vehicle, CallbackInfoReturnable<Float> cir) {
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));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class MixinItem {

@Redirect(method = { "getMaxDamage", "isDamageable", "getItemBarStep", "getItemBarColor" }, at = @At(value = "FIELD", target = "Lnet/minecraft/item/Item;maxDamage:I"))
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;
}

Expand Down

0 comments on commit 1544364

Please sign in to comment.