Upload files to "src/openonyx/utilities"
This commit is contained in:
1 parent
c44f382556
commit
f658a6a800
5 files changed
+289
No files matched your search
@@ -0,0 +1,110 @@
|
|||||||
|
package openonyx.utilities;
|
||||||
|
|
||||||
|
import net.minecraft.util.AxisAlignedBB;
|
||||||
|
import net.minecraft.util.EnumFacing;
|
||||||
|
import net.minecraft.util.MathHelper;
|
||||||
|
import net.minecraft.util.Vec3;
|
||||||
|
import net.minecraft.util.EnumFacing.AxisDirection;
|
||||||
|
import openonyx.utilities.internal.Box3;
|
||||||
|
|
||||||
|
public class BoxUtils {
|
||||||
|
public static double L(AxisAlignedBB axisAlignedBB, double d, double e, double f) {
|
||||||
|
d = Math.max(Math.max(axisAlignedBB.minX - d, d - axisAlignedBB.maxX), 0.0);
|
||||||
|
e = Math.max(Math.max(axisAlignedBB.minY - e, e - axisAlignedBB.maxY), 0.0);
|
||||||
|
f = Math.max(Math.max(axisAlignedBB.minZ - f, f - axisAlignedBB.maxZ), 0.0);
|
||||||
|
return d * d + e * e + f * f;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static double L(AxisAlignedBB axisAlignedBB, EnumFacing enumFacing) {
|
||||||
|
return enumFacing.getAxisDirection() == AxisDirection.POSITIVE ? axisAlignedBB.max(enumFacing.getAxis()) : axisAlignedBB.min(enumFacing.getAxis());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Vec3 L(AxisAlignedBB axisAlignedBB, EnumFacing enumFacing) {
|
||||||
|
double d = axisAlignedBB.minX + axisAlignedBB.getXsize() * 0.5;
|
||||||
|
double e = axisAlignedBB.minY + axisAlignedBB.getYsize() * 0.5;
|
||||||
|
double f = axisAlignedBB.minZ + axisAlignedBB.getZsize() * 0.5;
|
||||||
|
return L(axisAlignedBB, d, e, f, enumFacing);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Vec3 L(AxisAlignedBB axisAlignedBB, Vec3 vec3) {
|
||||||
|
return new Vec3(
|
||||||
|
MathHelper.clamp_double(vec3.xCoord, axisAlignedBB.minX, axisAlignedBB.maxX),
|
||||||
|
MathHelper.clamp_double(vec3.yCoord, axisAlignedBB.minY, axisAlignedBB.maxY),
|
||||||
|
MathHelper.clamp_double(vec3.zCoord, axisAlignedBB.minZ, axisAlignedBB.maxZ)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Vec3 L(AxisAlignedBB axisAlignedBB, Vec3 vec3, EnumFacing enumFacing) {
|
||||||
|
Vec3 vec31;
|
||||||
|
return L(axisAlignedBB, (vec31 = L(axisAlignedBB, vec3)).xCoord, vec31.yCoord, vec31.zCoord, enumFacing);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Vec3 L(AxisAlignedBB axisAlignedBB, double d, double e, double f, EnumFacing enumFacing) {
|
||||||
|
switch (enumFacing) {
|
||||||
|
case DOWN:
|
||||||
|
return new Vec3(d, axisAlignedBB.minY, f);
|
||||||
|
case UP:
|
||||||
|
return new Vec3(d, axisAlignedBB.maxY, f);
|
||||||
|
case NORTH:
|
||||||
|
return new Vec3(d, e, axisAlignedBB.minZ);
|
||||||
|
case SOUTH:
|
||||||
|
return new Vec3(d, e, axisAlignedBB.maxZ);
|
||||||
|
case WEST:
|
||||||
|
return new Vec3(axisAlignedBB.minX, e, f);
|
||||||
|
case EAST:
|
||||||
|
return new Vec3(axisAlignedBB.maxX, e, f);
|
||||||
|
default:
|
||||||
|
throw new MatchException(null, null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Box3 L(AxisAlignedBB axisAlignedBB, EnumFacing enumFacing) {
|
||||||
|
switch (enumFacing) {
|
||||||
|
case DOWN:
|
||||||
|
return new Box3(
|
||||||
|
new Vec3(axisAlignedBB.minX, axisAlignedBB.minY, axisAlignedBB.minZ), new Vec3(axisAlignedBB.maxX, axisAlignedBB.minY, axisAlignedBB.maxZ)
|
||||||
|
);
|
||||||
|
case UP:
|
||||||
|
return new Box3(
|
||||||
|
new Vec3(axisAlignedBB.minX, axisAlignedBB.maxY, axisAlignedBB.minZ), new Vec3(axisAlignedBB.maxX, axisAlignedBB.maxY, axisAlignedBB.maxZ)
|
||||||
|
);
|
||||||
|
case NORTH:
|
||||||
|
return new Box3(
|
||||||
|
new Vec3(axisAlignedBB.minX, axisAlignedBB.minY, axisAlignedBB.minZ), new Vec3(axisAlignedBB.maxX, axisAlignedBB.maxY, axisAlignedBB.minZ)
|
||||||
|
);
|
||||||
|
case SOUTH:
|
||||||
|
return new Box3(
|
||||||
|
new Vec3(axisAlignedBB.minX, axisAlignedBB.minY, axisAlignedBB.maxZ), new Vec3(axisAlignedBB.maxX, axisAlignedBB.maxY, axisAlignedBB.maxZ)
|
||||||
|
);
|
||||||
|
case WEST:
|
||||||
|
return new Box3(
|
||||||
|
new Vec3(axisAlignedBB.minX, axisAlignedBB.minY, axisAlignedBB.minZ), new Vec3(axisAlignedBB.minX, axisAlignedBB.maxY, axisAlignedBB.maxZ)
|
||||||
|
);
|
||||||
|
case EAST:
|
||||||
|
return new Box3(
|
||||||
|
new Vec3(axisAlignedBB.maxX, axisAlignedBB.minY, axisAlignedBB.minZ), new Vec3(axisAlignedBB.maxX, axisAlignedBB.maxY, axisAlignedBB.maxZ)
|
||||||
|
);
|
||||||
|
default:
|
||||||
|
throw new MatchException(null, null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static double L(AxisAlignedBB axisAlignedBB, Vec3 vec3) {
|
||||||
|
return L(axisAlignedBB, vec3.xCoord, vec3.yCoord, vec3.zCoord);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Vec3[] L(AxisAlignedBB axisAlignedBB) {
|
||||||
|
Vec3[] vec3s = new Vec3[8];
|
||||||
|
boolean bl = true;
|
||||||
|
boolean bl1 = false;
|
||||||
|
vec3s[0] = new Vec3(axisAlignedBB.minX, axisAlignedBB.minY, axisAlignedBB.minZ);
|
||||||
|
vec3s[1] = new Vec3(axisAlignedBB.minX, axisAlignedBB.minY, axisAlignedBB.maxZ);
|
||||||
|
vec3s[2] = new Vec3(axisAlignedBB.minX, axisAlignedBB.maxY, axisAlignedBB.minZ);
|
||||||
|
vec3s[3] = new Vec3(axisAlignedBB.minX, axisAlignedBB.maxY, axisAlignedBB.maxZ);
|
||||||
|
vec3s[4] = new Vec3(axisAlignedBB.maxX, axisAlignedBB.minY, axisAlignedBB.minZ);
|
||||||
|
vec3s[5] = new Vec3(axisAlignedBB.maxX, axisAlignedBB.minY, axisAlignedBB.maxZ);
|
||||||
|
vec3s[6] = new Vec3(axisAlignedBB.maxX, axisAlignedBB.maxY, axisAlignedBB.minZ);
|
||||||
|
vec3s[7] = new Vec3(axisAlignedBB.maxX, axisAlignedBB.maxY, axisAlignedBB.maxZ);
|
||||||
|
return vec3s;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
package openonyx.utilities;
|
||||||
|
|
||||||
|
import net.minecraft.util.EnumFacing;
|
||||||
|
|
||||||
|
// $VF: synthetic class
|
||||||
|
class BoxUtilsPart {
|
||||||
|
static {
|
||||||
|
int[] i = new int[EnumFacing.values().length];
|
||||||
|
boolean bl = true;
|
||||||
|
e = i;
|
||||||
|
|
||||||
|
try {
|
||||||
|
e[EnumFacing.DOWN.ordinal()] = 1;
|
||||||
|
} catch (NoSuchFieldError noSuchFieldError5) {
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
e[EnumFacing.UP.ordinal()] = 2;
|
||||||
|
} catch (NoSuchFieldError noSuchFieldError4) {
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
e[EnumFacing.NORTH.ordinal()] = 3;
|
||||||
|
} catch (NoSuchFieldError noSuchFieldError3) {
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
e[EnumFacing.SOUTH.ordinal()] = 4;
|
||||||
|
} catch (NoSuchFieldError noSuchFieldError2) {
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
e[EnumFacing.WEST.ordinal()] = 5;
|
||||||
|
} catch (NoSuchFieldError noSuchFieldError1) {
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
e[EnumFacing.EAST.ordinal()] = 6;
|
||||||
|
} catch (NoSuchFieldError noSuchFieldError) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,60 @@
|
|||||||
|
package openonyx.utilities;
|
||||||
|
|
||||||
|
import java.util.Comparator;
|
||||||
|
|
||||||
|
public class ChainedComparator<T> implements Comparator<T> {
|
||||||
|
private final Comparator<? super T>[] comparators;
|
||||||
|
|
||||||
|
@SafeVarargs
|
||||||
|
public ChainedComparator(Comparator<? super T>... comparators) {
|
||||||
|
this.comparators = comparatorsx;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String decrypt(String string) {
|
||||||
|
String string1 = string;
|
||||||
|
int n = (5 >> 1 ^ 5) << 4 ^ 5;
|
||||||
|
String string2;
|
||||||
|
int p = (string2 = string1).length();
|
||||||
|
char[] e = new char[p];
|
||||||
|
boolean bl = true;
|
||||||
|
int j;
|
||||||
|
int o = j = p - 1;
|
||||||
|
char[] c = e;
|
||||||
|
byte b = 18;
|
||||||
|
byte d = 84;
|
||||||
|
int k = o;
|
||||||
|
int i = n;
|
||||||
|
|
||||||
|
while (k >= 0) {
|
||||||
|
int l = j;
|
||||||
|
int m = string2.charAt(j);
|
||||||
|
j--;
|
||||||
|
c[l] = (char)(m ^ i);
|
||||||
|
if (j < 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
m = j--;
|
||||||
|
c[m] = (char)(string2.charAt(m) ^ b);
|
||||||
|
k = j;
|
||||||
|
}
|
||||||
|
|
||||||
|
return new String(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int compare(T object, T object1) {
|
||||||
|
ChainedComparator chainedComparator1 = this;
|
||||||
|
Comparator[] comparatorsx = chainedComparator1.comparators;
|
||||||
|
int i = chainedComparator1.comparators.length;
|
||||||
|
|
||||||
|
for (int l = k = 0; l < i; l = ++k) {
|
||||||
|
int j;
|
||||||
|
if ((j = comparatorsx[k].compare(object, object1)) != 0) {
|
||||||
|
return j;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
package openonyx.utilities;
|
||||||
|
|
||||||
|
import java.util.function.BooleanSupplier;
|
||||||
|
|
||||||
|
public class ConditionalAction {
|
||||||
|
private final Runnable runnable;
|
||||||
|
private boolean H;
|
||||||
|
private final BooleanSupplier booleanSupplier;
|
||||||
|
|
||||||
|
public ConditionalAction(BooleanSupplier booleanSupplier, Runnable runnable) {
|
||||||
|
this.booleanSupplier = booleanSupplierx;
|
||||||
|
this.runnable = runnablex;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void L() {
|
||||||
|
if (!this.H && this.booleanSupplier.getAsBoolean()) {
|
||||||
|
this.runnable.run();
|
||||||
|
this.H = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,56 @@
|
|||||||
|
package openonyx.utilities;
|
||||||
|
|
||||||
|
import meteordevelopment.orbit.EventHandler;
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.client.gui.inventory.GuiInventory;
|
||||||
|
import net.minecraft.network.Packet;
|
||||||
|
import net.minecraft.network.play.client.C0DPacketCloseWindow;
|
||||||
|
import net.minecraft.network.play.client.C0EPacketClickWindow;
|
||||||
|
import net.minecraft.network.play.server.S2DPacketOpenWindow;
|
||||||
|
import net.minecraft.network.play.server.S2EPacketCloseWindow;
|
||||||
|
import openonyx.configuration.internal.PacketEvent;
|
||||||
|
import openonyx.configuration.internal.WorldChangeEvent;
|
||||||
|
|
||||||
|
public final class ContainerTracker {
|
||||||
|
private boolean H;
|
||||||
|
public static final ContainerTracker INSTANCE = new ContainerTracker();
|
||||||
|
|
||||||
|
private ContainerTracker() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean L() {
|
||||||
|
return Minecraft.getMinecraft().currentScreen instanceof GuiInventory || this.H;
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = -1000)
|
||||||
|
private void onPacket(PacketEvent packetEvent) {
|
||||||
|
if (!packetEvent.isCancelled()) {
|
||||||
|
Packet packet = packetEvent.getPacket();
|
||||||
|
switch (packet) {
|
||||||
|
case C0EPacketClickWindow c0EPacketClickWindow:
|
||||||
|
while (false) {
|
||||||
|
}
|
||||||
|
|
||||||
|
if (((C0EPacketClickWindow)packet).getWindowId() == 0) {
|
||||||
|
this.H = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
case C0DPacketCloseWindow c0DPacketCloseWindow:
|
||||||
|
this.H = false;
|
||||||
|
return;
|
||||||
|
case S2EPacketCloseWindow s2EPacketCloseWindow:
|
||||||
|
this.H = false;
|
||||||
|
return;
|
||||||
|
case S2DPacketOpenWindow s2DPacketOpenWindow:
|
||||||
|
this.H = false;
|
||||||
|
return;
|
||||||
|
default:
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
private void onWorldChange(WorldChangeEvent worldChangeEvent) {
|
||||||
|
this.H = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in new issue
Block a user