Upload files to "src/openonyx/features/player/internal"
This commit is contained in:
1 parent
7f309f66f1
commit
71f9ed0dcf
5 files changed
+389
No files matched your search
@@ -0,0 +1,64 @@
|
||||
package openonyx.features.player.internal;
|
||||
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
import openonyx.protocol.group_d.RotationAngleMath;
|
||||
|
||||
public final class FeatureSupport_419 {
|
||||
private int e;
|
||||
|
||||
public float L(float f, double d) {
|
||||
if (d <= 0.0) {
|
||||
return f;
|
||||
}
|
||||
|
||||
double ex;
|
||||
return (ex = RotationAngleMath.d()) <= 0.0 ? f : (float)(f + this.L(Math.max(1, (int)Math.floor(d / ex))) * ex);
|
||||
}
|
||||
|
||||
public static String decrypt(String string) {
|
||||
String string1 = string;
|
||||
int p = (5 >> 1 ^ 5) << 4 ^ 6;
|
||||
int q = 112 ^ 1 << 1;
|
||||
String string2;
|
||||
int r = (string2 = string1).length();
|
||||
char[] ex = new char[r];
|
||||
boolean bl = true;
|
||||
int k;
|
||||
int n = k = r - 1;
|
||||
char[] c = ex;
|
||||
int j = q;
|
||||
int o = 108;
|
||||
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);
|
||||
}
|
||||
|
||||
private int L(int i) {
|
||||
FeatureSupport_419 featureSupport_4191 = this;
|
||||
if (i <= 1) {
|
||||
return featureSupport_4191.e = featureSupport_4191.e > 0 ? -1 : 1;
|
||||
}
|
||||
|
||||
do {
|
||||
while ((j = ThreadLocalRandom.current().nextInt(-i, i + 1)) == 0) {
|
||||
}
|
||||
} while (j == featureSupport_4191.e);
|
||||
|
||||
return featureSupport_4191.e = j;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package openonyx.features.player.internal;
|
||||
|
||||
import java.util.Set;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.block.BlockFalling;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import openonyx.core.MinecraftAccess;
|
||||
import openonyx.utilities.BlockItemUtils;
|
||||
|
||||
public final class ScaffoldBlockFilter implements MinecraftAccess {
|
||||
private static final Set<Block> BLOCKS = Set.of(Blocks.tnt, Blocks.web, Blocks.portal);
|
||||
private static final Set<Block> BLOCKS2 = Set.of(Blocks.crafting_table, Blocks.enchanting_table, Blocks.cauldron);
|
||||
|
||||
public static boolean d(ItemStack itemStack) {
|
||||
ItemStack itemStack1 = itemStack;
|
||||
if (itemStack1 == null) {
|
||||
return false;
|
||||
} else {
|
||||
Block block;
|
||||
if ((block = BlockItemUtils.L(itemStack1)) == null) {
|
||||
return false;
|
||||
} else if (!block.getMaterial().isSolid() || !block.isFullCube()) {
|
||||
return false;
|
||||
} else {
|
||||
return block instanceof BlockFalling ? false : !BLOCKS.contains(block);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private ScaffoldBlockFilter() {
|
||||
}
|
||||
|
||||
public static boolean L(ItemStack itemStack) {
|
||||
ItemStack itemStack1 = itemStack;
|
||||
Block block;
|
||||
if ((block = BlockItemUtils.L(itemStack1)) == null) {
|
||||
return true;
|
||||
} else if (block.slipperiness > 0.6F) {
|
||||
return true;
|
||||
} else if (block instanceof BlockContainer) {
|
||||
return true;
|
||||
} else {
|
||||
return !block.isFullCube() ? true : BLOCKS2.contains(block);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,245 @@
|
||||
package openonyx.features.player.internal;
|
||||
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Deque;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.Vec3;
|
||||
import openonyx.core.MinecraftAccess;
|
||||
import openonyx.interaction.BlockUtils;
|
||||
import openonyx.utilities.EdgeCollision;
|
||||
import openonyx.utilities.MovementInputState;
|
||||
import openonyx.utilities.PlayerUtils;
|
||||
import openonyx.utilities.VecUtils;
|
||||
import openonyx.utilities.internal.Line3;
|
||||
|
||||
public final class ScaffoldPathfinder implements MinecraftAccess {
|
||||
private static ScaffoldPathfinderData scaffoldPathfinderData;
|
||||
private static final int h = 4;
|
||||
private static final double l = 0.001;
|
||||
private static BlockPos blockPos;
|
||||
private static final Deque<BlockPos> BLOCK_POS_LIST = new ArrayDeque<>(4);
|
||||
private static final double i = 0.02;
|
||||
private static final double[] f;
|
||||
private static float H = Float.NaN;
|
||||
private static final float e = 30.0F;
|
||||
|
||||
private ScaffoldPathfinder() {
|
||||
}
|
||||
|
||||
private static ScaffoldPathfinderData2 L(Map<BlockPos, ScaffoldPathfinderData2> map, ScaffoldPathfinderData2 scaffoldPathfinderData2) {
|
||||
Map map1 = map;
|
||||
BlockPos blockPosx;
|
||||
ScaffoldPathfinderData2 scaffoldPathfinderData21 = (blockPosx = BLOCK_POS_LIST.peekLast()) == null ? null : (ScaffoldPathfinderData2)map1.get(blockPosx);
|
||||
ScaffoldPathfinderData2 scaffoldPathfinderData22 = blockPos == null ? null : (ScaffoldPathfinderData2)map1.get(blockPos);
|
||||
if (scaffoldPathfinderData21 != null && scaffoldPathfinderData21.L(scaffoldPathfinderData2)) {
|
||||
return scaffoldPathfinderData21;
|
||||
} else {
|
||||
return scaffoldPathfinderData22 != null && scaffoldPathfinderData22.L(scaffoldPathfinderData2) ? scaffoldPathfinderData22 : scaffoldPathfinderData2;
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean L(Line3 line3, Vec3 vec3) {
|
||||
return line3.direction().dotProduct(vec3) < 0.5;
|
||||
}
|
||||
|
||||
public static ScaffoldPathfinderData getScaffoldPathfinderData() {
|
||||
return scaffoldPathfinderData;
|
||||
}
|
||||
|
||||
private static Vec3 L(float f) {
|
||||
float g = fx;
|
||||
if (!Float.isNaN(H) && L(g, H) <= 30.0F) {
|
||||
return Vec3.directionFromRotation(0.0F, H);
|
||||
}
|
||||
|
||||
H = fx = MathHelper.wrapAngleTo180_float(((float)Math.rint(g / 180.0F * 4.0F + 4.0F) - 4.0F) / 4.0F * 180.0F);
|
||||
return Vec3.directionFromRotation(0.0F, fx);
|
||||
}
|
||||
|
||||
public static void L() {
|
||||
blockPos = null;
|
||||
scaffoldPathfinderData = null;
|
||||
H = Float.NaN;
|
||||
BLOCK_POS_LIST.clear();
|
||||
}
|
||||
|
||||
private static Map<BlockPos, ScaffoldPathfinderData2> L() {
|
||||
LinkedHashMap linkedHashMap = new LinkedHashMap();
|
||||
Vec3 vec3 = PlayerUtils.D((Entity)mc.thePlayer);
|
||||
double[] d = f;
|
||||
int ix = f.length;
|
||||
|
||||
int j;
|
||||
for (int n = j = 0; n < ix; n = ++j) {
|
||||
double ex = d[j];
|
||||
double[] fx = f;
|
||||
int k = f.length;
|
||||
|
||||
int lx;
|
||||
for (int m = lx = 0; m < k; m = ++lx) {
|
||||
double g = fx[lx];
|
||||
BlockPos blockPosx = VecUtils.L(vec3, ex, -1.0, g);
|
||||
IBlockState iBlockState;
|
||||
if (!linkedHashMap.containsKey(blockPosx) && (iBlockState = BlockUtils.L(blockPosx)) != null && !L(iBlockState, blockPosx).isEmpty()) {
|
||||
linkedHashMap.put(blockPosx, L(blockPosx));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return linkedHashMap;
|
||||
}
|
||||
|
||||
public static void L(BlockPos blockPos) {
|
||||
if (!blockPosx.equals(BLOCK_POS_LIST.peekLast())) {
|
||||
while (BLOCK_POS_LIST.size() >= 4) {
|
||||
BLOCK_POS_LIST.removeFirst();
|
||||
}
|
||||
|
||||
BLOCK_POS_LIST.addLast(blockPosx);
|
||||
}
|
||||
}
|
||||
|
||||
private static float L(float f, float g) {
|
||||
return Math.abs(MathHelper.wrapAngleTo180_float(g - fx));
|
||||
}
|
||||
|
||||
private static List<AxisAlignedBB> L(IBlockState iBlockState, BlockPos blockPos) {
|
||||
IBlockState iBlockState1 = iBlockState;
|
||||
ArrayList arrayList = new ArrayList(1);
|
||||
if (iBlockState1 != null) {
|
||||
EdgeCollision.L(iBlockState1, blockPosx, arrayList);
|
||||
}
|
||||
|
||||
return arrayList;
|
||||
}
|
||||
|
||||
private static ScaffoldPathfinderData L() {
|
||||
Map map;
|
||||
if ((map = L()).isEmpty()) {
|
||||
scaffoldPathfinderData = null;
|
||||
blockPos = null;
|
||||
return null;
|
||||
}
|
||||
|
||||
ScaffoldPathfinderData2 scaffoldPathfinderData2 = null;
|
||||
|
||||
for (ScaffoldPathfinderData2 scaffoldPathfinderData21 : map.values()) {
|
||||
if (scaffoldPathfinderData2 == null || scaffoldPathfinderData21.L(scaffoldPathfinderData2) < 0) {
|
||||
scaffoldPathfinderData2 = scaffoldPathfinderData21;
|
||||
}
|
||||
}
|
||||
|
||||
if (scaffoldPathfinderData2 == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
ScaffoldPathfinderData2 scaffoldPathfinderData22;
|
||||
blockPos = (scaffoldPathfinderData22 = L(map, scaffoldPathfinderData2)).blockPos();
|
||||
Vec3 vec3 = PlayerUtils.D((Entity)mc.thePlayer);
|
||||
return new ScaffoldPathfinderData(
|
||||
scaffoldPathfinderData22.blockPos(),
|
||||
vec3.xCoord - (scaffoldPathfinderData22.blockPos().getX() + 0.5),
|
||||
vec3.zCoord - (scaffoldPathfinderData22.blockPos().getZ() + 0.5)
|
||||
);
|
||||
}
|
||||
|
||||
static {
|
||||
double[] d = new double[3];
|
||||
boolean bl = true;
|
||||
d[0] = 0.301;
|
||||
d[1] = 0.0;
|
||||
d[2] = -0.301;
|
||||
f = d;
|
||||
}
|
||||
|
||||
private static ScaffoldPathfinderData2 L(BlockPos blockPos) {
|
||||
BlockPos blockPos1 = blockPosx;
|
||||
AxisAlignedBB axisAlignedBB1 = mc.thePlayer.getEntityBoundingBox();
|
||||
IBlockState iBlockState = BlockUtils.L(blockPos1);
|
||||
double d = Double.POSITIVE_INFINITY;
|
||||
double ex = 0.0;
|
||||
Iterator iterator = L(iBlockState, blockPos1).iterator();
|
||||
|
||||
label28:
|
||||
while (true) {
|
||||
for (Iterator iterator1 = iterator; iterator1.hasNext(); iterator1 = iterator) {
|
||||
AxisAlignedBB axisAlignedBB = (AxisAlignedBB)iterator.next();
|
||||
double fx = Math.min(axisAlignedBB1.maxX, axisAlignedBB.maxX) - Math.max(axisAlignedBB1.minX, axisAlignedBB.minX);
|
||||
double g = Math.min(axisAlignedBB1.maxZ, axisAlignedBB.maxZ) - Math.max(axisAlignedBB1.minZ, axisAlignedBB.minZ);
|
||||
if (fx <= 0.0) {
|
||||
continue label28;
|
||||
}
|
||||
|
||||
if (!(g <= 0.0)) {
|
||||
double hx = Math.abs(axisAlignedBB1.minY - axisAlignedBB.maxY);
|
||||
fx *= g;
|
||||
if (hx + 0.001 < d) {
|
||||
d = hx;
|
||||
ex = fx;
|
||||
} else if (Math.abs(hx - d) <= 0.001) {
|
||||
ex += fx;
|
||||
}
|
||||
continue label28;
|
||||
}
|
||||
}
|
||||
|
||||
return new ScaffoldPathfinderData2(blockPos1, ex, d, VecUtils.L(PlayerUtils.D((Entity)mc.thePlayer), blockPos1.getX() + 0.5, blockPos1.getZ() + 0.5));
|
||||
}
|
||||
}
|
||||
|
||||
public static BlockPos L() {
|
||||
return BLOCK_POS_LIST.peekLast();
|
||||
}
|
||||
|
||||
public static Line3 L(MovementInputState movementInputState) {
|
||||
MovementInputState movementInputState1 = movementInputState;
|
||||
Vec3 vec31 = L(PlayerUtils.L(mc.thePlayer, movementInputState1));
|
||||
ScaffoldPathfinderData scaffoldPathfinderDatax;
|
||||
if ((scaffoldPathfinderDatax = L()) == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
scaffoldPathfinderData = scaffoldPathfinderDatax;
|
||||
Line3 line3 = L();
|
||||
Vec3 vec3 = PlayerUtils.D((Entity)mc.thePlayer);
|
||||
Vec3 vec32;
|
||||
if (line3 != null && !L(line3, vec31)) {
|
||||
vec32 = line3.L(vec3);
|
||||
} else {
|
||||
vec32 = new Vec3(
|
||||
scaffoldPathfinderDatax.blockPos().getX() + 0.5 + scaffoldPathfinderDatax.offsetX(),
|
||||
vec3.yCoord,
|
||||
scaffoldPathfinderDatax.blockPos().getZ() + 0.5 + scaffoldPathfinderDatax.offsetZ()
|
||||
);
|
||||
}
|
||||
|
||||
return new Line3(VecUtils.i(vec32, vec3.yCoord), vec31);
|
||||
}
|
||||
|
||||
private static Line3 L() {
|
||||
if (BLOCK_POS_LIST.size() < 2) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Deque deque = BLOCK_POS_LIST;
|
||||
BlockPos[] blockPos3 = new BlockPos[0];
|
||||
boolean bl = true;
|
||||
BlockPos[] blockPosx;
|
||||
BlockPos[] blockPos2 = blockPosx = deque.toArray(blockPos3);
|
||||
BlockPos blockPos1 = blockPos2[blockPos2.length - 1];
|
||||
Vec3 vec3 = VecUtils.d(blockPosx[blockPosx.length - 2]);
|
||||
Vec3 vec32 = VecUtils.d(blockPos1);
|
||||
Vec3 vec31 = vec3.add(vec32).scale(0.5);
|
||||
Vec3 vec33 = vec32.subtract(vec3).normalize();
|
||||
return new Line3(vec31, vec33);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package openonyx.features.player.internal;
|
||||
|
||||
import net.minecraft.util.BlockPos;
|
||||
|
||||
public record ScaffoldPathfinderData(BlockPos blockPos, double offsetX, double offsetZ) {
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package openonyx.features.player.internal;
|
||||
|
||||
import net.minecraft.util.BlockPos;
|
||||
|
||||
record ScaffoldPathfinderData2(BlockPos blockPos, double overlapArea, double surfaceDelta, double horizontalDistanceToPlayerSqr)
|
||||
implements Comparable<ScaffoldPathfinderData2> {
|
||||
boolean L(ScaffoldPathfinderData2 scaffoldPathfinderData21) {
|
||||
return this.surfaceDelta > scaffoldPathfinderData21.surfaceDelta + 0.001 ? false : !(this.overlapArea + 0.02 < scaffoldPathfinderData21.overlapArea);
|
||||
}
|
||||
|
||||
public int L(ScaffoldPathfinderData2 scaffoldPathfinderData21) {
|
||||
if (this.surfaceDelta + 0.001 < scaffoldPathfinderData21.surfaceDelta) {
|
||||
return -1;
|
||||
} else if (scaffoldPathfinderData21.surfaceDelta + 0.001 < this.surfaceDelta) {
|
||||
return 1;
|
||||
} else if (this.overlapArea > scaffoldPathfinderData21.overlapArea + 0.02) {
|
||||
return -1;
|
||||
} else if (this.overlapArea + 0.02 < scaffoldPathfinderData21.overlapArea) {
|
||||
return 1;
|
||||
} else if (this.horizontalDistanceToPlayerSqr < scaffoldPathfinderData21.horizontalDistanceToPlayerSqr) {
|
||||
return -1;
|
||||
} else {
|
||||
return this.horizontalDistanceToPlayerSqr > scaffoldPathfinderData21.horizontalDistanceToPlayerSqr ? 1 : 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user