From f1c22fce7f80e619c9aabbd2715fbab159524694 Mon Sep 17 00:00:00 2001 From: winterflyt <36+winterflyt@noreply.skidsolutions.xyz> Date: Mon, 30 Nov 2026 06:19:02 +0200 Subject: [PATCH] Upload files to "src/openonyx/utilities" --- src/openonyx/utilities/ItemSpecMode.java | 164 +++++++++++ src/openonyx/utilities/ItemSpecMode2.java | 16 ++ .../utilities/MovementInputState.java | 77 +++++ src/openonyx/utilities/PacketQueue.java | 25 ++ src/openonyx/utilities/PlayerUtils.java | 272 ++++++++++++++++++ 5 files changed, 554 insertions(+) create mode 100644 src/openonyx/utilities/ItemSpecMode.java create mode 100644 src/openonyx/utilities/ItemSpecMode2.java create mode 100644 src/openonyx/utilities/MovementInputState.java create mode 100644 src/openonyx/utilities/PacketQueue.java create mode 100644 src/openonyx/utilities/PlayerUtils.java diff --git a/src/openonyx/utilities/ItemSpecMode.java b/src/openonyx/utilities/ItemSpecMode.java new file mode 100644 index 0000000..48592ea --- /dev/null +++ b/src/openonyx/utilities/ItemSpecMode.java @@ -0,0 +1,164 @@ +package openonyx.utilities; + +import java.util.Iterator; +import java.util.List; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemArmor; +import net.minecraft.item.ItemAxe; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemFood; +import net.minecraft.item.ItemHoe; +import net.minecraft.item.ItemPickaxe; +import net.minecraft.item.ItemPotion; +import net.minecraft.item.ItemShears; +import net.minecraft.item.ItemSpade; +import net.minecraft.item.ItemStack; +import net.minecraft.item.ItemSword; +import net.minecraft.item.ItemTool; +import net.minecraft.potion.Potion; +import net.minecraft.potion.PotionEffect; + +public enum ItemSpecMode { + TOOL("Any tool"), + AXE("Axes"), + FOOD("Food"), + BAD_POTION("Harmful potions"), + SWORD("Swords"), + ARMOR("Armor"), + ANY("Anything"), + BLOCK("Blocks"), + SHOVEL("Shovels"), + HOE("Hoes"), + POTION("Potions"), + PICKAXE("Pickaxes"); + + private final String h; + + private static ItemSpecMode[] L() { + ItemSpecMode[] itemSpecModes = new ItemSpecMode[12]; + boolean bl = true; + itemSpecModes[0] = SWORD; + itemSpecModes[1] = AXE; + itemSpecModes[2] = PICKAXE; + itemSpecModes[3] = SHOVEL; + itemSpecModes[4] = HOE; + itemSpecModes[5] = TOOL; + itemSpecModes[6] = ARMOR; + itemSpecModes[7] = BLOCK; + itemSpecModes[8] = FOOD; + itemSpecModes[9] = POTION; + itemSpecModes[10] = BAD_POTION; + itemSpecModes[11] = ANY; + return itemSpecModes; + } + + public String L() { + return this.h; + } + + public boolean L(Item item) { + switch (this) { + case TOOL: + while (false) { + } + + return item instanceof ItemSword; + case AXE: + return item instanceof ItemAxe; + case FOOD: + return item instanceof ItemPickaxe; + case BAD_POTION: + return item instanceof ItemSpade; + case SWORD: + return item instanceof ItemHoe; + case ARMOR: + if (!(item instanceof ItemTool) && !(item instanceof ItemHoe) && !(item instanceof ItemShears)) { + return false; + } + + return true; + case ANY: + return item instanceof ItemArmor; + case BLOCK: + return item instanceof ItemBlock; + case SHOVEL: + return item instanceof ItemFood; + case HOE: + return item instanceof ItemPotion; + case POTION: + return false; + case PICKAXE: + return true; + default: + throw new MatchException(null, null); + } + } + + public ItemStack L() { + ItemSpecMode itemSpecMode1 = this; + + Item item = switch (itemSpecMode1) { + case TOOL -> { + yield Items.iron_sword; + + while (false) { + } + } + case AXE -> Items.iron_axe; + case FOOD -> Items.iron_pickaxe; + case BAD_POTION -> Items.iron_shovel; + case SWORD -> Items.iron_hoe; + case ARMOR -> Items.iron_pickaxe; + case ANY -> Items.iron_chestplate; + case BLOCK -> Item.getItemFromBlock(Blocks.stone); + case SHOVEL -> Items.bread; + case HOE, POTION -> Items.potionitem; + case PICKAXE -> Items.book; + }; + return item == null ? null : new ItemStack(item); + } + + ItemSpecMode(String string1) { + this.h = string1; + } + + public boolean d(ItemStack itemStack) { + if (itemStack == null || itemStack.getItem() == null) { + return false; + } else { + return this == BAD_POTION ? L(itemStack) : this.L(itemStack.getItem()); + } + } + + private static boolean L(ItemStack itemStack) { + ItemStack itemStack1 = itemStack; + Item item; + if (!((item = itemStack1.getItem()) instanceof ItemPotion)) { + return false; + } + + ItemPotion itemPotion; + List list; + if ((list = (itemPotion = (ItemPotion)item).getEffects(itemStack1)) == null) { + return false; + } + + Iterator iterator = list.iterator(); + + while (iterator.hasNext()) { + int i; + if ((i = ((PotionEffect)iterator.next()).getPotionID()) == Potion.moveSlowdown.id + || i == Potion.blindness.id + || i == Potion.poison.id + || i == Potion.digSlowdown.id + || i == Potion.weakness.id + || i == Potion.harm.id) { + return true; + } + } + + return false; + } +} diff --git a/src/openonyx/utilities/ItemSpecMode2.java b/src/openonyx/utilities/ItemSpecMode2.java new file mode 100644 index 0000000..f2e7223 --- /dev/null +++ b/src/openonyx/utilities/ItemSpecMode2.java @@ -0,0 +1,16 @@ +package openonyx.utilities; + +enum ItemSpecMode2 { + NAME, + GROUP, + ITEM; + + private static ItemSpecMode2[] L() { + ItemSpecMode2[] itemSpecMode2s = new ItemSpecMode2[3]; + boolean bl = true; + itemSpecMode2s[0] = ITEM; + itemSpecMode2s[1] = GROUP; + itemSpecMode2s[2] = NAME; + return itemSpecMode2s; + } +} diff --git a/src/openonyx/utilities/MovementInputState.java b/src/openonyx/utilities/MovementInputState.java new file mode 100644 index 0000000..85a9181 --- /dev/null +++ b/src/openonyx/utilities/MovementInputState.java @@ -0,0 +1,77 @@ +package openonyx.utilities; + +import net.minecraft.util.MovementInput; + +public record MovementInputState(boolean forwards, boolean backwards, boolean left, boolean right) { + public static final MovementInputState INSTANCE = new MovementInputState(true, false, false, true); + public static final MovementInputState INSTANCE2 = new MovementInputState(false, true, false, true); + public static final MovementInputState INSTANCE3 = new MovementInputState(false, false, false, true); + public static final MovementInputState INSTANCE4 = new MovementInputState(false, true, true, false); + public static final MovementInputState INSTANCE5 = new MovementInputState(true, false, false, false); + public static final MovementInputState INSTANCE6 = new MovementInputState(false, true, false, false); + public static final MovementInputState INSTANCE7 = new MovementInputState(true, false, true, false); + public static final MovementInputState INSTANCE8 = new MovementInputState(false, false, false, false); + public static final MovementInputState INSTANCE9 = new MovementInputState(false, false, true, false); + + public float d() { + if (this.forwards == this.backwards) { + return 0.0F; + } else { + return this.forwards ? 1.0F : -1.0F; + } + } + + public MovementInputState(float f, float g) { + boolean bl2; + float h; + if (f > 0.0F) { + bl2 = true; + h = f; + } else { + bl2 = false; + h = f; + } + + boolean bl; + float i; + if (h < 0.0F) { + bl = true; + i = g; + } else { + bl = false; + i = g; + } + + boolean bl1; + float j; + if (i > 0.0F) { + bl1 = true; + j = g; + } else { + bl1 = false; + j = g; + } + + this(bl2, bl, bl1, j < 0.0F); + } + + public float L() { + if (this.left == this.right) { + return 0.0F; + } else { + return this.left ? 1.0F : -1.0F; + } + } + + public MovementInputState L() { + return new MovementInputState(this.backwards, this.forwards, this.right, this.left); + } + + public MovementInputState(MovementInput movementInput) { + this(movementInput.moveForward, movementInput.moveStrafe); + } + + public boolean i() { + return this.forwards != this.backwards || this.left != this.right; + } +} diff --git a/src/openonyx/utilities/PacketQueue.java b/src/openonyx/utilities/PacketQueue.java new file mode 100644 index 0000000..c3e74ae --- /dev/null +++ b/src/openonyx/utilities/PacketQueue.java @@ -0,0 +1,25 @@ +package openonyx.utilities; + +import java.util.ArrayList; +import java.util.List; +import net.minecraft.network.Packet; +import openonyx.core.MinecraftAccess; + +public class PacketQueue implements MinecraftAccess { + private final List packets = new ArrayList<>(); + + public void L() { + if (!this.packets.isEmpty() && mc.getNetHandler() != null) { + mc.getNetHandler().getNetworkManager().sendGrouped(this.packets); + this.packets.clear(); + } + } + + public PacketQueue L(Packet packet) { + if (packet != null) { + this.packets.add(packet); + } + + return this; + } +} diff --git a/src/openonyx/utilities/PlayerUtils.java b/src/openonyx/utilities/PlayerUtils.java new file mode 100644 index 0000000..637016c --- /dev/null +++ b/src/openonyx/utilities/PlayerUtils.java @@ -0,0 +1,272 @@ +package openonyx.utilities; + +import meteordevelopment.orbit.EventHandler; +import net.minecraft.client.entity.EntityPlayerSP; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.MathHelper; +import net.minecraft.util.Vec3; +import openonyx.configuration.internal.PreTickEvent; +import openonyx.configuration.internal.WorldChangeEvent; +import openonyx.core.MinecraftAccess; +import openonyx.movement.SimulatedPlayer; +import openonyx.movement.SimulatedPlayerInput; +import openonyx.protocol.group_m.Angles; + +public class PlayerUtils implements MinecraftAccess { + private static int d; + public static final PlayerUtils INSTANCE = new PlayerUtils(); + private static int f; + public static final float H = 0.6F; + public static final float e = 1.8F; + + public static Vec3 L(Vec3 vec3, double d) { + return L(vec3, dx, 1.0, L(mc.thePlayer)); + } + + public static MovementInputState L(EntityPlayerSP entityPlayerSP) { + return entityPlayerSP != null && entityPlayerSP.movementInput != null + ? new MovementInputState(entityPlayerSP.movementInput.untransformedForward, entityPlayerSP.movementInput.untransformedStrafe) + : MovementInputState.INSTANCE8; + } + + public static float L(float f, MovementInputState movementInputState) { + float g = fx; + float h; + MovementInputState movementInputState1; + if (movementInputState.backwards() && !movementInputState.forwards()) { + g += 180.0F; + h = -0.5F; + movementInputState1 = movementInputState; + } else if (movementInputState.forwards() && !movementInputState.backwards()) { + h = 0.5F; + movementInputState1 = movementInputState; + } else { + h = 1.0F; + movementInputState1 = movementInputState; + } + + if (movementInputState1.left() && !movementInputState.right()) { + g -= 90.0F * h; + } + + if (movementInputState.right() && !movementInputState.left()) { + g += 90.0F * h; + } + + return g; + } + + public static Angles d(Entity entity) { + return new Angles(entity.prevRotationYaw, entity.prevRotationPitch, true); + } + + public static float L(EntityPlayerSP entityPlayerSP, MovementInputState movementInputState) { + return L(entityPlayerSP.rotationYaw, movementInputState); + } + + public static AxisAlignedBB L(Vec3 vec3) { + double dx = 0.3F; + return new AxisAlignedBB(vec3.xCoord - dx, vec3.yCoord, vec3.zCoord - dx, vec3.xCoord + dx, vec3.yCoord + 1.8F, vec3.zCoord + dx); + } + + public static double d(Entity entity, Entity entity1) { + return Math.sqrt(L(entity, entity1)); + } + + public static boolean d(EntityPlayerSP entityPlayerSP) { + return L(entityPlayerSP, L(entityPlayerSP), 0.1, D((Entity)entityPlayerSP)); + } + + public static double L(AxisAlignedBB axisAlignedBB, Vec3 vec3) { + double dx = Math.max(Math.max(axisAlignedBB.minX - vec3.xCoord, vec3.xCoord - axisAlignedBB.maxX), 0.0); + double ex = Math.max(Math.max(axisAlignedBB.minY - vec3.yCoord, vec3.yCoord - axisAlignedBB.maxY), 0.0); + double fx = Math.max(Math.max(axisAlignedBB.minZ - vec3.zCoord, vec3.zCoord - axisAlignedBB.maxZ), 0.0); + return dx * dx + ex * ex + fx * fx; + } + + public static boolean L(EntityPlayer entityPlayer, Vec3 vec3) { + AxisAlignedBB axisAlignedBB = L(vec3).expand(-0.05, 0.0, -0.05).offset(0.0, entityPlayer.fallDistance - entityPlayer.stepHeight, 0.0); + return mc.theWorld.getCollidingBoundingBoxes(entityPlayer, axisAlignedBB).isEmpty(); + } + + public static Vec3 L(Vec3 vec3) { + return L(vec3, Math.sqrt(vec3.xCoord * vec3.xCoord + vec3.zCoord * vec3.zCoord), 1.0, L(mc.thePlayer)); + } + + public static int d(EntityPlayerSP entityPlayerSP) { + return f; + } + + public static boolean L(EntityPlayerSP entityPlayerSP) { + return d(entityPlayerSP) != 0.0F || D(entityPlayerSP) != 0.0F; + } + + public static Vec3 L(Vec3 vec3, double d, double e, MovementInputState movementInputState, float f) { + if (movementInputState != null && !movementInputState.i()) { + return new Vec3(0.0, vec3.yCoord, 0.0); + } + + double g = 1.0 - ex; + double h = vec3.xCoord * g; + g = vec3.zCoord * g; + dx *= ex; + ex = Math.toRadians(fx); + h -= Math.sin(ex) * dx; + dx = g + Math.cos(ex) * dx; + return new Vec3(h, vec3.yCoord, dx); + } + + public static double L(Entity entity, Entity entity1) { + return L((Entity)entity, entity1.getPositionEyes(1.0F)); + } + + public static Vec3 D(Entity entity) { + return new Vec3(entity.posX, entity.posY, entity.posZ); + } + + public static Vec3 L(Vec3 vec3, float f, float g) { + double dx; + if ((dx = vec3.lengthSqr()) < 1.0E-7) { + return Vec3.ZERO; + } + + double ex; + int j = (ex = dx - 1.0) == 0.0 ? 0 : (ex < 0.0 ? -1 : 1); + Vec3 vec32 = vec3; + float i; + if (j > 0) { + vec32 = vec3.normalize(); + i = fx; + } else { + i = fx; + } + + Vec3 vec31 = vec32.scale(i); + float h = MathHelper.sin(g * (float) Math.PI / 180.0F); + g = MathHelper.cos(g * (float) Math.PI / 180.0F); + return new Vec3(vec31.xCoord * g - vec31.zCoord * h, vec31.yCoord, vec31.zCoord * g + vec31.xCoord * h); + } + + public static float D(EntityPlayerSP entityPlayerSP) { + return entityPlayerSP.movementInput == null ? 0.0F : entityPlayerSP.movementInput.moveStrafe; + } + + public static float d(EntityPlayerSP entityPlayerSP) { + return entityPlayerSP.movementInput == null ? 0.0F : entityPlayerSP.movementInput.moveForward; + } + + public static Vec3 d(Entity entity) { + return new Vec3(entity.prevPosX, entity.prevPosY, entity.prevPosZ); + } + + public static Vec3 L(Entity entity) { + return new Vec3(entity.motionX, entity.motionY, entity.motionZ); + } + + public static double L(Entity entity, Vec3 vec3) { + return L(L(entity), vec3); + } + + public static boolean L(EntityPlayerSP entityPlayerSP, MovementInputState movementInputState, double d) { + return L(entityPlayerSP, movementInputState, dx, D((Entity)entityPlayerSP)); + } + + @EventHandler + private void onPreTick(PreTickEvent preTickEvent) { + if (mc.thePlayer == null) { + d = 0; + f = 0; + } else if (mc.thePlayer.onGround) { + d = 0; + f++; + } else { + f = 0; + d++; + } + } + + public static void L(Entity entity, Vec3 vec3) { + entity.motionX = vec3.xCoord; + entity.motionY = vec3.yCoord; + entity.motionZ = vec3.zCoord; + } + + public static int L(EntityPlayerSP entityPlayerSP) { + return d; + } + + public static boolean L(EntityPlayerSP entityPlayerSP, MovementInputState movementInputState, double d, Vec3 vec3) { + EntityPlayerSP entityPlayerSP1 = entityPlayerSP; + SimulatedPlayerInput simulatedPlayerInput; + SimulatedPlayerInput simulatedPlayerInput1 = simulatedPlayerInput = SimulatedPlayerInput.L(movementInputState); + simulatedPlayerInput1.inputFlags = InputFlagUtils.L( + simulatedPlayerInput1.inputFlags, + simulatedPlayerInput.inputFlags.forward(), + simulatedPlayerInput.inputFlags.backward(), + simulatedPlayerInput.inputFlags.left(), + simulatedPlayerInput.inputFlags.right(), + false, + false, + simulatedPlayerInput.inputFlags.sprint() + ); + SimulatedPlayer simulatedPlayer; + SimulatedPlayer simulatedPlayer1 = simulatedPlayer = SimulatedPlayer.L(simulatedPlayerInput); + simulatedPlayer1.i(vec3); + simulatedPlayer1.L(); + Vec3 vec31; + Vec3 vec32; + Vec3 vec34; + if ((vec31 = simulatedPlayer1.getVec32()).horizontalDistanceSqr() > 9.0E-6) { + vec32 = VecUtils.i(vec31, 0.0).normalize(); + vec34 = vec3; + } else { + float fx = L(entityPlayerSP1, movementInputState); + vec32 = Vec3.directionFromRotation(0.0F, fx); + vec34 = vec3; + } + + Vec3 vec35 = vec34.add(0.0, -0.1, 0.0); + if (EdgeCollision.L(vec35, VecUtils.L(vec35, dx, vec32)) != null) { + return true; + } + + Vec3 vec33 = simulatedPlayer.getVec3().add(VecUtils.i(vec31, 0.0)); + return L(entityPlayerSP1, vec3) || L(entityPlayerSP1, vec33); + } + + @EventHandler + private void onWorldChange(WorldChangeEvent worldChangeEvent) { + d = 0; + f = 0; + } + + public static Angles L(Entity entity) { + return new Angles(entity.rotationYaw, entity.rotationPitch, true); + } + + public static boolean L(EntityPlayerSP entityPlayerSP, double d) { + return L(entityPlayerSP, L(entityPlayerSP), dx, D((Entity)entityPlayerSP)); + } + + public static AxisAlignedBB L(Entity entity) { + Entity entity1 = entity; + float fx = entity1.getCollisionBorderSize(); + return entity1.getEntityBoundingBox().expand(fx, fx, fx); + } + + public static float L(EntityPlayerSP entityPlayerSP) { + return L(entityPlayerSP.rotationYaw, L(entityPlayerSP)); + } + + public static Vec3 L(Vec3 vec3, double d, double e, MovementInputState movementInputState) { + Vec3 vec31 = vec3; + MovementInputState movementInputState1 = movementInputState == null ? L(mc.thePlayer) : movementInputState; + return L(vec31, dx, ex, movementInputState1, L(mc.thePlayer, movementInputState1)); + } + + public static double L(Entity entity) { + return Math.sqrt(entity.motionX * entity.motionX + entity.motionZ * entity.motionZ); + } +}