fixes for 22w11a

This commit is contained in:
gnembon committed 2022-03-17 20:21:55 +01:00
1 parent 3e419d1557
commit 302a7b4817
39 files changed
+410 -305

No files matched your search

@@ -14,58 +14,19 @@ import org.spongepowered.asm.mixin.injection.Redirect;
@Mixin(value = ServerPlayerGameMode.class, priority = 69420) // not that important for carpet
public class ServerPlayerGameMode_antiCheatMixin
{
// this is how it should be done
/*
@ModifyConstant(method = "processBlockBreakingAction", require = 0,
constant = @Constant(doubleValue = 36D))
private double addDistance(double original) {
if (CarpetSettings.antiCheatDisabled)
return 1024D; // blocks 32 distance
return original;
}
*/
// that shoudn't've been a constant at the first place
// resolves problems with mobs using reach entity attributes.
@Redirect(method = "handleBlockBreakAction", at = @At(
value = "INVOKE",
target = "Lnet/minecraft/server/level/ServerPlayer;getX()D"
))
private double getXX(ServerPlayer player,
BlockPos pos, ServerboundPlayerActionPacket.Action action, Direction direction, int worldHeight)
{
if (CarpetSettings.antiCheatDisabled &&
player.position().add(0, 1.5, 0).distanceToSqr(Vec3.atCenterOf(pos)) < 1024
) return pos.getX()+0.5;
return player.getX();
}
@Redirect(method = "handleBlockBreakAction", at = @At(
value = "INVOKE",
target = "Lnet/minecraft/server/level/ServerPlayer;getY()D"
target = "Lnet/minecraft/server/level/ServerPlayer;getEyePosition()Lnet/minecraft/world/phys/Vec3;"
))
private double getYY(ServerPlayer player,
BlockPos pos, ServerboundPlayerActionPacket.Action action, Direction direction, int worldHeight)
private Vec3 getEyePos(ServerPlayer instance,
final BlockPos pos, final ServerboundPlayerActionPacket.Action action, final Direction direction, final int maxBuildHeight, final int sequence)
{
if (CarpetSettings.antiCheatDisabled &&
player.position().add(0, 1.5, 0).distanceToSqr(Vec3.atCenterOf(pos)) < 1024
) return pos.getY()-1.0;
return player.getY();
instance.getEyePosition().distanceToSqr(Vec3.atCenterOf(pos)) < 1024
) return Vec3.atCenterOf(pos);
return instance.getEyePosition();
}
@Redirect(method = "handleBlockBreakAction", at = @At(
value = "INVOKE",
target = "Lnet/minecraft/server/level/ServerPlayer;getZ()D"
))
private double getZZ(ServerPlayer player,
BlockPos pos, ServerboundPlayerActionPacket.Action action, Direction direction, int worldHeight)
{
if (CarpetSettings.antiCheatDisabled &&
player.position().add(0, 1.5, 0).distanceToSqr(Vec3.atCenterOf(pos)) < 1024
) return pos.getZ()+0.5;
return player.getZ();
}
}