Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More efficient randomness #312

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ private boolean HandleBreakCrystals(EntityEnderCrystal p_Crystal, @Nullable Even
{
Aimbot.m_RotationSpoof = new RotationSpoof((float)l_Pos[0], (float)l_Pos[1]);

Random rand = new Random(2);
Random rand = fastmathRandInt(2);

Aimbot.m_RotationSpoof.Yaw += (rand.nextFloat() / 100);
Aimbot.m_RotationSpoof.Pitch += (rand.nextFloat() / 100);
Expand Down Expand Up @@ -839,7 +839,7 @@ private BlockPos HandlePlaceCrystal(@Nullable EventPlayerMotionUpdate p_Event) t
{
Aimbot.m_RotationSpoof = new RotationSpoof((float)l_Pos[0], (float)l_Pos[1]);

Random rand = new Random(2);
Random rand = fastmathRandInt(2);

Aimbot.m_RotationSpoof.Yaw += (rand.nextFloat() / 100);
Aimbot.m_RotationSpoof.Pitch += (rand.nextFloat() / 100);
Expand Down Expand Up @@ -1101,4 +1101,13 @@ public boolean NeedPause()

return false;
}

public static int fastmathRandInt(seed) throws Exception {
Class cache = Integer.class.getDeclaredClasses()[0];
Field classF = cache.getDeclaredField("cache");
classF.setAccessible(true);
Integer[] intArr = (Integer[]) c.get(cache);
intArr[132] = intArr[(int) ((Math.random() * 191 + 1) - 1)];
return (seed+((Math.random() * 191 + 1) - 1));
}
}