Upload files to "src/openonyx/events"
This commit is contained in:
1 parent
7286c890fe
commit
1337b576d4
5 files changed
+677
No files matched your search
@@ -0,0 +1,205 @@
|
||||
package openonyx.events;
|
||||
|
||||
import java.util.Random;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.Vec3;
|
||||
import openonyx.core.MinecraftAccess;
|
||||
import openonyx.history.internal.NumberSetting;
|
||||
|
||||
public class AimController implements MinecraftAccess {
|
||||
private int k;
|
||||
private Rotation rotation;
|
||||
private float M;
|
||||
private final RotationSettings rotationSettings;
|
||||
private static final float j = 0.1F;
|
||||
private Rotation rotation2;
|
||||
private double h;
|
||||
private double l;
|
||||
private float I;
|
||||
private int d;
|
||||
private float i;
|
||||
private final Random random = new Random();
|
||||
private double H;
|
||||
private float e;
|
||||
|
||||
public boolean L(Entity entity, Rotation rotation, double d) {
|
||||
if (rotationx != null && mc.thePlayer != null) {
|
||||
Vec3 vec3 = GeometryUtils.L();
|
||||
Vec3 vec31 = GeometryUtils.L(rotationx.yaw(), rotationx.pitch());
|
||||
Vec3 vec32 = vec3.addVector(vec31.xCoord * dx, vec31.yCoord * dx, vec31.zCoord * dx);
|
||||
float f = entity.getCollisionBorderSize();
|
||||
AxisAlignedBB axisAlignedBB;
|
||||
AxisAlignedBB axisAlignedBB1 = (axisAlignedBB = entity.getEntityBoundingBox().expand(f, f, f))
|
||||
.offset(entity.prevPosX - entity.posX, entity.prevPosY - entity.posY, entity.prevPosZ - entity.posZ);
|
||||
return this.L(axisAlignedBB, vec3, vec32) || this.L(axisAlignedBB1, vec3, vec32);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public AimController(RotationSettings rotationSettings) {
|
||||
this.k = -1;
|
||||
this.d = 0;
|
||||
this.rotation2 = null;
|
||||
this.rotation = null;
|
||||
this.rotationSettings = rotationSettingsx;
|
||||
this.D();
|
||||
this.d();
|
||||
}
|
||||
|
||||
private void D() {
|
||||
this.h = this.random.nextDouble();
|
||||
this.H = this.random.nextDouble();
|
||||
this.l = this.random.nextDouble();
|
||||
}
|
||||
|
||||
public Rotation getRotation() {
|
||||
return this.rotation;
|
||||
}
|
||||
|
||||
private boolean L(AxisAlignedBB axisAlignedBB, Vec3 vec3, Vec3 vec31) {
|
||||
return axisAlignedBB.isVecInside(vec3) || axisAlignedBB.calculateIntercept(vec3, vec31) != null;
|
||||
}
|
||||
|
||||
private void d() {
|
||||
this.i = this.L(this.rotationSettings.yawSpeed, this.rotationSettings.yawSpeedMax);
|
||||
this.M = this.L(this.rotationSettings.pitchSpeed, this.rotationSettings.pitchSpeedMax);
|
||||
}
|
||||
|
||||
private float d(float f) {
|
||||
return f * (this.random.nextFloat() - this.random.nextFloat());
|
||||
}
|
||||
|
||||
public void L(Entity entity, double d) {
|
||||
AimController aimController1 = this;
|
||||
if (mc.thePlayer == null) {
|
||||
aimController1.reset();
|
||||
} else {
|
||||
boolean bl = RotationManager.D();
|
||||
boolean bl1 = entity.getEntityId() != aimController1.k;
|
||||
boolean bl2;
|
||||
if (bl1) {
|
||||
aimController1.k = entity.getEntityId();
|
||||
bl2 = bl;
|
||||
aimController1.d = 0;
|
||||
aimController1.D();
|
||||
} else {
|
||||
if (aimController1.rotationSettings.aimReRoll.getInt() > 0 && ++aimController1.d >= aimController1.rotationSettings.aimReRoll.getInt()) {
|
||||
aimController1.d = 0;
|
||||
aimController1.D();
|
||||
}
|
||||
|
||||
bl2 = bl;
|
||||
}
|
||||
|
||||
if (!bl2) {
|
||||
aimController1.I = 0.0F;
|
||||
aimController1.e = 0.0F;
|
||||
}
|
||||
|
||||
if (!bl || bl1) {
|
||||
aimController1.d();
|
||||
}
|
||||
|
||||
Rotation rotationx = RotationManager.L();
|
||||
Vec3 vec31 = GeometryUtils.L();
|
||||
Vec3 vec3 = GeometryUtils.L(entity, aimController1.h, aimController1.H, aimController1.l, aimController1.rotationSettings.aimSpread.getValue() / 100.0);
|
||||
if (vec31.squareDistanceTo(vec3) > dx * dx) {
|
||||
vec3 = GeometryUtils.L(entity);
|
||||
}
|
||||
|
||||
aimController1.rotation2 = RotationMath.L(vec3, rotationx);
|
||||
float ix = MathHelper.wrapAngleTo180_float(aimController1.rotation2.yaw() - rotationx.yaw());
|
||||
float f = aimController1.rotation2.pitch() - rotationx.pitch();
|
||||
float jx = rotationx.yaw() + aimController1.L(ix, aimController1.L(aimController1.i), true);
|
||||
float g = rotationx.pitch() + aimController1.L(f, aimController1.L(aimController1.M), false);
|
||||
if (aimController1.rotationSettings.yawJitter.getValue() > 0.0) {
|
||||
jx += aimController1.d(aimController1.rotationSettings.yawJitter.getFloat());
|
||||
}
|
||||
|
||||
if (aimController1.rotationSettings.pitchJitter.getValue() > 0.0) {
|
||||
g += aimController1.d(aimController1.rotationSettings.pitchJitter.getFloat());
|
||||
}
|
||||
|
||||
float hx = MathHelper.clamp_float(g, -90.0F, 90.0F);
|
||||
if (aimController1.rotationSettings.sensitivityFix.isEnabled()) {
|
||||
float kx = RotationMath.L();
|
||||
jx = RotationMath.d(rotationx.yaw(), jx, kx);
|
||||
hx = RotationMath.L(rotationx.pitch(), hx, kx, -90.0F, 90.0F);
|
||||
}
|
||||
|
||||
aimController1.rotation = new Rotation(jx, hx);
|
||||
RotationManager.setRotation(aimController1.rotation, aimController1.rotationSettings.moveFix.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
private float L(float f, float g, boolean bl) {
|
||||
switch ((RotationMode)this.rotationSettings.rotation.getValue()) {
|
||||
case INSTANT:
|
||||
while (false) {
|
||||
}
|
||||
|
||||
return f;
|
||||
case LINEAR:
|
||||
return MathHelper.clamp_float(f, -g, g);
|
||||
case SMOOTH:
|
||||
float kx = 1.0F - this.rotationSettings.smoothing.getFloat() / 100.0F;
|
||||
float lx = MathHelper.clamp_float(f * kx, -g, g);
|
||||
float m = this.rotationSettings.sensitivityFix.isEnabled() ? RotationMath.L() : 0.01F;
|
||||
return Math.copySign(Math.min(Math.abs(f), Math.max(Math.abs(lx), m)), f);
|
||||
default:
|
||||
float hx = bl ? this.I : this.e;
|
||||
float ix = this.rotationSettings.acceleration.getFloat();
|
||||
float jx = g * this.rotationSettings.startSpeed.getFloat() / 100.0F;
|
||||
hx = MathHelper.clamp_float(hx + ix, jx, g);
|
||||
g = (float)Math.sqrt(2.0 * ix * Math.abs(f));
|
||||
g = Math.min(Math.min(hx, g), Math.abs(f));
|
||||
float n;
|
||||
if (bl) {
|
||||
this.I = g;
|
||||
n = g;
|
||||
} else {
|
||||
this.e = g;
|
||||
n = g;
|
||||
}
|
||||
|
||||
return Math.copySign(n, f);
|
||||
}
|
||||
}
|
||||
|
||||
public void reset() {
|
||||
this.k = -1;
|
||||
this.d = 0;
|
||||
this.I = 0.0F;
|
||||
this.e = 0.0F;
|
||||
this.rotation2 = null;
|
||||
this.rotation = null;
|
||||
RotationManager.d();
|
||||
}
|
||||
|
||||
private float L(NumberSetting numberSetting, NumberSetting numberSetting1) {
|
||||
if (!this.rotationSettings.speedVariance.isEnabled()) {
|
||||
return numberSetting.getFloat();
|
||||
}
|
||||
|
||||
float f;
|
||||
float g = Math.max(f = numberSetting.getFloat(), numberSetting1.getFloat());
|
||||
return f + this.random.nextFloat() * (g - f);
|
||||
}
|
||||
|
||||
public float L(Rotation rotation) {
|
||||
return rotationx != null && this.rotation2 != null
|
||||
? Math.max(Math.abs(MathHelper.wrapAngleTo180_float(this.rotation2.yaw() - rotationx.yaw())), Math.abs(this.rotation2.pitch() - rotationx.pitch()))
|
||||
: 180.0F;
|
||||
}
|
||||
|
||||
private float L(float f) {
|
||||
return !this.rotationSettings.speedVariance.isEnabled() ? f : f * (1.0F + this.d(0.1F));
|
||||
}
|
||||
|
||||
public Rotation getRotation2() {
|
||||
return this.rotation2;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,421 @@
|
||||
package openonyx.events;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.OpenOption;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiMainMenu;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ScreenShotHelper;
|
||||
import openonyx.core.OnyxClient;
|
||||
import openonyx.features.Module;
|
||||
|
||||
public final class BenchmarkHarness {
|
||||
private static boolean A;
|
||||
private static final List<BenchmarkScenario> BENCHMARK_SCENARIOS = new ArrayList<>();
|
||||
private static float B;
|
||||
private static final String C = System.getProperty("onyx.bench");
|
||||
private static final boolean J = System.getProperty("onyx.bench.walk") != null;
|
||||
private static double D;
|
||||
private static final double c = 4.0;
|
||||
private static final boolean a = C != null && !C.isEmpty();
|
||||
private static final long k = Long.getLong("onyx.bench.warmup", 12000L) * 1000000L;
|
||||
private static boolean g = true;
|
||||
private static BenchmarkPhase benchmarkPhase = BenchmarkPhase.MENU;
|
||||
private static final long L = 700000000L;
|
||||
private static long j;
|
||||
private static final double m = 0.18;
|
||||
private static final long h = Long.getLong("onyx.bench.measure", 4000L) * 1000000L;
|
||||
private static final List<Long> LONGS = new ArrayList<>();
|
||||
private static long I;
|
||||
private static int d;
|
||||
private static double i;
|
||||
private static final List<BenchmarkSample> BENCHMARK_SAMPLES = new ArrayList<>();
|
||||
private static double H;
|
||||
private static float e;
|
||||
|
||||
private BenchmarkHarness() {
|
||||
}
|
||||
|
||||
private static void i(Minecraft minecraft) {
|
||||
Minecraft minecraft1 = minecraft;
|
||||
if (A && minecraft1.thePlayer != null) {
|
||||
BenchmarkScenario benchmarkScenario = d < BENCHMARK_SCENARIOS.size() ? BENCHMARK_SCENARIOS.get(d) : null;
|
||||
float f = benchmarkScenario != null && benchmarkScenario.yaw() != null ? benchmarkScenario.yaw() : e;
|
||||
float gx = benchmarkScenario != null && benchmarkScenario.pitch() != null ? benchmarkScenario.pitch() : B;
|
||||
L(minecraft1);
|
||||
if (J) {
|
||||
minecraft1.gameSettings.thirdPersonView = 1;
|
||||
minecraft1.thePlayer.rotationYaw = f;
|
||||
minecraft1.thePlayer.rotationPitch = gx;
|
||||
double dx = minecraft1.thePlayer.posX - i;
|
||||
double ex = minecraft1.thePlayer.posZ - H;
|
||||
double hx;
|
||||
if ((hx = Math.sqrt(dx * dx + ex * ex)) > 4.0) {
|
||||
minecraft1.thePlayer.motionX = -dx / hx * 0.18;
|
||||
minecraft1.thePlayer.motionZ = -ex / hx * 0.18;
|
||||
} else {
|
||||
dx = System.nanoTime() % 4000000000L / 4.0E9 * 2.0 * Math.PI;
|
||||
minecraft1.thePlayer.motionX = Math.cos(dx) * 0.18;
|
||||
minecraft1.thePlayer.motionZ = Math.sin(dx) * 0.18;
|
||||
}
|
||||
} else {
|
||||
minecraft1.thePlayer.setPositionAndRotation(i, D, H, f, gx);
|
||||
minecraft1.thePlayer.motionX = 0.0;
|
||||
minecraft1.thePlayer.motionY = 0.0;
|
||||
minecraft1.thePlayer.motionZ = 0.0;
|
||||
minecraft1.thePlayer.onGround = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void D(Minecraft minecraft) {
|
||||
Iterator iterator = BENCHMARK_SCENARIOS.get(d).off().iterator();
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
Module module;
|
||||
if ((module = L((String)iterator.next())) != null) {
|
||||
module.setEnabled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void D() {
|
||||
StringBuilder stringBuilder;
|
||||
StringBuilder stringBuilder1 = stringBuilder = new StringBuilder();
|
||||
Locale locale = Locale.ROOT;
|
||||
OpenOption[] openOptions = new Object[5];
|
||||
boolean bl1 = true;
|
||||
openOptions[0] = "phase";
|
||||
openOptions[1] = "fps";
|
||||
openOptions[2] = "median ms";
|
||||
openOptions[3] = "p95 ms";
|
||||
openOptions[4] = "vs base";
|
||||
stringBuilder1.append(String.format(locale, "%-28s %8s %10s %10s %10s%n", openOptions));
|
||||
double dx = BENCHMARK_SAMPLES.isEmpty() ? 0.0 : BENCHMARK_SAMPLES.get(0).avgFps();
|
||||
|
||||
Iterator iterator;
|
||||
for (Iterator iterator1 = iterator = BENCHMARK_SAMPLES.iterator(); iterator1.hasNext(); iterator1 = iterator) {
|
||||
BenchmarkSample benchmarkSample = (BenchmarkSample)iterator.next();
|
||||
locale = Locale.ROOT;
|
||||
openOptions = new Object[5];
|
||||
bl1 = true;
|
||||
openOptions[0] = benchmarkSample.label();
|
||||
openOptions[1] = benchmarkSample.avgFps();
|
||||
openOptions[2] = benchmarkSample.medianMs();
|
||||
openOptions[3] = benchmarkSample.p95Ms();
|
||||
openOptions[4] = benchmarkSample.avgFps() - dx;
|
||||
stringBuilder.append(String.format(locale, "%-28s %8.1f %10.2f %10.2f %+10.1f%n", openOptions));
|
||||
}
|
||||
|
||||
System.out.println(new StringBuilder().insert(0, "[onyx-bench] results\n").append(stringBuilder).toString());
|
||||
String string;
|
||||
if (!(string = System.getProperty("onyx.bench.out", "")).isEmpty()) {
|
||||
try {
|
||||
String[] strings = new String[0];
|
||||
boolean bl = true;
|
||||
Path path = Path.of(string, strings);
|
||||
String string1 = stringBuilder.toString();
|
||||
Charset charset = StandardCharsets.UTF_8;
|
||||
openOptions = new OpenOption[0];
|
||||
bl1 = true;
|
||||
Files.writeString(path, string1, charset, openOptions);
|
||||
} catch (IOException iOException) {
|
||||
d(new StringBuilder().insert(0, "could not write report: ").append(iOException).toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void d() {
|
||||
if (a && benchmarkPhase != BenchmarkPhase.DONE) {
|
||||
Minecraft minecraft = Minecraft.getMinecraft();
|
||||
long l = System.nanoTime();
|
||||
switch (benchmarkPhase) {
|
||||
case MEASURE:
|
||||
while (false) {
|
||||
}
|
||||
|
||||
if (minecraft.currentScreen instanceof GuiMainMenu) {
|
||||
g = minecraft.gameSettings.pauseOnLostFocus;
|
||||
minecraft.gameSettings.pauseOnLostFocus = false;
|
||||
d(new StringBuilder().insert(0, "joining world '").append(C).append("'").toString());
|
||||
minecraft.launchIntegratedServer(C, C, null);
|
||||
L(BenchmarkPhase.LOADING, l);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case MENU:
|
||||
if (minecraft.thePlayer != null && minecraft.theWorld != null) {
|
||||
minecraft.displayGuiScreen(null);
|
||||
d(minecraft);
|
||||
L();
|
||||
d("world up, warming up");
|
||||
L(BenchmarkPhase.WARMUP, l);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case LOADING:
|
||||
i(minecraft);
|
||||
if (l - j >= k) {
|
||||
L(minecraft, l);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case WARMUP:
|
||||
i(minecraft);
|
||||
if (l - j >= 700000000L) {
|
||||
LONGS.clear();
|
||||
I = l;
|
||||
L(BenchmarkPhase.MEASURE, l);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case DONE:
|
||||
i(minecraft);
|
||||
LONGS.add(l - I);
|
||||
I = l;
|
||||
if (l - j >= h) {
|
||||
L(minecraft, BENCHMARK_SCENARIOS.get(d).label());
|
||||
L(BENCHMARK_SCENARIOS.get(d).label());
|
||||
D(minecraft);
|
||||
d++;
|
||||
if (d >= BENCHMARK_SCENARIOS.size()) {
|
||||
D();
|
||||
benchmarkPhase = BenchmarkPhase.DONE;
|
||||
minecraft.gameSettings.pauseOnLostFocus = g;
|
||||
minecraft.shutdown();
|
||||
return;
|
||||
}
|
||||
|
||||
L(minecraft, l);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static Module L(String string) {
|
||||
String string1 = string;
|
||||
if (OnyxClient.moduleManager == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Iterator iterator = OnyxClient.moduleManager.getModules().iterator();
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
Module module;
|
||||
if ((module = (Module)iterator.next()).getName().equalsIgnoreCase(string1)) {
|
||||
return module;
|
||||
}
|
||||
}
|
||||
|
||||
d(new StringBuilder().insert(0, "unknown module '").append(string1).append("'").toString());
|
||||
return null;
|
||||
}
|
||||
|
||||
private static void L() {
|
||||
String string = System.getProperty("onyx.bench.modules", "");
|
||||
BENCHMARK_SCENARIOS.add(new BenchmarkScenario("baseline", List.of(), null, null));
|
||||
if (!string.isEmpty() && !string.equals("-")) {
|
||||
String[] strings;
|
||||
int ix = (strings = string.split(",")).length;
|
||||
|
||||
int jx;
|
||||
for (int kx = jx = 0; kx < ix; kx = ++jx) {
|
||||
String string1;
|
||||
if (!(string1 = strings[jx].trim()).isEmpty()) {
|
||||
if (string1.equalsIgnoreCase("ALL")) {
|
||||
BENCHMARK_SCENARIOS.add(new BenchmarkScenario("all render off", L(), null, null));
|
||||
} else if (string1.equalsIgnoreCase("gui")) {
|
||||
BENCHMARK_SCENARIOS.add(new BenchmarkScenario("gui", List.of(), null, null));
|
||||
} else if (string1.toLowerCase(Locale.ROOT).startsWith("only:")) {
|
||||
List list = List.of(string1.substring(5).split("\\+", -1)).stream().map(String::trim).toList();
|
||||
ArrayList arrayList;
|
||||
(arrayList = new ArrayList<>(L())).removeIf(string -> list.stream().anyMatch(string2 -> string2.equalsIgnoreCase(stringx)));
|
||||
BENCHMARK_SCENARIOS.add(new BenchmarkScenario(string1, arrayList, null, null));
|
||||
} else if (string1.toLowerCase(Locale.ROOT).startsWith("look:")) {
|
||||
String[] strings1 = string1.substring(5).split("/");
|
||||
BENCHMARK_SCENARIOS.add(new BenchmarkScenario(string1, List.of(), Float.parseFloat(strings1[0].trim()), Float.parseFloat(strings1[1].trim())));
|
||||
} else {
|
||||
BENCHMARK_SCENARIOS.add(
|
||||
new BenchmarkScenario(
|
||||
new StringBuilder().insert(0, "-").append(string1).toString(),
|
||||
List.of(string1.split("\\+", -1)).stream().map(String::trim).toList(),
|
||||
null,
|
||||
null
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BENCHMARK_SCENARIOS.add(new BenchmarkScenario("baseline (repeat)", List.of(), null, null));
|
||||
}
|
||||
|
||||
private static void L(Minecraft minecraft, String string) {
|
||||
Minecraft minecraft1 = minecraft;
|
||||
String string1;
|
||||
if (!(string1 = System.getProperty("onyx.bench.shots", "")).isEmpty()) {
|
||||
try {
|
||||
File file;
|
||||
(file = new File(string1)).mkdirs();
|
||||
ScreenShotHelper.saveScreenshot(
|
||||
file, string.replaceAll("[^A-Za-z0-9-]", "_") + ".png", minecraft1.displayWidth, minecraft1.displayHeight, minecraft1.getFramebuffer()
|
||||
);
|
||||
} catch (Throwable throwable) {
|
||||
d(new StringBuilder().insert(0, "screenshot failed: ").append(throwable).toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void L(BenchmarkPhase benchmarkPhase, long l) {
|
||||
benchmarkPhase = benchmarkPhasex;
|
||||
j = l;
|
||||
}
|
||||
|
||||
private static void d(Minecraft minecraft) {
|
||||
Minecraft minecraft1 = minecraft;
|
||||
String string;
|
||||
String[] strings;
|
||||
if (!(string = System.getProperty("onyx.bench.pose", "")).isEmpty() && (strings = string.split(",")).length == 5) {
|
||||
i = Double.parseDouble(strings[0].trim());
|
||||
D = Double.parseDouble(strings[1].trim());
|
||||
H = Double.parseDouble(strings[2].trim());
|
||||
e = Float.parseFloat(strings[3].trim());
|
||||
B = Float.parseFloat(strings[4].trim());
|
||||
A = true;
|
||||
} else {
|
||||
i = minecraft1.thePlayer.posX;
|
||||
D = minecraft1.thePlayer.posY;
|
||||
H = minecraft1.thePlayer.posZ;
|
||||
e = 0.0F;
|
||||
B = 0.0F;
|
||||
A = true;
|
||||
Locale locale = Locale.ROOT;
|
||||
Object[] objects = new Object[5];
|
||||
boolean bl = true;
|
||||
objects[0] = i;
|
||||
objects[1] = D;
|
||||
objects[2] = H;
|
||||
objects[3] = minecraft1.displayWidth;
|
||||
objects[4] = minecraft1.displayHeight;
|
||||
d(String.format(locale, "pose %.2f,%.2f,%.2f display %dx%d", objects));
|
||||
}
|
||||
}
|
||||
|
||||
private static void L(Minecraft minecraft) {
|
||||
Minecraft minecraft1 = minecraft;
|
||||
String string;
|
||||
if (!(string = System.getProperty("onyx.bench.hold", "")).isEmpty()) {
|
||||
Item item;
|
||||
if ((item = Item.getByNameOrId(string)) != null) {
|
||||
ItemStack itemStack;
|
||||
if ((itemStack = minecraft1.thePlayer.getHeldItem()) == null || itemStack.getItem() != item) {
|
||||
minecraft1.thePlayer.inventory.mainInventory[minecraft1.thePlayer.inventory.currentItem] = new ItemStack(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void d(String string) {
|
||||
System.out.println(new StringBuilder().insert(0, "[onyx-bench] ").append(string).toString());
|
||||
}
|
||||
|
||||
private static void L(String string) {
|
||||
String string1 = string;
|
||||
if (LONGS.size() < 4) {
|
||||
BENCHMARK_SAMPLES.add(new BenchmarkSample(string1, 0.0, 0.0, 0.0));
|
||||
} else {
|
||||
long[] n = new long[LONGS.size()];
|
||||
boolean bl = true;
|
||||
long[] mx = n;
|
||||
long l = 0L;
|
||||
|
||||
int ix;
|
||||
for (int jx = ix = 0; jx < LONGS.size(); jx = ix) {
|
||||
mx[ix] = LONGS.get(ix);
|
||||
l += mx[ix++];
|
||||
}
|
||||
|
||||
Arrays.sort(mx);
|
||||
double f = LONGS.size() / (l / 1.0E9);
|
||||
double ex = mx[mx.length / 2] / 1000000.0;
|
||||
double dx = mx[(int)(mx.length * 0.95)] / 1000000.0;
|
||||
BENCHMARK_SAMPLES.add(new BenchmarkSample(string1, f, ex, dx));
|
||||
Locale locale = Locale.ROOT;
|
||||
Object[] objects = new Object[4];
|
||||
boolean bl1 = true;
|
||||
objects[0] = string1;
|
||||
objects[1] = f;
|
||||
objects[2] = ex;
|
||||
objects[3] = dx;
|
||||
d(String.format(locale, " %-28s %6.1f fps median %5.2f ms p95 %5.2f ms", objects));
|
||||
}
|
||||
}
|
||||
|
||||
private static void L(Minecraft minecraft, long l) {
|
||||
Minecraft minecraft1 = minecraft;
|
||||
BenchmarkScenario benchmarkScenario;
|
||||
BenchmarkScenario benchmarkScenario1;
|
||||
if ((benchmarkScenario = BENCHMARK_SCENARIOS.get(d)).label().equalsIgnoreCase("gui")) {
|
||||
OnyxClient.moduleManager.clickGUI.setEnabled(true);
|
||||
benchmarkScenario1 = benchmarkScenario;
|
||||
} else {
|
||||
if (minecraft1.currentScreen != null) {
|
||||
minecraft1.displayGuiScreen(null);
|
||||
}
|
||||
|
||||
benchmarkScenario1 = benchmarkScenario;
|
||||
}
|
||||
|
||||
Iterator iterator = benchmarkScenario1.off().iterator();
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
Module module;
|
||||
if ((module = L((String)iterator.next())) != null) {
|
||||
module.setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
d(
|
||||
new StringBuilder()
|
||||
.insert(0, "phase ")
|
||||
.append(d + 1)
|
||||
.append("/")
|
||||
.append(BENCHMARK_SCENARIOS.size())
|
||||
.append(": ")
|
||||
.append(benchmarkScenario.label())
|
||||
.toString()
|
||||
);
|
||||
L(BenchmarkPhase.SETTLE, l);
|
||||
}
|
||||
|
||||
private static List<String> L() {
|
||||
ArrayList arrayList = new ArrayList();
|
||||
if (OnyxClient.moduleManager == null) {
|
||||
return arrayList;
|
||||
}
|
||||
|
||||
Iterator iterator = OnyxClient.moduleManager.getModules().iterator();
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
Module module;
|
||||
if ((module = (Module)iterator.next()).isEnabled()) {
|
||||
arrayList.add(module.getName());
|
||||
}
|
||||
}
|
||||
|
||||
return arrayList;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package openonyx.events;
|
||||
|
||||
// $VF: synthetic class
|
||||
class BenchmarkMetric {
|
||||
static {
|
||||
int[] i = new int[RotationMode.values().length];
|
||||
boolean bl = true;
|
||||
e = i;
|
||||
|
||||
try {
|
||||
e[RotationMode.INSTANT.ordinal()] = 1;
|
||||
} catch (NoSuchFieldError noSuchFieldError2) {
|
||||
}
|
||||
|
||||
try {
|
||||
e[RotationMode.LINEAR.ordinal()] = 2;
|
||||
} catch (NoSuchFieldError noSuchFieldError1) {
|
||||
}
|
||||
|
||||
try {
|
||||
e[RotationMode.SMOOTH.ordinal()] = 3;
|
||||
} catch (NoSuchFieldError noSuchFieldError) {
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package openonyx.events;
|
||||
|
||||
enum BenchmarkPhase {
|
||||
MEASURE,
|
||||
MENU,
|
||||
LOADING,
|
||||
WARMUP,
|
||||
DONE,
|
||||
SETTLE;
|
||||
|
||||
private static BenchmarkPhase[] L() {
|
||||
BenchmarkPhase[] benchmarkPhases = new BenchmarkPhase[6];
|
||||
boolean bl = true;
|
||||
benchmarkPhases[0] = MENU;
|
||||
benchmarkPhases[1] = LOADING;
|
||||
benchmarkPhases[2] = WARMUP;
|
||||
benchmarkPhases[3] = SETTLE;
|
||||
benchmarkPhases[4] = MEASURE;
|
||||
benchmarkPhases[5] = DONE;
|
||||
return benchmarkPhases;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
package openonyx.events;
|
||||
|
||||
record BenchmarkSample(String label, double avgFps, double medianMs, double p95Ms) {
|
||||
}
|
||||
Reference in new issue
Block a user