antiCheat allows Elytra to deploy when lagging

This commit is contained in:
gnembon committed 2019-07-30 23:02:13 -03:00
1 parent cb8bacc6ce
commit 993c083198
1 file changed
+29
@@ -1,8 +1,11 @@
package carpet.mixins;
import carpet.settings.CarpetSettings;
import net.minecraft.network.ClientConnection;
import net.minecraft.server.network.ServerPlayNetworkHandler;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.util.math.Vec3d;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
@@ -19,6 +22,10 @@ public abstract class ServerPlayNetworkHandler_antiCheatDisabledMixin
@Shadow protected abstract boolean isServerOwner();
@Shadow @Final public ClientConnection client;
@Shadow public ServerPlayerEntity player;
@Inject(method = "tick", at = @At("HEAD"))
private void restrictFloatingBits(CallbackInfo ci)
{
@@ -47,6 +54,28 @@ public abstract class ServerPlayNetworkHandler_antiCheatDisabledMixin
return CarpetSettings.antiCheatDisabled || serverPlayerEntity.isInTeleportationState();
}
@Redirect(method = "onClientCommand", at = @At(
value = "INVOKE",
target = "Lnet/minecraft/server/network/ServerPlayerEntity;getVelocity()Lnet/minecraft/util/math/Vec3d;"
))
private Vec3d getFallingVelocity(ServerPlayerEntity serverPlayerEntity)
{
if (CarpetSettings.antiCheatDisabled)
return new Vec3d(0,-1,0);
return serverPlayerEntity.getVelocity();
}
@Redirect(method = "onClientCommand", at = @At(
value = "FIELD",
target = "Lnet/minecraft/server/network/ServerPlayerEntity;onGround:Z"
))
private boolean getNotOnGround(ServerPlayerEntity serverPlayerEntity)
{
if (CarpetSettings.antiCheatDisabled)
return false;
return serverPlayerEntity.onGround;
}
}