diff --git a/src/openonyx/movement/SimulatedEntity.java b/src/openonyx/movement/SimulatedEntity.java new file mode 100644 index 0000000..06361b9 --- /dev/null +++ b/src/openonyx/movement/SimulatedEntity.java @@ -0,0 +1,9 @@ +package openonyx.movement; + +import net.minecraft.util.Vec3; + +public interface SimulatedEntity { + Vec3 pos(); + + void L(); +} diff --git a/src/openonyx/movement/SimulatedEntityData.java b/src/openonyx/movement/SimulatedEntityData.java new file mode 100644 index 0000000..f4fc1f0 --- /dev/null +++ b/src/openonyx/movement/SimulatedEntityData.java @@ -0,0 +1,9 @@ +package openonyx.movement; + +import net.minecraft.util.Vec3; + +public record SimulatedEntityData(Vec3 pos) implements SimulatedEntity { + @Override + public void L() { + } +} diff --git a/src/openonyx/movement/SimulatedPlayer.java b/src/openonyx/movement/SimulatedPlayer.java new file mode 100644 index 0000000..6efd54f --- /dev/null +++ b/src/openonyx/movement/SimulatedPlayer.java @@ -0,0 +1,753 @@ +package openonyx.movement; + +import java.util.Iterator; +import java.util.List; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.block.state.IBlockState; +import net.minecraft.client.entity.EntityPlayerSP; +import net.minecraft.enchantment.EnchantmentHelper; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.potion.Potion; +import net.minecraft.potion.PotionEffect; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.BlockPos; +import net.minecraft.util.MathHelper; +import net.minecraft.util.Vec3; +import net.minecraft.world.World; +import openonyx.configuration.internal.SimulatedMoveEvent; +import openonyx.core.MinecraftAccess; +import openonyx.core.OnyxClient; +import openonyx.utilities.PlayerUtils; +import openonyx.utilities.VecUtils; + +public class SimulatedPlayer implements SimulatedEntity, MinecraftAccess { + private Vec3 vec3; + private boolean c; + private double a; + private static final double k = 1.0; + private float g; + private Vec3 vec32; + private int L; + private boolean j; + private boolean m; + private int h; + private final EntityPlayer entityPlayer; + private float I; + private boolean d; + private boolean i; + private SimulatedPlayerInput simulatedPlayerInput; + private boolean H; + private AxisAlignedBB axisAlignedBB; + + private boolean H() { + return this.L().isMaterialInBB(this.axisAlignedBB.expand(-0.1F, -0.4F, -0.1F), Material.lava); + } + + private void i() { + this.a = 0.0; + } + + public boolean e() { + return this.c; + } + + public static SimulatedPlayer L(SimulatedPlayerInput simulatedPlayerInput) { + return L(mc.thePlayer, simulatedPlayerInputx, PlayerUtils.L((Entity)mc.thePlayer)); + } + + public boolean k() { + return this.m; + } + + public void L(SimulatedPlayerInput simulatedPlayerInput) { + this.simulatedPlayerInput = simulatedPlayerInputx; + } + + private boolean F() { + SimulatedPlayer simulatedPlayer1 = this; + Block block; + return ( + block = simulatedPlayer1.L( + new BlockPos( + MathHelper.floor_double(simulatedPlayer1.vec3.xCoord), + MathHelper.floor_double(simulatedPlayer1.axisAlignedBB.minY), + MathHelper.floor_double(simulatedPlayer1.vec3.zCoord) + ) + ) + .getBlock() + ) + == Blocks.ladder + || block == Blocks.vine; + } + + public void i(Vec3 vec3) { + this.vec3 = vec3x; + this.axisAlignedBB = PlayerUtils.L(vec3x); + } + + public float i() { + return this.g; + } + + public SimulatedPlayerInput getSimulatedPlayerInput() { + return this.simulatedPlayerInput; + } + + public void I(boolean bl) { + this.j = bl; + } + + public int d() { + return this.L; + } + + private IBlockState L(BlockPos blockPos) { + return this.L().getBlockState(blockPos); + } + + private boolean L(AxisAlignedBB axisAlignedBB) { + return this.L().getCollidingBoundingBoxes(this.entityPlayer, axisAlignedBBx).isEmpty(); + } + + public boolean l() { + return this.i; + } + + public SimulatedPlayer L() { + return new SimulatedPlayer( + this.entityPlayer, + this.simulatedPlayerInput, + this.vec3, + this.vec32, + this.axisAlignedBB, + this.I, + this.g, + this.d, + this.a, + this.L, + this.j, + this.m, + this.i, + this.c + ); + } + + private float D() { + SimulatedPlayer simulatedPlayer1 = this; + float f = 0.02F; + return simulatedPlayer1.simulatedPlayerInput.L() ? (float)(f + f * 0.3) : f; + } + + public void D(Vec3 vec3) { + this.vec32 = vec3x; + } + + private Vec3 D(Vec3 vec3) { + if (!this.F()) { + return vec3x; + } + + this.i(); + double dx = MathHelper.clamp_double(vec3x.xCoord, -0.15F, 0.15F); + double e = MathHelper.clamp_double(vec3x.zCoord, -0.15F, 0.15F); + double f; + if ((f = Math.max(vec3x.yCoord, -0.15F)) < 0.0 && this.simulatedPlayerInput.inputFlags.shift()) { + f = 0.0; + } + + return new Vec3(dx, f, e); + } + + public void d(int i) { + this.h = ix; + } + + public void i(boolean bl) { + this.m = bl; + } + + public Vec3 getVec32() { + return this.vec32; + } + + private float d() { + return this.entityPlayer.getAIMoveSpeed(); + } + + private static SimulatedPlayer L(EntityPlayer entityPlayer, SimulatedPlayerInput simulatedPlayerInput, Vec3 vec3) { + SimulatedPlayer simulatedPlayer = new SimulatedPlayer; + Vec3 vec31 = PlayerUtils.D(entityPlayerx); + AxisAlignedBB axisAlignedBBx = entityPlayerx.getEntityBoundingBox(); + float f = entityPlayerx.rotationYaw; + float gx = entityPlayerx.rotationPitch; + boolean bl = entityPlayerx.isSprinting(); + double dx = entityPlayerx.fallDistance; + EntityPlayerSP entityPlayerSP; + boolean bl1; + EntityPlayer entityPlayer1; + if (entityPlayerx instanceof EntityPlayerSP + && (entityPlayerSP = (EntityPlayerSP)entityPlayerx).movementInput != null + && entityPlayerSP.movementInput.jump) { + bl1 = true; + entityPlayer1 = entityPlayerx; + } else { + bl1 = false; + entityPlayer1 = entityPlayerx; + } + + simulatedPlayer./* $VF: Unable to resugar constructor */( + entityPlayerx, + simulatedPlayerInputx, + vec31, + vec3x, + axisAlignedBBx, + f, + gx, + bl, + dx, + 0, + bl1, + entityPlayer1.onGround, + entityPlayerx.isCollidedHorizontally, + entityPlayerx.isCollidedVertically + ); + return simulatedPlayer; + } + + private boolean h() { + return this.L().isMaterialInBB(this.axisAlignedBB.expand(0.0, -0.4F, 0.0).contract(0.001, 0.001, 0.001), Material.water); + } + + public void L(double d) { + this.a = dx; + } + + public boolean I() { + return this.j; + } + + public float L() { + return this.I; + } + + public int L() { + return this.h; + } + + private void L(float f, Vec3 vec3) { + this.vec32 = this.vec32.add(PlayerUtils.L(vec3x, f, this.I)); + } + + private IBlockState L() { + return this.L( + new BlockPos( + MathHelper.floor_double(this.vec3.xCoord), MathHelper.floor_double(this.axisAlignedBB.minY) - 1, MathHelper.floor_double(this.vec3.zCoord) + ) + ); + } + + public void D() { + SimulatedPlayer simulatedPlayer1 = this; + simulatedPlayer1.vec32 = VecUtils.i(simulatedPlayer1.vec32, 0.42F); + PotionEffect potionEffect; + if ((potionEffect = simulatedPlayer1.entityPlayer.getActivePotionEffect(Potion.jump)) != null) { + simulatedPlayer1.vec32 = simulatedPlayer1.vec32.add(0.0, (potionEffect.getAmplifier() + 1) * 0.1F, 0.0); + } + + if (simulatedPlayer1.d) { + float f = simulatedPlayer1.I * (float) (Math.PI / 180.0); + simulatedPlayer1.vec32 = simulatedPlayer1.vec32.add(-MathHelper.sin(f) * 0.2F, 0.0, MathHelper.cos(f) * 0.2F); + } + } + + private void d(Vec3 vec3) { + SimulatedMoveEvent simulatedMoveEvent = new SimulatedMoveEvent(vec3x); + OnyxClient.EVENT_BUS.post(simulatedMoveEvent); + vec3x = simulatedMoveEvent.getVec3(); + if (this.D()) { + vec3x = vec3x.multiply(0.25, 0.05F, 0.25); + this.vec32 = Vec3.ZERO; + } + + Vec3 vec31; + if ((vec31 = this.d(vec3x = this.L(vec3x))).lengthSqr() > 1.0E-7) { + this.vec3 = this.vec3.add(vec31); + this.axisAlignedBB = PlayerUtils.L(this.vec3); + } + + boolean bl1 = vec3x.xCoord != vec31.xCoord; + boolean bl = vec3x.zCoord != vec31.zCoord; + this.i = bl1 || bl; + this.c = vec3x.yCoord != vec31.yCoord; + this.m = this.c && vec3x.yCoord < 0.0; + SimulatedPlayer simulatedPlayer1; + if (this.m) { + simulatedPlayer1 = this; + this.i(); + } else { + if (vec31.yCoord < 0.0) { + this.a = this.a - vec31.yCoord; + } + + simulatedPlayer1 = this; + } + + vec3x = simulatedPlayer1.vec32; + if (this.i || this.c) { + Vec3 vec32x = new Vec3; + double e; + SimulatedPlayer simulatedPlayer2; + if (bl1) { + e = 0.0; + simulatedPlayer2 = this; + } else { + e = vec3x.xCoord; + simulatedPlayer2 = this; + } + + double dx; + boolean bl2; + if (simulatedPlayer2.m) { + dx = 0.0; + bl2 = bl; + } else { + dx = vec3x.yCoord; + bl2 = bl; + } + + vec32x./* $VF: Unable to resugar constructor */(e, dx, bl2 ? 0.0 : vec3x.zCoord); + this.vec32 = vec32x; + } + } + + public void d() { + this.D(); + } + + public void L(AxisAlignedBB axisAlignedBB) { + this.axisAlignedBB = axisAlignedBBx; + } + + private Vec3 d(Vec3 vec3) { + SimulatedPlayer simulatedPlayer1 = this; + double dx = vec3x.xCoord; + double e = vec3x.yCoord; + double f = vec3x.zCoord; + double gx = dx; + double hx = f; + AxisAlignedBB axisAlignedBBx = simulatedPlayer1.axisAlignedBB; + AxisAlignedBB axisAlignedBB1 = simulatedPlayer1.axisAlignedBB; + List list; + Iterator iterator3; + Iterator iterator13 = iterator3 = (list = simulatedPlayer1.L() + .getCollidingBoundingBoxes(simulatedPlayer1.entityPlayer, axisAlignedBB1.addCoord(dx, e, f))) + .iterator(); + + while (iterator13.hasNext()) { + AxisAlignedBB axisAlignedBB2 = (AxisAlignedBB)iterator3.next(); + iterator13 = iterator3; + e = axisAlignedBB2.calculateYOffset(axisAlignedBB1, e); + } + + axisAlignedBB1 = axisAlignedBB1.offset(0.0, e, 0.0); + boolean bl = simulatedPlayer1.m || vec3x.yCoord != e && vec3x.yCoord < 0.0; + Iterator iterator8; + iterator13 = iterator8 = list.iterator(); + + while (iterator13.hasNext()) { + AxisAlignedBB axisAlignedBB3 = (AxisAlignedBB)iterator8.next(); + iterator13 = iterator8; + dx = axisAlignedBB3.calculateXOffset(axisAlignedBB1, dx); + } + + axisAlignedBB1 = axisAlignedBB1.offset(dx, 0.0, 0.0); + iterator13 = iterator8 = list.iterator(); + + while (iterator13.hasNext()) { + AxisAlignedBB axisAlignedBB16 = (AxisAlignedBB)iterator8.next(); + iterator13 = iterator8; + f = axisAlignedBB16.calculateZOffset(axisAlignedBB1, f); + } + + axisAlignedBB1 = axisAlignedBB1.offset(0.0, 0.0, f); + float l = simulatedPlayer1.entityPlayer.stepHeight; + if (simulatedPlayer1.entityPlayer.stepHeight > 0.0F && bl && (gx != dx || hx != f)) { + double mx = dx; + double ix = e; + double jx = f; + e = l; + List list1 = simulatedPlayer1.L().getCollidingBoundingBoxes(simulatedPlayer1.entityPlayer, axisAlignedBBx.addCoord(gx, e, hx)); + AxisAlignedBB axisAlignedBB10 = axisAlignedBBx; + AxisAlignedBB axisAlignedBB5 = axisAlignedBBx.addCoord(gx, 0.0, hx); + double kx = e; + + Iterator iterator; + for (Iterator iterator9 = iterator = list1.iterator(); iterator9.hasNext(); iterator9 = iterator) { + kx = ((AxisAlignedBB)iterator.next()).calculateYOffset(axisAlignedBB5, kx); + } + + AxisAlignedBB axisAlignedBB11 = axisAlignedBB10.offset(0.0, kx, 0.0); + double n = gx; + + Iterator iterator1; + for (Iterator iterator10 = iterator1 = list1.iterator(); iterator10.hasNext(); iterator10 = iterator1) { + n = ((AxisAlignedBB)iterator1.next()).calculateXOffset(axisAlignedBB11, n); + } + + AxisAlignedBB axisAlignedBB12 = axisAlignedBB11.offset(n, 0.0, 0.0); + double o = hx; + Iterator iterator4; + iterator13 = iterator4 = list1.iterator(); + + while (iterator13.hasNext()) { + AxisAlignedBB axisAlignedBB4 = (AxisAlignedBB)iterator4.next(); + iterator13 = iterator4; + o = axisAlignedBB4.calculateZOffset(axisAlignedBB12, o); + } + + AxisAlignedBB axisAlignedBB13 = axisAlignedBB12.offset(0.0, 0.0, o); + AxisAlignedBB axisAlignedBB6 = axisAlignedBBx; + double p = e; + + Iterator iterator2; + for (Iterator iterator11 = iterator2 = list1.iterator(); iterator11.hasNext(); iterator11 = iterator2) { + p = ((AxisAlignedBB)iterator2.next()).calculateYOffset(axisAlignedBB6, p); + } + + AxisAlignedBB axisAlignedBB7 = axisAlignedBB6.offset(0.0, p, 0.0); + double q = gx; + + for (Iterator iterator12 = iterator5 = list1.iterator(); iterator12.hasNext(); iterator12 = iterator5) { + q = ((AxisAlignedBB)iterator5.next()).calculateXOffset(axisAlignedBB7, q); + } + + AxisAlignedBB axisAlignedBB8 = axisAlignedBB7.offset(q, 0.0, 0.0); + gx = hx; + Iterator iterator6; + iterator13 = iterator6 = list1.iterator(); + + while (iterator13.hasNext()) { + AxisAlignedBB axisAlignedBB14 = (AxisAlignedBB)iterator6.next(); + iterator13 = iterator6; + gx = axisAlignedBB14.calculateZOffset(axisAlignedBB8, gx); + } + + AxisAlignedBB axisAlignedBB9 = axisAlignedBB8.offset(0.0, 0.0, gx); + List list2; + if (n * n + o * o > q * q + gx * gx) { + dx = n; + f = o; + e = -kx; + axisAlignedBB1 = axisAlignedBB13; + list2 = list1; + } else { + dx = q; + f = gx; + e = -p; + axisAlignedBB1 = axisAlignedBB9; + list2 = list1; + } + + Iterator iterator7; + iterator13 = iterator7 = list2.iterator(); + + while (iterator13.hasNext()) { + AxisAlignedBB axisAlignedBB15 = (AxisAlignedBB)iterator7.next(); + iterator13 = iterator7; + e = axisAlignedBB15.calculateYOffset(axisAlignedBB1, e); + } + + if (mx * mx + jx * jx >= dx * dx + f * f) { + dx = mx; + e = ix; + f = jx; + } + } + + return new Vec3(dx, e, f); + } + + public void D(boolean bl) { + this.i = bl; + } + + public static SimulatedPlayer L(EntityPlayer entityPlayer, SimulatedPlayerInput simulatedPlayerInput) { + return L(entityPlayerx, simulatedPlayerInputx, PlayerUtils.D(entityPlayerx).subtract(PlayerUtils.d(entityPlayerx))); + } + + @Override + public Vec3 pos() { + return this.vec3; + } + + private void L(Vec3 vec3) { + SimulatedPlayer simulatedPlayer1 = this; + boolean bl = simulatedPlayer1.entityPlayer.capabilities.isFlying; + double dx = simulatedPlayer1.vec32.yCoord; + if (simulatedPlayer1.h() && !bl) { + double l = simulatedPlayer1.vec3.yCoord; + float jx = 0.8F; + float mx = 0.02F; + float hx; + if ((hx = EnchantmentHelper.getDepthStriderModifier(simulatedPlayer1.entityPlayer)) > 3.0F) { + hx = 3.0F; + } + + if (!simulatedPlayer1.m) { + hx *= 0.5F; + } + + if (hx > 0.0F) { + jx += (0.54600006F - jx) * hx / 3.0F; + mx += (simulatedPlayer1.d() * 1.0F - mx) * hx / 3.0F; + } + + simulatedPlayer1.L(mx, vec3x); + simulatedPlayer1.d(simulatedPlayer1.vec32); + simulatedPlayer1.vec32 = simulatedPlayer1.vec32.multiply(jx, 0.8F, jx).add(0.0, -0.02, 0.0); + if (simulatedPlayer1.i + && simulatedPlayer1.L( + simulatedPlayer1.vec32.xCoord, simulatedPlayer1.vec32.yCoord + 0.6F - simulatedPlayer1.vec3.yCoord + l, simulatedPlayer1.vec32.zCoord + )) { + simulatedPlayer1.vec32 = VecUtils.i(simulatedPlayer1.vec32, 0.3F); + return; + } + } else if (simulatedPlayer1.H() && !bl) { + double kx = simulatedPlayer1.vec3.yCoord; + simulatedPlayer1.L(0.02F, vec3x); + simulatedPlayer1.d(simulatedPlayer1.vec32); + simulatedPlayer1.vec32 = simulatedPlayer1.vec32.scale(0.5).add(0.0, -0.02, 0.0); + if (simulatedPlayer1.i + && simulatedPlayer1.L( + simulatedPlayer1.vec32.xCoord, simulatedPlayer1.vec32.yCoord + 0.6F - simulatedPlayer1.vec3.yCoord + kx, simulatedPlayer1.vec32.zCoord + )) { + simulatedPlayer1.vec32 = VecUtils.i(simulatedPlayer1.vec32, 0.3F); + return; + } + } else { + float f = 0.91F; + if (simulatedPlayer1.m) { + f = simulatedPlayer1.L().getBlock().slipperiness * 0.91F; + } + + float gx = 0.16277136F / (f * f * f); + float ix = simulatedPlayer1.m ? simulatedPlayer1.d() * gx : simulatedPlayer1.D(); + simulatedPlayer1.L(ix, vec3x); + simulatedPlayer1.vec32 = simulatedPlayer1.D(simulatedPlayer1.vec32); + simulatedPlayer1.d(simulatedPlayer1.vec32); + if (simulatedPlayer1.i && simulatedPlayer1.F()) { + simulatedPlayer1.vec32 = VecUtils.i(simulatedPlayer1.vec32, 0.2); + } + + double e = bl ? dx * 0.6 : (simulatedPlayer1.vec32.yCoord - 0.08) * 0.98F; + simulatedPlayer1.vec32 = new Vec3(simulatedPlayer1.vec32.xCoord * f, e, simulatedPlayer1.vec32.zCoord * f); + if (bl) { + simulatedPlayer1.i(); + } + } + } + + public AxisAlignedBB getAxisAlignedBB() { + return this.axisAlignedBB; + } + + public Vec3 getVec3() { + return this.vec3; + } + + public EntityPlayer getEntityPlayer() { + return this.entityPlayer; + } + + private boolean L(double d, double e, double f) { + AxisAlignedBB axisAlignedBBx; + return this.L(axisAlignedBBx = this.axisAlignedBB.offset(dx, e, f)) && !this.L().isAnyLiquid(axisAlignedBBx); + } + + public void d(boolean bl) { + this.d = bl; + } + + public boolean i() { + return this.d; + } + + private Vec3 L(Vec3 vec3) { + if (this.m && !(vec3x.yCoord > 0.0)) { + double dx = vec3x.xCoord; + double e = vec3x.zCoord; + double f = 0.05; + double gx = dx; + + while (gx != 0.0 && this.L(this.axisAlignedBB.offset(dx, -1.0, 0.0))) { + gx = dx < f && dx >= -f ? (dx = 0.0) : (dx > 0.0 ? (dx -= f) : (dx += f)); + } + + gx = e; + + while (gx != 0.0 && this.L(this.axisAlignedBB.offset(0.0, -1.0, e))) { + gx = e < f && e >= -f ? (e = 0.0) : (e > 0.0 ? (e -= f) : (e += f)); + } + + gx = dx; + + while (gx != 0.0 && e != 0.0 && this.L(this.axisAlignedBB.offset(dx, -1.0, e))) { + if (dx < f && dx >= -f) { + dx = 0.0; + gx = e; + } else if (dx > 0.0) { + dx -= f; + gx = e; + } else { + dx += f; + gx = e; + } + + if (gx < f && e >= -f) { + e = 0.0; + gx = dx; + } else if (e > 0.0) { + e -= f; + gx = dx; + } else { + e += f; + gx = dx; + } + } + + if (vec3x.xCoord != dx || vec3x.zCoord != e) { + this.H = true; + } + + return !this.L() ? vec3x : new Vec3(dx, vec3x.yCoord, e); + } else { + return vec3x; + } + } + + public void L(boolean bl) { + this.c = bl; + } + + public SimulatedPlayer( + EntityPlayer entityPlayer, + SimulatedPlayerInput simulatedPlayerInput, + Vec3 vec3, + Vec3 vec31, + AxisAlignedBB axisAlignedBB, + float f, + float g, + boolean bl, + double d, + int i, + boolean bl1, + boolean bl2, + boolean bl3, + boolean bl4 + ) { + this.entityPlayer = entityPlayerx; + this.simulatedPlayerInput = simulatedPlayerInputx; + this.vec3 = vec3x; + this.vec32 = vec31; + this.axisAlignedBB = axisAlignedBBx; + this.I = f; + this.g = gx; + this.d = bl; + this.a = dx; + this.L = ix; + this.j = bl1; + this.m = bl2; + this.i = bl3; + this.c = bl4; + } + + @Override + public void L() { + this.H = false; + if (!(this.vec3.yCoord <= -70.0)) { + this.simulatedPlayerInput.L(); + if (this.L > 0) { + this.L--; + } + + this.j = this.simulatedPlayerInput.inputFlags.jump(); + double dx = this.vec32.xCoord; + double e = this.vec32.yCoord; + double f = this.vec32.zCoord; + if (Math.abs(dx) < 0.005) { + dx = 0.0; + } + + if (Math.abs(e) < 0.005) { + e = 0.0; + } + + if (Math.abs(f) < 0.005) { + f = 0.0; + } + + SimulatedPlayer simulatedPlayer1; + label36: { + this.vec32 = new Vec3(dx, e, f); + if (this.j) { + if (this.h() || this.H()) { + simulatedPlayer1 = this; + this.vec32 = this.vec32.add(0.0, 0.04F, 0.0); + break label36; + } + + if (this.m && this.L == 0) { + simulatedPlayer1 = this; + this.D(); + this.L = 10; + break label36; + } + } else { + this.L = 0; + } + + simulatedPlayer1 = this; + } + + dx = simulatedPlayer1.simulatedPlayerInput.D() * 0.98; + e = this.simulatedPlayerInput.d() * 0.98; + this.L(new Vec3(dx, 0.0, e)); + this.h++; + } + } + + public double L() { + return this.a; + } + + public void L(int i) { + this.L = ix; + } + + private boolean D() { + return this.L(VecUtils.L(this.vec3)).getBlock() == Blocks.web; + } + + public void d(float f) { + this.I = f; + } + + public boolean d() { + return this.H; + } + + private boolean L() { + return !this.simulatedPlayerInput.D() && (this.simulatedPlayerInput.inputFlags.shift() || this.simulatedPlayerInput.d()); + } + + private World L() { + return this.entityPlayer.worldObj; + } + + public void L(float f) { + this.g = f; + } +} diff --git a/src/openonyx/movement/SimulatedPlayerInput.java b/src/openonyx/movement/SimulatedPlayerInput.java new file mode 100644 index 0000000..42a901a --- /dev/null +++ b/src/openonyx/movement/SimulatedPlayerInput.java @@ -0,0 +1,183 @@ +package openonyx.movement; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.MathHelper; +import net.minecraft.util.Vec3; +import openonyx.configuration.internal.SafeWalkEvent; +import openonyx.core.MinecraftAccess; +import openonyx.core.OnyxClient; +import openonyx.utilities.EdgeCollision; +import openonyx.utilities.InputFlags; +import openonyx.utilities.MovementInputState; +import openonyx.utilities.PlayerUtils; + +public class SimulatedPlayerInput implements MinecraftAccess { + private float h; + private boolean l; + private static final double I = 0.121; + private float d; + private boolean i; + private boolean f; + private final MovementInputState movementInputState; + public InputFlags inputFlags; + + public boolean D() { + return this.i; + } + + public void D(boolean bl) { + this.f = bl; + } + + @Override + public String toString() { + return new StringBuilder() + .insert(0, "SimulatedPlayerInput(forwards={") + .append(this.inputFlags.forward()) + .append("}, backwards={") + .append(this.inputFlags.backward()) + .append("}, left={") + .append(this.inputFlags.left()) + .append("}, right={") + .append(this.inputFlags.right()) + .append("}, jumping={") + .append(this.inputFlags.jump()) + .append("}, sprinting=") + .append(this.l) + .append(", slowDown=") + .append(this.inputFlags.shift()) + .append(")") + .toString(); + } + + public float i() { + return this.h; + } + + public boolean d() { + return this.f; + } + + public boolean L() { + return this.l; + } + + public InputFlags getInputFlags() { + return this.inputFlags; + } + + public float D() { + return this.h; + } + + public SimulatedPlayerInput(MovementInputState movementInputState, boolean bl, boolean bl1, boolean bl2) { + this(movementInputStatex, bl, bl1, bl2, false); + } + + public MovementInputState getMovementInputState() { + return this.movementInputState; + } + + public static SimulatedPlayerInput L(MovementInputState movementInputState, boolean bl, boolean bl1, boolean bl2) { + SimulatedPlayerInput simulatedPlayerInput = new SimulatedPlayerInput(movementInputStatex, bl, bl1, bl2); + SafeWalkEvent safeWalkEvent = new SafeWalkEvent(); + OnyxClient.EVENT_BUS.post(safeWalkEvent); + if (safeWalkEvent.d()) { + simulatedPlayerInput.f = true; + } + + return simulatedPlayerInput; + } + + public void d(boolean bl) { + this.i = bl; + } + + public float d() { + return this.d; + } + + public SimulatedPlayerInput(MovementInputState movementInputState, boolean bl, boolean bl1, boolean bl2, boolean bl3) { + this.movementInputState = movementInputStatex; + this.l = bl1; + this.i = bl3; + this.inputFlags = new InputFlags( + movementInputStatex.forwards(), movementInputStatex.backwards(), movementInputStatex.left(), movementInputStatex.right(), bl, bl2, bl1 + ); + } + + public float L() { + return this.d; + } + + public void L(boolean bl) { + this.l = bl; + } + + public static SimulatedPlayerInput L(MovementInputState movementInputState) { + return L( + movementInputStatex, mc.thePlayer.movementInput != null && mc.thePlayer.movementInput.jump, mc.thePlayer.isSprinting(), mc.thePlayer.isSneaking() + ); + } + + public static SimulatedPlayerInput L(EntityPlayer entityPlayer) { + EntityPlayer entityPlayer1 = entityPlayer; + double dx; + Vec3 vec3; + boolean bl = (dx = (vec3 = PlayerUtils.D(entityPlayer1).subtract(PlayerUtils.d(entityPlayer1))).horizontalDistanceSqr()) >= 0.014641; + MovementInputState movementInputStatex; + if (dx > 0.0025000000000000005) { + float fx = EdgeCollision.L(vec3, entityPlayer1.rotationYaw); + movementInputStatex = EdgeCollision.L(MovementInputState.INSTANCE8, MathHelper.wrapAngleTo180_float(fx)); + } else { + movementInputStatex = MovementInputState.INSTANCE8; + } + + SimulatedPlayerInput simulatedPlayerInput = new SimulatedPlayerInput; + boolean bl1; + boolean bl2; + if (!entityPlayer1.onGround) { + bl1 = true; + bl2 = bl; + } else { + bl1 = false; + bl2 = bl; + } + + simulatedPlayerInput./* $VF: Unable to resugar constructor */(movementInputStatex, bl1, bl2, entityPlayer1.isSneaking()); + return simulatedPlayerInput; + } + + public void L() { + SimulatedPlayerInput simulatedPlayerInput1 = this; + float fx; + SimulatedPlayerInput simulatedPlayerInput2; + if (simulatedPlayerInput1.inputFlags.forward() != simulatedPlayerInput1.inputFlags.backward()) { + fx = simulatedPlayerInput1.inputFlags.forward() ? 1.0F : -1.0F; + simulatedPlayerInput2 = simulatedPlayerInput1; + } else { + fx = 0.0F; + simulatedPlayerInput2 = simulatedPlayerInput1; + } + + float g; + if (simulatedPlayerInput2.inputFlags.left() == simulatedPlayerInput1.inputFlags.right()) { + g = 0.0F; + simulatedPlayerInput2 = simulatedPlayerInput1; + } else if (simulatedPlayerInput1.inputFlags.left()) { + g = 1.0F; + simulatedPlayerInput2 = simulatedPlayerInput1; + } else { + g = -1.0F; + simulatedPlayerInput2 = simulatedPlayerInput1; + } + + if (simulatedPlayerInput2.inputFlags.shift()) { + g = (float)(g * 0.3); + fx = (float)(fx * 0.3); + } + + simulatedPlayerInput1.h = g; + simulatedPlayerInput1.d = fx; + } +} diff --git a/src/openonyx/movement/SimulatedTickState.java b/src/openonyx/movement/SimulatedTickState.java new file mode 100644 index 0000000..c393e8e --- /dev/null +++ b/src/openonyx/movement/SimulatedTickState.java @@ -0,0 +1,41 @@ +package openonyx.movement; + +import net.minecraft.util.Vec3; + +public record SimulatedTickState(Vec3 pos, double fallDistance, Vec3 velocity, boolean onGround, boolean clipLedged) { + public static String decrypt(String string) { + String string1 = string; + int l = --3 << --3 ^ 2; + int m = 112 ^ 1 << 1; + String string2; + int o = (string2 = string1).length(); + char[] d = new char[o]; + boolean bl = true; + int j; + int n = j = o - 1; + char[] c = d; + byte b = 14; + l = n; + int i = m; + + while (l >= 0) { + m = j; + int k = string2.charAt(j); + j--; + c[m] = (char)(k ^ i); + if (j < 0) { + break; + } + + k = j--; + c[k] = (char)(string2.charAt(k) ^ b); + l = j; + } + + return new String(c); + } + + public SimulatedTickState(SimulatedPlayer simulatedPlayer) { + this(simulatedPlayer.getVec3(), simulatedPlayer.L(), simulatedPlayer.getVec32(), simulatedPlayer.k(), simulatedPlayer.d()); + } +}