🎨 Improve fly drifting injection.

This commit is contained in:
LambdAurora
2020-01-12 21:45:12 +01:00
parent 32e4ad1b7c
commit 502e9ff15e

View File

@@ -19,7 +19,8 @@ import net.minecraft.util.math.Vec3d;
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.injection.At; import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect; import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
/** /**
* Injects the anti fly drifting feature. * Injects the anti fly drifting feature.
@@ -38,12 +39,12 @@ public abstract class ClientPlayerEntityMixin extends AbstractClientPlayerEntity
super(world, profile); super(world, profile);
} }
@Redirect(method = "move(Lnet/minecraft/entity/MovementType;Lnet/minecraft/util/math/Vec3d;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/AbstractClientPlayerEntity;move(Lnet/minecraft/entity/MovementType;Lnet/minecraft/util/math/Vec3d;)V")) @Inject(method = "move(Lnet/minecraft/entity/MovementType;Lnet/minecraft/util/math/Vec3d;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/AbstractClientPlayerEntity;move(Lnet/minecraft/entity/MovementType;Lnet/minecraft/util/math/Vec3d;)V"))
public void lambdacontrols_move(AbstractClientPlayerEntity player, MovementType type, Vec3d movement) public void lambdacontrols_move(MovementType type, Vec3d movement, CallbackInfo ci)
{ {
LambdaControlsClient mod = LambdaControlsClient.get(); LambdaControlsClient mod = LambdaControlsClient.get();
if (type == MovementType.SELF) { if (type == MovementType.SELF) {
if (player.abilities.flying && !mod.config.has_fly_drifting()) { if (this.abilities.flying && !mod.config.has_fly_drifting()) {
if (!this.method_22120()) { if (!this.method_22120()) {
if (!this.lambdacontrols_drifting_prevented) { if (!this.lambdacontrols_drifting_prevented) {
this.setVelocity(this.getVelocity().multiply(0, 1.0, 0)); this.setVelocity(this.getVelocity().multiply(0, 1.0, 0));
@@ -53,6 +54,5 @@ public abstract class ClientPlayerEntityMixin extends AbstractClientPlayerEntity
this.lambdacontrols_drifting_prevented = false; this.lambdacontrols_drifting_prevented = false;
} }
} }
super.move(type, movement);
} }
} }