Upload files to "src/openonyx/utilities"

This commit is contained in:
winterflyt committed 2026-11-30 06:18:50 +02:00
1 parent f658a6a800
commit e5f9d06113
5 files changed
+382

No files matched your search

+188
View File
@@ -0,0 +1,188 @@
package openonyx.utilities;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.BlockPos;
import net.minecraft.util.MathHelper;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.Vec3;
import openonyx.core.MinecraftAccess;
public class EdgeCollision implements MinecraftAccess {
public static Vec3 L(Vec3 vec3, Vec3 vec31, float f) {
Vec3 vec32 = vec3;
Vec3 vec35;
if ((vec35 = vec31.subtract(vec32)).lengthSqr() <= 1.0E-12) {
return null;
}
List list = L(vec32, vec31, f);
Vec3 vec33 = vec32;
Vec3 vec34 = vec32.add(vec35.scale(-1000.0));
vec35 = vec31.add(vec35.scale(1000.0));
HashSet hashSet;
HashSet hashSet1 = hashSet = new HashSet();
while (true) {
hashSet1.clear();
Iterator iterator1 = list.iterator();
while (iterator1.hasNext()) {
AxisAlignedBB axisAlignedBB;
if ((axisAlignedBB = (AxisAlignedBB)iterator1.next()).isVecInside(vec33)) {
hashSet.add(axisAlignedBB);
}
}
if (hashSet.isEmpty()) {
return vec33;
}
Iterator iterator2 = hashSet.iterator();
while (iterator2.hasNext()) {
if (((AxisAlignedBB)iterator2.next()).isVecInside(vec31)) {
return null;
}
}
vec3 = null;
double e = Double.POSITIVE_INFINITY;
Iterator iterator = hashSet.iterator();
while (iterator.hasNext()) {
AxisAlignedBB axisAlignedBB1;
MovingObjectPosition movingObjectPosition;
if ((movingObjectPosition = (axisAlignedBB1 = (AxisAlignedBB)iterator.next()).calculateIntercept(vec35, vec34)) == null) {
throw new IllegalArgumentException(
new StringBuilder()
.insert(0, "Raycast failed. This should be impossible. AABB=")
.append(axisAlignedBB1)
.append(" from=")
.append(vec32)
.append(" to=")
.append(vec31)
.toString()
);
}
Vec3 vec36 = movingObjectPosition.hitVec;
double d;
if ((d = movingObjectPosition.hitVec.distanceToSqr(vec31)) < e) {
e = d;
vec3 = vec36;
}
}
if (vec3 == null) {
throw new IllegalStateException("Unable to resolve an edge collision");
}
vec33 = vec3;
hashSet1 = hashSet;
list.removeAll(hashSet);
}
}
public static void L() {
mc.thePlayer.motionX = 0.0;
mc.thePlayer.motionZ = 0.0;
}
private static List<AxisAlignedBB> L(Vec3 vec3, Vec3 vec31, float f) {
Vec3 vec32 = vec3;
AxisAlignedBB axisAlignedBB2 = PlayerUtils.L(vec32);
AxisAlignedBB axisAlignedBB = PlayerUtils.L(vec31);
AxisAlignedBB axisAlignedBB3 = axisAlignedBB2.union(axisAlignedBB);
BlockPos blockPos1 = VecUtils.L(new Vec3(axisAlignedBB3.minX - 0.3 - 1.0E-7, axisAlignedBB3.minY - f - 1.0E-7, axisAlignedBB3.minZ - 0.3 - 1.0E-7));
BlockPos blockPos = VecUtils.L(new Vec3(axisAlignedBB3.maxX + 0.3 + 1.0E-7, axisAlignedBB3.minY + 1.0E-7, axisAlignedBB3.maxZ + 0.3 + 1.0E-7));
Vec3 vec33;
Vec3 vec34 = vec32.add((vec33 = vec31.subtract(vec32)).scale(-1000.0));
vec31 = vec31.add(vec33.scale(1000.0));
ArrayList arrayList1 = new ArrayList();
ArrayList arrayList = new ArrayList();
for (BlockPos blockPos2 : BlockPos.getAllInBox(blockPos1, blockPos)) {
IBlockState iBlockState = mc.theWorld.getBlockState(blockPos2);
arrayList.clear();
L(iBlockState, blockPos2, arrayList);
Iterator iterator;
Iterator iterator1 = iterator = arrayList.iterator();
while (iterator1.hasNext()) {
AxisAlignedBB axisAlignedBB1 = (AxisAlignedBB)iterator.next();
if ((axisAlignedBB1 = new AxisAlignedBB(
axisAlignedBB1.minX - 0.3,
axisAlignedBB1.minY - 1.0,
axisAlignedBB1.minZ - 0.3,
axisAlignedBB1.maxX + 0.3,
axisAlignedBB1.maxY + f + 0.05,
axisAlignedBB1.maxZ + 0.3
))
.calculateIntercept(vec34, vec31)
== null) {
iterator1 = iterator;
} else {
arrayList1.add(axisAlignedBB1);
iterator1 = iterator;
}
}
}
return arrayList1;
}
public static MovementInputState L(MovementInputState movementInputState, float f, float g) {
boolean bl = movementInputState.forwards();
boolean bl1 = movementInputState.backwards();
boolean bl2 = movementInputState.left();
boolean bl3 = movementInputState.right();
float h;
if (f > -90.0F + g && f < 90.0F - g) {
bl = true;
h = f;
} else {
if (f < -90.0F - g || f > 90.0F + g) {
bl1 = true;
}
h = f;
}
if (h > g && f < 180.0F - g) {
bl3 = true;
} else if (f > -180.0F + g && f < -g) {
bl2 = true;
}
return new MovementInputState(bl, bl1, bl2, bl3);
}
public static void L(IBlockState iBlockState, BlockPos blockPos, List<AxisAlignedBB> list) {
if (iBlockState.getBlock().getMaterial() != Material.air) {
AxisAlignedBB axisAlignedBB = new AxisAlignedBB(
blockPos.getX() - 1.0, blockPos.getY() - 1.0, blockPos.getZ() - 1.0, blockPos.getX() + 2.0, blockPos.getY() + 2.0, blockPos.getZ() + 2.0
);
iBlockState.getBlock().addCollisionBoxesToList(mc.theWorld, blockPos, iBlockState, axisAlignedBB, list, null);
}
}
public static Vec3 L(Vec3 vec3, Vec3 vec31) {
return L(vec3, vec31, 0.5F);
}
public static float L(Vec3 vec3, float f) {
double d = VecUtils.L(vec3);
f = MathHelper.wrapAngleTo180_float(f);
return MathHelper.wrapAngleTo180_float((float)d - f);
}
public static MovementInputState L(MovementInputState movementInputState, float f) {
return L(movementInputState, f, 20.0F);
}
}
+105
View File
@@ -0,0 +1,105 @@
package openonyx.utilities;
import java.io.File;
import java.lang.reflect.Method;
import java.net.URI;
import java.nio.file.Path;
import openonyx.core.OnyxClient;
import org.apache.logging.log4j.Logger;
public final class FileUtils {
public static void L(Path path) {
Path path1 = path;
try {
Class class_xx;
Class class_x = class_xx = Class.forName("java.awt.Desktop");
Class[] class_xx = new Class[0];
boolean bl = true;
Method method = class_x.getMethod("getDesktop", class_xx);
Object[] objects = new Object[0];
bl = true;
Object object = method.invoke(null, objects);
objects = new Class[1];
bl = true;
objects[0] = File.class;
Method method1 = class_xx.getMethod("open", objects);
objects = new Object[1];
bl = true;
objects[0] = path1.toFile();
method1.invoke(object, objects);
} catch (Throwable throwable) {
L(path1.toUri());
}
}
public static void L(URI uRI) {
URI uRI1 = uRI;
try {
Class class_xx;
Class class_x = class_xx = Class.forName("java.awt.Desktop");
Class[] class_xx = new Class[0];
boolean bl = true;
Method method = class_x.getMethod("getDesktop", class_xx);
Object[] objects = new Object[0];
bl = true;
Object object = method.invoke(null, objects);
objects = new Class[1];
bl = true;
objects[0] = URI.class;
Method method1 = class_xx.getMethod("browse", objects);
objects = new Object[1];
bl = true;
objects[0] = uRI1;
method1.invoke(object, objects);
} catch (Throwable throwable) {
Logger logger = OnyxClient.LOGGER;
Object[] objects1 = new Object[2];
boolean bl1 = true;
objects1[0] = uRI1;
objects1[1] = throwable;
logger.error("Could not open {}", objects1);
}
}
public static String decrypt(String string) {
String string1 = string;
int p = --5 << 4 ^ 15;
int q = 4 << 4 ^ 12;
String string2;
int r = (string2 = string1).length();
char[] e = new char[r];
boolean bl = true;
int k;
int n = k = r - 1;
char[] c = e;
int j = q;
int o = 84;
int l = n;
int i = p;
while (l >= 0) {
int m = k;
char d = string2.charAt(k);
k--;
c[m] = (char)(d ^ i);
if (k < 0) {
break;
}
o = k--;
c[o] = (char)(string2.charAt(o) ^ j);
l = k;
}
return new String(c);
}
public static void L(String string) {
L(URI.create(string));
}
private FileUtils() {
}
}
+80
View File
@@ -0,0 +1,80 @@
package openonyx.utilities;
import meteordevelopment.orbit.EventHandler;
import openonyx.configuration.internal.HotbarSlotEvent;
import openonyx.configuration.internal.PreTickEvent;
import openonyx.configuration.internal.WorldChangeEvent;
import openonyx.core.MinecraftAccess;
import openonyx.core.OnyxClient;
public class HotbarManager implements MinecraftAccess {
private int f;
private HotbarManagerData hotbarManagerData;
public static final HotbarManager INSTANCE = new HotbarManager();
private int D() {
return mc.thePlayer == null ? 0 : mc.thePlayer.inventory.currentItem;
}
public int d() {
return this.hotbarManagerData != null ? this.hotbarManagerData.clientsideSlot : this.D();
}
public boolean L(Object object) {
return this.hotbarManagerData != null && this.hotbarManagerData.requester == object;
}
public int L() {
return this.hotbarManagerData != null ? this.hotbarManagerData.enforcedHotbarSlot : this.D();
}
public boolean L(Object object, int i, int j) {
if (!L(i)) {
throw new IllegalArgumentException(new StringBuilder().insert(0, "Invalid hotbar slot: ").append(i).toString());
}
HotbarSlotEvent hotbarSlotEvent = new HotbarSlotEvent(object, i);
OnyxClient.EVENT_BUS.post(hotbarSlotEvent);
if (hotbarSlotEvent.isCancelled()) {
return false;
}
this.hotbarManagerData = new HotbarManagerData(i, object, j, this.d());
this.f = 0;
return true;
}
private HotbarManager() {
}
public boolean L() {
return this.hotbarManagerData != null;
}
public void L(Object object) {
if (this.hotbarManagerData != null && this.hotbarManagerData.requester == object) {
this.hotbarManagerData = null;
}
}
@EventHandler
public void onWorldChange(WorldChangeEvent worldChangeEvent) {
this.hotbarManagerData = null;
this.f = 0;
}
@EventHandler(priority = 1001)
public void onPreTick(PreTickEvent preTickEvent) {
if (this.hotbarManagerData != null) {
if (this.f >= this.hotbarManagerData.ticksUntilReset) {
this.hotbarManagerData = null;
} else {
this.f++;
}
}
}
public static boolean L(int i) {
return i >= 0 && i < 9;
}
}
@@ -0,0 +1,4 @@
package openonyx.utilities;
record HotbarManagerData(int enforcedHotbarSlot, Object requester, int ticksUntilReset, int clientsideSlot) {
}
+5
View File
@@ -0,0 +1,5 @@
package openonyx.utilities;
public record InputFlags(boolean forward, boolean backward, boolean left, boolean right, boolean jump, boolean shift, boolean sprint) {
public static final InputFlags INSTANCE = new InputFlags(false, false, false, false, false, false, false);
}