From 3b96da078d3d4d71df8af89605cf548cb6cf096a Mon Sep 17 00:00:00 2001 From: thoq Date: Wed, 8 Apr 2026 08:56:02 -0400 Subject: [PATCH 1/4] add nuker --- src/main/java/dev/thoq/Alya.java | 1 + .../dev/thoq/lua/api/LuaMinecraftApi.java | 171 ++++++++++++++---- .../client/renderer/EntityRenderer.java | 40 ++-- src/main/resources/lua/alya.d.lua | 9 + .../resources/lua/modules/player/nuker.lua | 117 ++++++++++++ 5 files changed, 287 insertions(+), 51 deletions(-) create mode 100644 src/main/resources/lua/modules/player/nuker.lua diff --git a/src/main/java/dev/thoq/Alya.java b/src/main/java/dev/thoq/Alya.java index fb5e8c9c..c18104a4 100644 --- a/src/main/java/dev/thoq/Alya.java +++ b/src/main/java/dev/thoq/Alya.java @@ -101,6 +101,7 @@ public String[] initializeModules() { new Script(Category.COMBAT, "reach"), new Script(Category.COMBAT, "targetstrafe"), new Script(Category.PLAYER, "scaffold"), + new Script(Category.PLAYER, "nuker"), new Script(Category.PLAYER, "timer"), new Script(Category.EXPLOIT, "disabler"), new Script(Category.OTHER, "hackerdetector"), diff --git a/src/main/java/dev/thoq/lua/api/LuaMinecraftApi.java b/src/main/java/dev/thoq/lua/api/LuaMinecraftApi.java index ca0384e7..0ef81b5f 100644 --- a/src/main/java/dev/thoq/lua/api/LuaMinecraftApi.java +++ b/src/main/java/dev/thoq/lua/api/LuaMinecraftApi.java @@ -8,6 +8,7 @@ import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; import net.minecraft.network.Packet; +import net.minecraft.network.play.client.C07PacketPlayerDigging; import net.minecraft.util.*; import org.jspecify.annotations.NonNull; import org.luaj.vm2.LuaTable; @@ -36,12 +37,16 @@ public static void registerEvents(dev.thoq.event.EventBus eventBus) { eventBus.subscribe( ReachEvent.class, event -> { - if(reachOverride > 0) event.setReachDistance(reachOverride); + if(reachOverride > 0) { + event.setReachDistance(reachOverride); + } }); eventBus.subscribe( HitboxEvent.class, event -> { - if(hitboxExpansion >= 0) event.setExpansion(hitboxExpansion); + if(hitboxExpansion >= 0) { + event.setExpansion(hitboxExpansion); + } }); eventBus.subscribe( PacketSendEvent.class, @@ -135,7 +140,9 @@ public LuaValue call(LuaValue speedValue) { new ZeroArgFunction() { @Override public LuaValue call() { - if(minecraft.theWorld == null) return LuaValue.valueOf(0L); + if(minecraft.theWorld == null) { + return LuaValue.valueOf(0L); + } return LuaValue.valueOf((double) minecraft.theWorld.getWorldTime()); } }); @@ -144,8 +151,9 @@ public LuaValue call() { new OneArgFunction() { @Override public LuaValue call(LuaValue timeValue) { - if(minecraft.theWorld != null) + if(minecraft.theWorld != null) { minecraft.theWorld.setWorldTime((long) timeValue.todouble()); + } return LuaValue.NIL; } }); @@ -193,7 +201,9 @@ public LuaValue call(LuaValue v) { new OneArgFunction() { @Override public LuaValue call(LuaValue v) { - if(minecraft.thePlayer == null) return LuaValue.NIL; + if(minecraft.thePlayer == null) { + return LuaValue.NIL; + } minecraft.thePlayer.setPosition( minecraft.thePlayer.posX, v.todouble(), @@ -236,7 +246,9 @@ public LuaValue call() { new OneArgFunction() { @Override public LuaValue call(LuaValue motionValue) { - if(minecraft.thePlayer != null) minecraft.thePlayer.motionX = motionValue.todouble(); + if(minecraft.thePlayer != null) { + minecraft.thePlayer.motionX = motionValue.todouble(); + } return LuaValue.NIL; } }); @@ -245,7 +257,9 @@ public LuaValue call(LuaValue motionValue) { new OneArgFunction() { @Override public LuaValue call(LuaValue motionValue) { - if(minecraft.thePlayer != null) minecraft.thePlayer.motionY = motionValue.todouble(); + if(minecraft.thePlayer != null) { + minecraft.thePlayer.motionY = motionValue.todouble(); + } return LuaValue.NIL; } }); @@ -254,7 +268,9 @@ public LuaValue call(LuaValue motionValue) { new OneArgFunction() { @Override public LuaValue call(LuaValue motionValue) { - if(minecraft.thePlayer != null) minecraft.thePlayer.motionZ = motionValue.todouble(); + if(minecraft.thePlayer != null) { + minecraft.thePlayer.motionZ = motionValue.todouble(); + } return LuaValue.NIL; } }); @@ -281,7 +297,9 @@ public LuaValue call() { new OneArgFunction() { @Override public LuaValue call(LuaValue ticksValue) { - if(minecraft.thePlayer != null) minecraft.thePlayer.jumpTicks = ticksValue.toint(); + if(minecraft.thePlayer != null) { + minecraft.thePlayer.jumpTicks = ticksValue.toint(); + } return LuaValue.NIL; } }); @@ -290,7 +308,9 @@ public LuaValue call(LuaValue ticksValue) { new ZeroArgFunction() { @Override public LuaValue call() { - if(minecraft.thePlayer != null) minecraft.thePlayer.jump(); + if(minecraft.thePlayer != null) { + minecraft.thePlayer.jump(); + } return LuaValue.NIL; } }); @@ -299,8 +319,9 @@ public LuaValue call() { new OneArgFunction() { @Override public LuaValue call(LuaValue sprintingValue) { - if(minecraft.thePlayer != null) + if(minecraft.thePlayer != null) { minecraft.thePlayer.setSprinting(sprintingValue.toboolean()); + } return LuaValue.NIL; } }); @@ -377,8 +398,9 @@ public LuaValue call() { new OneArgFunction() { @Override public LuaValue call(LuaValue yawValue) { - if(minecraft.getRenderViewEntity() != null) + if(minecraft.getRenderViewEntity() != null) { minecraft.getRenderViewEntity().rotationYaw = (float) yawValue.todouble(); + } return LuaValue.NIL; } }); @@ -443,8 +465,9 @@ public LuaValue call() { new OneArgFunction() { @Override public LuaValue call(LuaValue fallDistance) { - if(minecraft.thePlayer != null) + if(minecraft.thePlayer != null) { minecraft.thePlayer.fallDistance = fallDistance.tofloat(); + } return LuaValue.NIL; } }); @@ -482,7 +505,9 @@ public LuaValue call(LuaValue v) { new ZeroArgFunction() { @Override public LuaValue call() { - if(minecraft.thePlayer == null) return LuaValue.valueOf(0); + if(minecraft.thePlayer == null) { + return LuaValue.valueOf(0); + } return LuaValue.valueOf(minecraft.thePlayer.rotationYaw); } }); @@ -491,7 +516,9 @@ public LuaValue call() { new ZeroArgFunction() { @Override public LuaValue call() { - if(minecraft.thePlayer == null) return LuaValue.valueOf(0); + if(minecraft.thePlayer == null) { + return LuaValue.valueOf(0); + } return LuaValue.valueOf(minecraft.thePlayer.rotationPitch); } }); @@ -500,7 +527,9 @@ public LuaValue call() { new ZeroArgFunction() { @Override public LuaValue call() { - if(minecraft.thePlayer == null || minecraft.thePlayer.movementInput == null) return LuaValue.valueOf(0); + if(minecraft.thePlayer == null || minecraft.thePlayer.movementInput == null) { + return LuaValue.valueOf(0); + } return LuaValue.valueOf(minecraft.thePlayer.movementInput.moveForward); } }); @@ -509,7 +538,9 @@ public LuaValue call() { new ZeroArgFunction() { @Override public LuaValue call() { - if(minecraft.thePlayer == null || minecraft.thePlayer.movementInput == null) return LuaValue.valueOf(0); + if(minecraft.thePlayer == null || minecraft.thePlayer.movementInput == null) { + return LuaValue.valueOf(0); + } return LuaValue.valueOf(minecraft.thePlayer.movementInput.moveStrafe); } }); @@ -518,7 +549,9 @@ public LuaValue call() { new OneArgFunction() { @Override public LuaValue call(LuaValue v) { - if(minecraft.thePlayer == null || minecraft.thePlayer.movementInput == null) return LuaValue.NIL; + if(minecraft.thePlayer == null || minecraft.thePlayer.movementInput == null) { + return LuaValue.NIL; + } minecraft.thePlayer.movementInput.moveForward = (float) v.todouble(); return LuaValue.NIL; } @@ -528,7 +561,9 @@ public LuaValue call(LuaValue v) { new OneArgFunction() { @Override public LuaValue call(LuaValue v) { - if(minecraft.thePlayer == null || minecraft.thePlayer.movementInput == null) return LuaValue.NIL; + if(minecraft.thePlayer == null || minecraft.thePlayer.movementInput == null) { + return LuaValue.NIL; + } minecraft.thePlayer.movementInput.moveStrafe = (float) v.todouble(); return LuaValue.NIL; } @@ -538,7 +573,9 @@ public LuaValue call(LuaValue v) { new ZeroArgFunction() { @Override public LuaValue call() { - if(minecraft.thePlayer == null || minecraft.theWorld == null) return LuaValue.FALSE; + if(minecraft.thePlayer == null || minecraft.theWorld == null) { + return LuaValue.FALSE; + } java.util.List boxes = minecraft.theWorld.getCollidingBoundingBoxes( minecraft.thePlayer, @@ -582,7 +619,9 @@ public LuaValue call() { new ZeroArgFunction() { @Override public LuaValue call() { - if(minecraft.thePlayer == null) return LuaValue.FALSE; + if(minecraft.thePlayer == null) { + return LuaValue.FALSE; + } ItemStack held = minecraft.thePlayer.getHeldItem(); return LuaValue.valueOf(held != null && held.getItem() instanceof ItemBlock); } @@ -592,7 +631,9 @@ public LuaValue call() { new OneArgFunction() { @Override public LuaValue call(LuaValue v) { - if(minecraft.thePlayer != null) minecraft.thePlayer.stepHeight = (float) v.todouble(); + if(minecraft.thePlayer != null) { + minecraft.thePlayer.stepHeight = (float) v.todouble(); + } return LuaValue.NIL; } }); @@ -601,7 +642,9 @@ public LuaValue call(LuaValue v) { new ZeroArgFunction() { @Override public LuaValue call() { - if(minecraft.thePlayer != null) minecraft.thePlayer.stepHeight = 0.5f; + if(minecraft.thePlayer != null) { + minecraft.thePlayer.stepHeight = 0.5f; + } return LuaValue.NIL; } }); @@ -650,7 +693,9 @@ public LuaValue call() { new ZeroArgFunction() { @Override public LuaValue call() { - if(minecraft.thePlayer == null || minecraft.theWorld == null) return LuaValue.FALSE; + if(minecraft.thePlayer == null || minecraft.theWorld == null) { + return LuaValue.FALSE; + } BlockPos pos = new BlockPos( minecraft.thePlayer.posX, @@ -673,7 +718,9 @@ public LuaValue call() { new ZeroArgFunction() { @Override public LuaValue call() { - if(minecraft.currentScreen == null) return LuaValue.valueOf("none"); + if(minecraft.currentScreen == null) { + return LuaValue.valueOf("none"); + } return LuaValue.valueOf(minecraft.currentScreen.getClass().getSimpleName()); } }); @@ -735,7 +782,9 @@ public LuaValue call() { new ZeroArgFunction() { @Override public LuaValue call() { - if(minecraft.thePlayer == null || minecraft.theWorld == null) return LuaValue.FALSE; + if(minecraft.thePlayer == null || minecraft.theWorld == null) { + return LuaValue.FALSE; + } double x = minecraft.thePlayer.posX; double z = minecraft.thePlayer.posZ; double blockX = Math.floor(x); @@ -756,8 +805,12 @@ public LuaValue call() { new ZeroArgFunction() { @Override public LuaValue call() { - if(minecraft.thePlayer == null) return LuaValue.valueOf(-1); - for(int slotIndex = 0; slotIndex < 9; slotIndex++) { + if(minecraft.thePlayer == null) { + return LuaValue.valueOf(-1); + } + for(int slotIndex = 0; + slotIndex < 9; + slotIndex++) { ItemStack itemStack = minecraft.thePlayer.inventory.getStackInSlot(slotIndex); if(itemStack != null && itemStack.getItem() instanceof ItemBlock) { return LuaValue.valueOf(slotIndex); @@ -771,7 +824,9 @@ public LuaValue call() { new ZeroArgFunction() { @Override public LuaValue call() { - if(minecraft.thePlayer == null) return LuaValue.valueOf(-1); + if(minecraft.thePlayer == null) { + return LuaValue.valueOf(-1); + } return LuaValue.valueOf(minecraft.thePlayer.inventory.currentItem); } }); @@ -887,8 +942,12 @@ public org.luaj.vm2.Varargs invoke(org.luaj.vm2.Varargs arguments) { new ZeroArgFunction() { @Override public LuaValue call() { - if(minecraft.thePlayer == null || minecraft.theWorld == null) return LuaValue.FALSE; - if(!minecraft.thePlayer.onGround) return LuaValue.FALSE; + if(minecraft.thePlayer == null || minecraft.theWorld == null) { + return LuaValue.FALSE; + } + if(!minecraft.thePlayer.onGround) { + return LuaValue.FALSE; + } BlockPos icePos = new BlockPos( minecraft.thePlayer.posX, minecraft.thePlayer.getEntityBoundingBox().minY - 0.1, @@ -967,5 +1026,55 @@ public LuaValue call(LuaValue messageValue) { return LuaValue.NIL; } }); + set( + "breakBlock", + new org.luaj.vm2.lib.VarArgFunction() { + @Override + public org.luaj.vm2.Varargs invoke(org.luaj.vm2.Varargs arguments) { + if(minecraft.thePlayer == null || minecraft.theWorld == null) { + return LuaValue.FALSE; + } + final int action = arguments.checkint(1); + final int x = arguments.checkint(2); + final int y = arguments.checkint(3); + final int z = arguments.checkint(4); + final int faceIndex = arguments.optint(5, 1); + final BlockPos pos = new BlockPos(x, y, z); + final EnumFacing facing; + switch(faceIndex) { + case 0: + facing = EnumFacing.DOWN; + break; + case 1: + facing = EnumFacing.UP; + break; + case 2: + facing = EnumFacing.NORTH; + break; + case 3: + facing = EnumFacing.SOUTH; + break; + case 4: + facing = EnumFacing.WEST; + break; + case 5: + facing = EnumFacing.EAST; + break; + default: + facing = EnumFacing.UP; + break; + } + final C07PacketPlayerDigging.Action digAction; + if(action == 0) { + digAction = C07PacketPlayerDigging.Action.START_DESTROY_BLOCK; + } else if(action == 1) { + digAction = C07PacketPlayerDigging.Action.STOP_DESTROY_BLOCK; + } else { + digAction = C07PacketPlayerDigging.Action.ABORT_DESTROY_BLOCK; + } + minecraft.getNetHandler().addToSendQueue(new C07PacketPlayerDigging(digAction, pos, facing)); + return LuaValue.TRUE; + } + }); } } diff --git a/src/main/java/net/minecraft/client/renderer/EntityRenderer.java b/src/main/java/net/minecraft/client/renderer/EntityRenderer.java index e70330b6..955276c8 100644 --- a/src/main/java/net/minecraft/client/renderer/EntityRenderer.java +++ b/src/main/java/net/minecraft/client/renderer/EntityRenderer.java @@ -2241,28 +2241,28 @@ private void frameFinish() { } private void updateMainMenu(GuiMainMenu p_updateMainMenu_1_) { + //noinspection CommentedOutCode try { String s = null; - Calendar calendar = Calendar.getInstance(); - calendar.setTime(new Date()); - int i = calendar.get(5); - int j = calendar.get(2) + 1; - - if(i == 8 && j == 4) { - s = "Happy birthday, OptiFine!"; - } - - if(i == 14 && j == 8) { - s = "Happy birthday, sp614x!"; - } - - if(s == null) { - return; - } - - Reflector.setFieldValue(p_updateMainMenu_1_, Reflector.GuiMainMenu_splashText, s); - } catch(Throwable var6) { - ; +// Calendar calendar = Calendar.getInstance(); +// calendar.setTime(new Date()); +// int i = calendar.get(5); +// int j = calendar.get(2) + 1; +// +// if(i == 8 && j == 4) { +// s = "Happy birthday, OptiFine!"; +// } +// +// if(i == 14 && j == 8) { +// s = "Happy birthday, sp614x!"; +// } +// +// if(s == null) { +// return; +// } +// +// Reflector.setFieldValue(p_updateMainMenu_1_, Reflector.GuiMainMenu_splashText, s); + } catch(Throwable _) { } } diff --git a/src/main/resources/lua/alya.d.lua b/src/main/resources/lua/alya.d.lua index d0636e13..fe5be296 100644 --- a/src/main/resources/lua/alya.d.lua +++ b/src/main/resources/lua/alya.d.lua @@ -447,6 +447,15 @@ function AlyaMC.resetHitboxExpansion() end ---@param message string function AlyaMC.sendChatMessage(message) end +---breaks a block using the specified action and position +---@param action integer 0 = START_DESTROY_BLOCK, 1 = STOP_DESTROY_BLOCK, 2 = ABORT_DESTROY_BLOCK +---@param x integer block x +---@param y integer block y +---@param z integer block z +---@param facing? integer block face (0=down, 1=up, 2=north, 3=south, 4=west, 5=east) +---@return boolean success +function AlyaMC.breakBlock(action, x, y, z, facing) end + ---@class AlyaFontRenderer ---@field drawString fun(text: string, x: number, y: number, color: integer) ---@field drawStringWithShadow fun(text: string, x: number, y: number, color: integer) diff --git a/src/main/resources/lua/modules/player/nuker.lua b/src/main/resources/lua/modules/player/nuker.lua new file mode 100644 index 00000000..47ffa212 --- /dev/null +++ b/src/main/resources/lua/modules/player/nuker.lua @@ -0,0 +1,117 @@ +local moduleTable = alya.modules.register("Nuker", "Break blocks around you", "PLAYER") + +local range = moduleTable.addNumberSetting("Range", "Maximum distance to break blocks", 6, 1, 10, 0.5) +local delay = moduleTable.addNumberSetting("Delay", "Delay between break attempts (ms)", 50, 0, 500, 10) +local verticalMode = moduleTable.addModeSetting("Vertical", "Vertical range mode", "Both", "Down", "Up", "Both") +local horizontalMode = moduleTable.addModeSetting("Horizontal", "Horizontal range mode", "Circle", "Circle", "Square") +local nukeIt = moduleTable.addBooleanSetting("NukeIt", "Break all blocks at once", false) +local ignoreAir = moduleTable.addBooleanSetting("IgnoreAir", "Skip air blocks in calculation", true) + +local timer = alya.timer.create() +local currentTarget = nil + +local function isBlockValid(x, y, z) + if alya.mc.isPlayerNull() or alya.mc.isWorldNull() then return false end + + if ignoreAir.isEnabled() and alya.mc.isBlockAir(x, y, z) then + return false + end + + return true +end + +local function getBlocksInRange() + local blocks = {} + local playerX = alya.mc.getPlayerX() + local playerY = alya.mc.getPlayerY() + local playerZ = alya.mc.getPlayerZ() + local rangeVal = range.getValue() + local vert = verticalMode.getValue() + local horiz = horizontalMode.getValue() + + local minY, maxY + if vert == "Down" then + minY = math.floor(playerY) - 1 + maxY = math.floor(playerY) + elseif vert == "Up" then + minY = math.floor(playerY) + maxY = math.floor(playerY) + 1 + else + minY = math.floor(playerY) - 1 + maxY = math.floor(playerY) + 1 + end + + for x = math.floor(playerX) - rangeVal, math.floor(playerX) + rangeVal do + for z = math.floor(playerZ) - rangeVal, math.floor(playerZ) + rangeVal do + for y = minY, maxY do + local dx = x - math.floor(playerX) + local dz = z - math.floor(playerZ) + + local inRange + if horiz == "Circle" then + inRange = math.sqrt(dx * dx + dz * dz) <= rangeVal + else + inRange = true + end + + if inRange and isBlockValid(x, y, z) then + local dist = math.sqrt( + (x - playerX) * (x - playerX) + + (y - playerY) * (y - playerY) + + (z - playerZ) * (z - playerZ) + ) + table.insert(blocks, { x = x, y = y, z = z, dist = dist }) + end + end + end + end + + table.sort(blocks, function(a, b) return a.dist < b.dist end) + return blocks +end + +local function breakBlock(x, y, z) + alya.mc.breakBlock(0, x, y, z, 1) + alya.mc.breakBlock(1, x, y, z, 1) +end + +moduleTable.onEnable(function() + timer.reset() + currentTarget = nil +end) + +moduleTable.onDisable(function() + currentTarget = nil +end) + +alya.events.on("tick", function(event) + if not moduleTable.isEnabled() then return end + if alya.mc.isPlayerNull() or alya.mc.isWorldNull() then return end + + if not timer.hasElapsed(delay.getValueAsInt()) then + return + end + timer.reset() + + local blocks = getBlocksInRange() + + if #blocks == 0 then + currentTarget = nil + return + end + + if nukeIt.isEnabled() then + for _, block in ipairs(blocks) do + alya.mc.breakBlock(0, block.x, block.y, block.z, 1) + alya.mc.breakBlock(1, block.x, block.y, block.z, 1) + end + else + local target = blocks[1] + if not currentTarget or currentTarget.x ~= target.x or currentTarget.y ~= target.y or currentTarget.z ~= target.z then + alya.mc.breakBlock(0, target.x, target.y, target.z, 1) + currentTarget = target + else + alya.mc.breakBlock(1, target.x, target.y, target.z, 1) + end + end +end) From 3b493a62bebd3cf9920b9a6c8688bb688fe37910 Mon Sep 17 00:00:00 2001 From: thoq Date: Wed, 8 Apr 2026 09:19:25 -0400 Subject: [PATCH 2/4] new arraylist, add fucker module --- src/main/java/dev/thoq/Alya.java | 1 + src/main/java/dev/thoq/lua/LuaEngine.java | 24 +- .../java/dev/thoq/lua/api/LuaCombatApi.java | 283 ++++++++++++------ .../dev/thoq/lua/api/LuaMinecraftApi.java | 81 +++-- src/main/resources/lua/alya.d.lua | 25 ++ .../resources/lua/modules/player/fucker.lua | 271 +++++++++++++++++ .../lua/modules/visual/arraylist.lua | 28 +- 7 files changed, 588 insertions(+), 125 deletions(-) create mode 100644 src/main/resources/lua/modules/player/fucker.lua diff --git a/src/main/java/dev/thoq/Alya.java b/src/main/java/dev/thoq/Alya.java index c18104a4..c2bb3ed2 100644 --- a/src/main/java/dev/thoq/Alya.java +++ b/src/main/java/dev/thoq/Alya.java @@ -102,6 +102,7 @@ public String[] initializeModules() { new Script(Category.COMBAT, "targetstrafe"), new Script(Category.PLAYER, "scaffold"), new Script(Category.PLAYER, "nuker"), + new Script(Category.PLAYER, "fucker"), new Script(Category.PLAYER, "timer"), new Script(Category.EXPLOIT, "disabler"), new Script(Category.OTHER, "hackerdetector"), diff --git a/src/main/java/dev/thoq/lua/LuaEngine.java b/src/main/java/dev/thoq/lua/LuaEngine.java index 35225568..fa2f36e1 100644 --- a/src/main/java/dev/thoq/lua/LuaEngine.java +++ b/src/main/java/dev/thoq/lua/LuaEngine.java @@ -1,6 +1,7 @@ package dev.thoq.lua; import dev.thoq.Alya; +import dev.thoq.gui.UIConstants; import dev.thoq.gui.toast.Toast; import dev.thoq.gui.toast.ToastManager; import dev.thoq.lua.api.*; @@ -70,6 +71,14 @@ public LuaValue call() { return LuaValue.valueOf(Alya.getVersion()); } }); + alyaTable.set( + "getAccent", + new ZeroArgFunction() { + @Override + public LuaValue call() { + return LuaValue.valueOf(UIConstants.ACCENT_COLOR); + } + }); globals.set("alya", alyaTable); globals.set( "loadScript", @@ -95,7 +104,8 @@ public LuaValue call(LuaValue resourcePathValue) { } final LuaValue chunk = globals.load(new InputStreamReader(inputStream), resourcePath); return chunk.call(); - } catch(final LuaError | FileNotFoundException luaError) { + } catch(final LuaError | + FileNotFoundException luaError) { Alya.getInstance() .getLogger() .error("Lua error loading {}: {}", resourcePath, luaError.getMessage()); @@ -132,6 +142,12 @@ public LuaValue call(LuaValue resourcePathValue) { } } }); + globals.set("getAccent", new ZeroArgFunction() { + @Override + public LuaValue call() { + return LuaValue.valueOf(UIConstants.ACCENT_COLOR); + } + }); } public void loadScript(final String resourcePath) { @@ -167,7 +183,7 @@ public void loadScript(final String resourcePath) { } private String[] getAlyaScriptCore() { - return new String[] { + return new String[]{ "util/movement.lua", "util/chat.lua", "util/visual.lua", @@ -201,7 +217,9 @@ public void loadExternalScripts() { return; } final File[] luaFiles = scriptsDir.listFiles((dir, name) -> name.endsWith(".lua")); - if(luaFiles == null) return; + if(luaFiles == null) { + return; + } for(final File luaFile : luaFiles) { if(loadedExternalScripts.contains(luaFile.getName())) { loadExternalScript(luaFile); diff --git a/src/main/java/dev/thoq/lua/api/LuaCombatApi.java b/src/main/java/dev/thoq/lua/api/LuaCombatApi.java index cd777cc6..a19ea6ef 100644 --- a/src/main/java/dev/thoq/lua/api/LuaCombatApi.java +++ b/src/main/java/dev/thoq/lua/api/LuaCombatApi.java @@ -52,23 +52,36 @@ public LuaValue call() { "getPlayers", new VarArgFunction() { @Override - public Varargs invoke(Varargs args) { - if(mc.theWorld == null || mc.thePlayer == null) return LuaValue.NIL; - double reach = args.narg() >= 1 ? args.checkdouble(1) : 6.0; - boolean raycastOnly = args.narg() >= 2 && args.checkboolean(2); - List players = new ArrayList<>(); - for(Object obj : mc.theWorld.getLoadedEntityList()) { - if(!(obj instanceof EntityPlayer)) continue; - EntityPlayer ep = (EntityPlayer) obj; - if(ep == mc.thePlayer) continue; - if(ep.isInvisible()) continue; - if(mc.thePlayer.getDistanceToEntity(ep) > reach) continue; - if(raycastOnly && !mc.thePlayer.canEntityBeSeen(ep)) continue; - players.add(ep); + public Varargs invoke(final Varargs args) { + if(mc.theWorld == null || mc.thePlayer == null) { + return LuaValue.NIL; + } + final double reach = args.narg() >= 1 ? args.checkdouble(1) : 6.0; + final boolean raycastOnly = args.narg() >= 2 && args.checkboolean(2); + final List players = new ArrayList<>(); + for(final Object object : mc.theWorld.getLoadedEntityList()) { + if(!(object instanceof final EntityPlayer entityPlayer)) { + continue; + } + if(entityPlayer == mc.thePlayer) { + continue; + } + if(entityPlayer.isInvisible()) { + continue; + } + if(mc.thePlayer.getDistanceToEntity(entityPlayer) > reach) { + continue; + } + if(raycastOnly && !mc.thePlayer.canEntityBeSeen(entityPlayer)) { + continue; + } + players.add(entityPlayer); } players.sort(Comparator.comparingDouble(e -> mc.thePlayer.getDistanceToEntity(e))); LuaTable result = new LuaTable(); - for(int i = 0; i < players.size(); i++) { + for(int i = 0; + i < players.size(); + i++) { result.set(i + 1, entityToTable(players.get(i))); } return result; @@ -79,13 +92,18 @@ public Varargs invoke(Varargs args) { new ZeroArgFunction() { @Override public LuaValue call() { - if(mc.theWorld == null || mc.thePlayer == null) return new LuaTable(); + if(mc.theWorld == null || mc.thePlayer == null) { + return new LuaTable(); + } LuaTable result = new LuaTable(); int i = 1; for(Object obj : mc.theWorld.getLoadedEntityList()) { - if(!(obj instanceof EntityPlayer)) continue; - EntityPlayer ep = (EntityPlayer) obj; - if(ep == mc.thePlayer) continue; + if(!(obj instanceof EntityPlayer ep)) { + continue; + } + if(ep == mc.thePlayer) { + continue; + } LuaTable t = new LuaTable(); t.set("id", LuaValue.valueOf(ep.getEntityId())); t.set("name", LuaValue.valueOf(ep.getName())); @@ -95,10 +113,10 @@ public LuaValue call() { t.set("lastX", LuaValue.valueOf(ep.lastTickPosX)); t.set("lastY", LuaValue.valueOf(ep.lastTickPosY)); t.set("lastZ", LuaValue.valueOf(ep.lastTickPosZ)); - t.set("width", LuaValue.valueOf((double) ep.width)); - t.set("height", LuaValue.valueOf((double) ep.height)); - t.set("health", LuaValue.valueOf((double) ep.getHealth())); - t.set("maxHealth", LuaValue.valueOf((double) ep.getMaxHealth())); + t.set("width", LuaValue.valueOf(ep.width)); + t.set("height", LuaValue.valueOf(ep.height)); + t.set("health", LuaValue.valueOf(ep.getHealth())); + t.set("maxHealth", LuaValue.valueOf(ep.getMaxHealth())); t.set("hurtTime", LuaValue.valueOf(ep.hurtTime)); t.set("isInvisible", LuaValue.valueOf(ep.isInvisible())); result.set(i++, t); @@ -111,32 +129,53 @@ public LuaValue call() { new VarArgFunction() { @Override public Varargs invoke(Varargs args) { - if(mc.theWorld == null || mc.thePlayer == null) return new LuaTable(); - double reach = args.narg() >= 1 ? args.checkdouble(1) : 6.0; - boolean raycastOnly = args.narg() >= 2 && args.checkboolean(2); - boolean players = args.narg() < 3 || args.checkboolean(3); - boolean hostile = args.narg() < 4 || args.checkboolean(4); - boolean passive = args.narg() < 5 || args.checkboolean(5); - List targets = new ArrayList<>(); - for(Object obj : mc.theWorld.getLoadedEntityList()) { - if(!(obj instanceof EntityLivingBase)) continue; - EntityLivingBase e = (EntityLivingBase) obj; - if(e == mc.thePlayer) continue; - if(e.isInvisible()) continue; - if(mc.thePlayer.getDistanceToEntity(e) > reach) continue; - if(raycastOnly && !mc.thePlayer.canEntityBeSeen(e)) continue; - boolean isPlayer = e instanceof EntityPlayer; - boolean isHostile = e instanceof IMob; - boolean isPassive = e instanceof IAnimals && !isHostile; - if(isPlayer && !players) continue; - if(isHostile && !hostile) continue; - if(isPassive && !passive) continue; - if(!isPlayer && !isHostile && !isPassive) continue; - targets.add(e); + if(mc.theWorld == null || mc.thePlayer == null) { + return new LuaTable(); + } + final double reach = args.narg() >= 1 ? args.checkdouble(1) : 6.0; + final boolean raycastOnly = args.narg() >= 2 && args.checkboolean(2); + final boolean players = args.narg() < 3 || args.checkboolean(3); + final boolean hostile = args.narg() < 4 || args.checkboolean(4); + final boolean passive = args.narg() < 5 || args.checkboolean(5); + final List targets = new ArrayList<>(); + for(Object object : mc.theWorld.getLoadedEntityList()) { + if(!(object instanceof final EntityLivingBase entityLivingBase)) { + continue; + } + if(entityLivingBase == mc.thePlayer) { + continue; + } + if(entityLivingBase.isInvisible()) { + continue; + } + if(mc.thePlayer.getDistanceToEntity(entityLivingBase) > reach) { + continue; + } + if(raycastOnly && !mc.thePlayer.canEntityBeSeen(entityLivingBase)) { + continue; + } + boolean isPlayer = entityLivingBase instanceof EntityPlayer; + boolean isHostile = entityLivingBase instanceof IMob; + boolean isPassive = entityLivingBase instanceof IAnimals && !isHostile; + if(isPlayer && !players) { + continue; + } + if(isHostile && !hostile) { + continue; + } + if(isPassive && !passive) { + continue; + } + if(!isPlayer && !isHostile && !isPassive) { + continue; + } + targets.add(entityLivingBase); } targets.sort(Comparator.comparingDouble(e -> mc.thePlayer.getDistanceToEntity(e))); LuaTable result = new LuaTable(); - for(int i = 0; i < targets.size(); i++) { + for(int i = 0; + i < targets.size(); + i++) { result.set(i + 1, livingToTable(targets.get(i))); } return result; @@ -147,7 +186,9 @@ public Varargs invoke(Varargs args) { new VarArgFunction() { @Override public Varargs invoke(Varargs args) { - if(mc.thePlayer == null) return LuaValue.NIL; + if(mc.thePlayer == null) { + return LuaValue.NIL; + } LuaTable entityTable = args.checktable(1); double ex = entityTable.get("x").todouble(); double ey = entityTable.get("y").todouble(); @@ -160,8 +201,8 @@ public Varargs invoke(Varargs args) { float yaw = (float) Math.toDegrees(Math.atan2(dz, dx)) - 90.0f; float pitch = (float) -Math.toDegrees(Math.atan2(dy, dist)); LuaTable rot = new LuaTable(); - rot.set("yaw", LuaValue.valueOf((double) yaw)); - rot.set("pitch", LuaValue.valueOf((double) pitch)); + rot.set("yaw", LuaValue.valueOf(yaw)); + rot.set("pitch", LuaValue.valueOf(pitch)); return rot; } }); @@ -171,7 +212,7 @@ public Varargs invoke(Varargs args) { @Override public LuaValue call() { float sens = mc.gameSettings.mouseSensitivity * 0.6f + 0.2f; - return LuaValue.valueOf((double) (sens * sens * sens * 8.0f)); + return LuaValue.valueOf(sens * sens * sens * 8.0f); } }); set( @@ -179,10 +220,14 @@ public LuaValue call() { new OneArgFunction() { @Override public LuaValue call(LuaValue entityIdValue) { - if(mc.theWorld == null || mc.thePlayer == null) return LuaValue.NIL; + if(mc.theWorld == null || mc.thePlayer == null) { + return LuaValue.NIL; + } int id = entityIdValue.toint(); Entity entity = mc.theWorld.getEntityByID(id); - if(entity == null) return LuaValue.FALSE; + if(entity == null) { + return LuaValue.FALSE; + } mc.thePlayer.swingItem(); mc.getNetHandler() .addToSendQueue(new C02PacketUseEntity(entity, C02PacketUseEntity.Action.ATTACK)); @@ -194,7 +239,9 @@ public LuaValue call(LuaValue entityIdValue) { new ZeroArgFunction() { @Override public LuaValue call() { - if(mc.thePlayer != null) mc.thePlayer.swingItem(); + if(mc.thePlayer != null) { + mc.thePlayer.swingItem(); + } return LuaValue.NIL; } }); @@ -203,9 +250,13 @@ public LuaValue call() { new OneArgFunction() { @Override public LuaValue call(LuaValue entityIdValue) { - if(mc.theWorld == null || mc.thePlayer == null) return LuaValue.NIL; + if(mc.theWorld == null || mc.thePlayer == null) { + return LuaValue.NIL; + } Entity entity = mc.theWorld.getEntityByID(entityIdValue.toint()); - if(entity instanceof EntityLivingBase) mc.thePlayer.onEnchantmentCritical(entity); + if(entity instanceof EntityLivingBase) { + mc.thePlayer.onEnchantmentCritical(entity); + } return LuaValue.NIL; } }); @@ -214,9 +265,13 @@ public LuaValue call(LuaValue entityIdValue) { new OneArgFunction() { @Override public LuaValue call(LuaValue entityIdValue) { - if(mc.theWorld == null || mc.thePlayer == null) return LuaValue.NIL; + if(mc.theWorld == null || mc.thePlayer == null) { + return LuaValue.NIL; + } Entity entity = mc.theWorld.getEntityByID(entityIdValue.toint()); - if(entity instanceof EntityLivingBase) mc.thePlayer.onCriticalHit(entity); + if(entity instanceof EntityLivingBase) { + mc.thePlayer.onCriticalHit(entity); + } return LuaValue.NIL; } }); @@ -225,7 +280,9 @@ public LuaValue call(LuaValue entityIdValue) { new ZeroArgFunction() { @Override public LuaValue call() { - if(mc.thePlayer == null) return LuaValue.NIL; + if(mc.thePlayer == null) { + return LuaValue.NIL; + } mc.getNetHandler() .addToSendQueue( new C08PacketPlayerBlockPlacement( @@ -238,7 +295,9 @@ public LuaValue call() { new ZeroArgFunction() { @Override public LuaValue call() { - if(mc.thePlayer == null) return LuaValue.NIL; + if(mc.thePlayer == null) { + return LuaValue.NIL; + } mc.getNetHandler() .addToSendQueue( new C07PacketPlayerDigging( @@ -253,7 +312,9 @@ public LuaValue call() { new ZeroArgFunction() { @Override public LuaValue call() { - if(mc.thePlayer == null) return LuaValue.FALSE; + if(mc.thePlayer == null) { + return LuaValue.FALSE; + } return LuaValue.valueOf( mc.thePlayer.getHeldItem() != null && mc.thePlayer.getHeldItem().getItem() instanceof ItemSword); @@ -282,9 +343,13 @@ public LuaValue call() { new OneArgFunction() { @Override public LuaValue call(LuaValue entityIdValue) { - if(mc.theWorld == null || mc.thePlayer == null) return LuaValue.FALSE; + if(mc.theWorld == null || mc.thePlayer == null) { + return LuaValue.FALSE; + } Entity entity = mc.theWorld.getEntityByID(entityIdValue.toint()); - if(entity == null) return LuaValue.FALSE; + if(entity == null) { + return LuaValue.FALSE; + } return LuaValue.valueOf(mc.thePlayer.canEntityBeSeen(entity)); } }); @@ -332,7 +397,9 @@ public LuaValue call() { new VarArgFunction() { @Override public Varargs invoke(Varargs args) { - if(mc.thePlayer == null) return LuaValue.NIL; + if(mc.thePlayer == null) { + return LuaValue.NIL; + } double x = mc.thePlayer.posX; double y = mc.thePlayer.posY; double z = mc.thePlayer.posZ; @@ -349,7 +416,9 @@ public Varargs invoke(Varargs args) { new ZeroArgFunction() { @Override public LuaValue call() { - if(mc.thePlayer == null) return LuaValue.NIL; + if(mc.thePlayer == null) { + return LuaValue.NIL; + } mc.leftClickCounter = 0; mc.clickMouse(); return LuaValue.NIL; @@ -360,7 +429,9 @@ public LuaValue call() { new ZeroArgFunction() { @Override public LuaValue call() { - if(mc.thePlayer == null) return LuaValue.NIL; + if(mc.thePlayer == null) { + return LuaValue.NIL; + } try { java.lang.reflect.Method m = net.minecraft.client.Minecraft.class.getDeclaredMethod("rightClickMouse"); @@ -393,7 +464,7 @@ public LuaValue call() { @Override public LuaValue call() { return mc.thePlayer != null - ? LuaValue.valueOf((double) mc.thePlayer.rotationYaw) + ? LuaValue.valueOf(mc.thePlayer.rotationYaw) : LuaValue.valueOf(0d); } }); @@ -403,7 +474,7 @@ public LuaValue call() { @Override public LuaValue call() { return mc.thePlayer != null - ? LuaValue.valueOf((double) mc.thePlayer.rotationPitch) + ? LuaValue.valueOf(mc.thePlayer.rotationPitch) : LuaValue.valueOf(0d); } }); @@ -412,7 +483,9 @@ public LuaValue call() { new OneArgFunction() { @Override public LuaValue call(LuaValue v) { - if(mc.thePlayer != null) mc.thePlayer.rotationPitch = (float) v.todouble(); + if(mc.thePlayer != null) { + mc.thePlayer.rotationPitch = (float) v.todouble(); + } return LuaValue.NIL; } }); @@ -421,7 +494,9 @@ public LuaValue call(LuaValue v) { new OneArgFunction() { @Override public LuaValue call(LuaValue v) { - if(mc.thePlayer != null) mc.thePlayer.rotationYaw = (float) v.todouble(); + if(mc.thePlayer != null) { + mc.thePlayer.rotationYaw = (float) v.todouble(); + } return LuaValue.NIL; } }); @@ -430,7 +505,9 @@ public LuaValue call(LuaValue v) { new OneArgFunction() { @Override public LuaValue call(LuaValue v) { - if(mc.thePlayer != null) mc.thePlayer.cameraPitch = (float) v.todouble(); + if(mc.thePlayer != null) { + mc.thePlayer.cameraPitch = (float) v.todouble(); + } return LuaValue.NIL; } }); @@ -439,7 +516,9 @@ public LuaValue call(LuaValue v) { new OneArgFunction() { @Override public LuaValue call(LuaValue v) { - if(mc.thePlayer != null) mc.thePlayer.hurtTime = v.toint(); + if(mc.thePlayer != null) { + mc.thePlayer.hurtTime = v.toint(); + } return LuaValue.NIL; } }); @@ -448,7 +527,9 @@ public LuaValue call(LuaValue v) { new VarArgFunction() { @Override public Varargs invoke(Varargs args) { - if(mc.thePlayer == null) return LuaValue.NIL; + if(mc.thePlayer == null) { + return LuaValue.NIL; + } float yaw = (float) args.checkdouble(1); float pitch = (float) args.checkdouble(2); mc.thePlayer.rotationYaw = yaw; @@ -458,14 +539,33 @@ public Varargs invoke(Varargs args) { return LuaValue.NIL; } }); + set( + "setServerRotation", + new VarArgFunction() { + @Override + public Varargs invoke(Varargs args) { + if(mc.thePlayer == null) { + return LuaValue.NIL; + } + float yaw = (float) args.checkdouble(1); + float pitch = (float) args.checkdouble(2); + mc.thePlayer.rotationYaw = yaw; + mc.thePlayer.rotationPitch = pitch; + return LuaValue.NIL; + } + }); set( "getEntityById", new OneArgFunction() { @Override public LuaValue call(LuaValue idValue) { - if(mc.theWorld == null || mc.thePlayer == null) return LuaValue.NIL; + if(mc.theWorld == null || mc.thePlayer == null) { + return LuaValue.NIL; + } Entity entity = mc.theWorld.getEntityByID(idValue.toint()); - if(!(entity instanceof EntityLivingBase)) return LuaValue.NIL; + if(!(entity instanceof EntityLivingBase)) { + return LuaValue.NIL; + } return livingToTable((EntityLivingBase) entity); } }); @@ -474,7 +574,9 @@ public LuaValue call(LuaValue idValue) { new OneArgFunction() { @Override public LuaValue call(LuaValue v) { - if(mc.thePlayer != null) mc.thePlayer.moveForward = (float) v.todouble(); + if(mc.thePlayer != null) { + mc.thePlayer.moveForward = (float) v.todouble(); + } return LuaValue.NIL; } }); @@ -483,7 +585,9 @@ public LuaValue call(LuaValue v) { new OneArgFunction() { @Override public LuaValue call(LuaValue v) { - if(mc.thePlayer != null) mc.thePlayer.moveStrafing = (float) v.todouble(); + if(mc.thePlayer != null) { + mc.thePlayer.moveStrafing = (float) v.todouble(); + } return LuaValue.NIL; } }); @@ -492,10 +596,14 @@ public LuaValue call(LuaValue v) { new OneArgFunction() { @Override public LuaValue call(LuaValue slotValue) { - if(mc.thePlayer == null) return LuaValue.valueOf(""); + if(mc.thePlayer == null) { + return LuaValue.valueOf(""); + } net.minecraft.item.ItemStack stack = mc.thePlayer.inventory.getStackInSlot(slotValue.toint()); - if(stack == null) return LuaValue.valueOf(""); + if(stack == null) { + return LuaValue.valueOf(""); + } return LuaValue.valueOf(stack.getItem().getUnlocalizedName()); } }); @@ -504,7 +612,9 @@ public LuaValue call(LuaValue slotValue) { new OneArgFunction() { @Override public LuaValue call(LuaValue v) { - if(mc.thePlayer != null) mc.thePlayer.inventory.currentItem = v.toint(); + if(mc.thePlayer != null) { + mc.thePlayer.inventory.currentItem = v.toint(); + } return LuaValue.NIL; } }); @@ -513,9 +623,10 @@ public LuaValue call(LuaValue v) { new ZeroArgFunction() { @Override public LuaValue call() { - if(mc.thePlayer != null && mc.theWorld != null) + if(mc.thePlayer != null && mc.theWorld != null) { mc.playerController.sendUseItem( mc.thePlayer, mc.theWorld, mc.thePlayer.getCurrentEquippedItem()); + } return LuaValue.NIL; } }); @@ -526,16 +637,16 @@ private LuaTable livingToTable(EntityLivingBase e) { t.set("id", LuaValue.valueOf(e.getEntityId())); String name = e instanceof EntityPlayer - ? ((EntityPlayer) e).getName() + ? e.getName() : e.hasCustomName() ? e.getCustomNameTag() : e.getClass().getSimpleName(); t.set("name", LuaValue.valueOf(name)); t.set("x", LuaValue.valueOf(e.posX)); t.set("y", LuaValue.valueOf(e.posY)); t.set("z", LuaValue.valueOf(e.posZ)); - t.set("eyeHeight", LuaValue.valueOf((double) e.getEyeHeight())); - t.set("health", LuaValue.valueOf((double) e.getHealth())); + t.set("eyeHeight", LuaValue.valueOf(e.getEyeHeight())); + t.set("health", LuaValue.valueOf(e.getHealth())); t.set("hurtTime", LuaValue.valueOf(e.hurtTime)); - t.set("distance", LuaValue.valueOf((double) mc.thePlayer.getDistanceToEntity(e))); + t.set("distance", LuaValue.valueOf(mc.thePlayer.getDistanceToEntity(e))); t.set("isInvisible", LuaValue.valueOf(e.isInvisible())); t.set("isPlayer", LuaValue.valueOf(e instanceof EntityPlayer)); t.set("isHostile", LuaValue.valueOf(e instanceof IMob)); @@ -550,10 +661,10 @@ private LuaTable entityToTable(EntityPlayer ep) { t.set("x", LuaValue.valueOf(ep.posX)); t.set("y", LuaValue.valueOf(ep.posY)); t.set("z", LuaValue.valueOf(ep.posZ)); - t.set("eyeHeight", LuaValue.valueOf((double) ep.getEyeHeight())); - t.set("health", LuaValue.valueOf((double) ep.getHealth())); + t.set("eyeHeight", LuaValue.valueOf(ep.getEyeHeight())); + t.set("health", LuaValue.valueOf(ep.getHealth())); t.set("hurtTime", LuaValue.valueOf(ep.hurtTime)); - t.set("distance", LuaValue.valueOf((double) mc.thePlayer.getDistanceToEntity(ep))); + t.set("distance", LuaValue.valueOf(mc.thePlayer.getDistanceToEntity(ep))); t.set("isInvisible", LuaValue.valueOf(ep.isInvisible())); return t; } diff --git a/src/main/java/dev/thoq/lua/api/LuaMinecraftApi.java b/src/main/java/dev/thoq/lua/api/LuaMinecraftApi.java index 0ef81b5f..50242aeb 100644 --- a/src/main/java/dev/thoq/lua/api/LuaMinecraftApi.java +++ b/src/main/java/dev/thoq/lua/api/LuaMinecraftApi.java @@ -404,6 +404,27 @@ public LuaValue call(LuaValue yawValue) { return LuaValue.NIL; } }); + set( + "getCameraPitch", + new ZeroArgFunction() { + @Override + public LuaValue call() { + return minecraft.getRenderViewEntity() != null + ? LuaValue.valueOf(minecraft.getRenderViewEntity().rotationPitch) + : LuaValue.valueOf(0d); + } + }); + set( + "setCameraPitch", + new OneArgFunction() { + @Override + public LuaValue call(LuaValue pitchValue) { + if(minecraft.getRenderViewEntity() != null) { + minecraft.getRenderViewEntity().rotationPitch = (float) pitchValue.todouble(); + } + return LuaValue.NIL; + } + }); set( "getPartialTicks", new ZeroArgFunction() { @@ -899,6 +920,19 @@ public LuaValue call(LuaValue xValue, LuaValue yValue, LuaValue zValue) { return LuaValue.FALSE; } }); + set( + "getBlockId", + new org.luaj.vm2.lib.ThreeArgFunction() { + @Override + public LuaValue call(LuaValue xValue, LuaValue yValue, LuaValue zValue) { + if(minecraft.theWorld != null) { + BlockPos blockPos = new BlockPos(xValue.toint(), yValue.toint(), zValue.toint()); + int blockId = net.minecraft.block.Block.getIdFromBlock(minecraft.theWorld.getBlockState(blockPos).getBlock()); + return LuaValue.valueOf(blockId); + } + return LuaValue.valueOf(0); + } + }); set( "rightClickBlock", new org.luaj.vm2.lib.VarArgFunction() { @@ -1040,30 +1074,14 @@ public org.luaj.vm2.Varargs invoke(org.luaj.vm2.Varargs arguments) { final int z = arguments.checkint(4); final int faceIndex = arguments.optint(5, 1); final BlockPos pos = new BlockPos(x, y, z); - final EnumFacing facing; - switch(faceIndex) { - case 0: - facing = EnumFacing.DOWN; - break; - case 1: - facing = EnumFacing.UP; - break; - case 2: - facing = EnumFacing.NORTH; - break; - case 3: - facing = EnumFacing.SOUTH; - break; - case 4: - facing = EnumFacing.WEST; - break; - case 5: - facing = EnumFacing.EAST; - break; - default: - facing = EnumFacing.UP; - break; - } + final EnumFacing facing = switch(faceIndex) { + case 0 -> EnumFacing.DOWN; + case 2 -> EnumFacing.NORTH; + case 3 -> EnumFacing.SOUTH; + case 4 -> EnumFacing.WEST; + case 5 -> EnumFacing.EAST; + default -> EnumFacing.UP; + }; final C07PacketPlayerDigging.Action digAction; if(action == 0) { digAction = C07PacketPlayerDigging.Action.START_DESTROY_BLOCK; @@ -1076,5 +1094,20 @@ public org.luaj.vm2.Varargs invoke(org.luaj.vm2.Varargs arguments) { return LuaValue.TRUE; } }); + set( + "sendRotation", + new org.luaj.vm2.lib.TwoArgFunction() { + @Override + public LuaValue call(LuaValue yawValue, LuaValue pitchValue) { + if(minecraft.thePlayer != null) { + float yaw = (float) yawValue.todouble(); + float pitch = (float) pitchValue.todouble(); + minecraft.getNetHandler().addToSendQueue( + new net.minecraft.network.play.client.C03PacketPlayer.C05PacketPlayerLook( + yaw, pitch, minecraft.thePlayer.onGround)); + } + return LuaValue.NIL; + } + }); } } diff --git a/src/main/resources/lua/alya.d.lua b/src/main/resources/lua/alya.d.lua index fe5be296..b1d76878 100644 --- a/src/main/resources/lua/alya.d.lua +++ b/src/main/resources/lua/alya.d.lua @@ -373,6 +373,10 @@ function AlyaMC.getCameraYaw() end ---@param yaw number function AlyaMC.setCameraYaw(yaw) end ---@return number +function AlyaMC.getCameraPitch() end +---@param pitch number +function AlyaMC.setCameraPitch(pitch) end +---@return number function AlyaMC.getCurrentTime() end ---@return number function AlyaMC.getLastPosX() end @@ -456,6 +460,18 @@ function AlyaMC.sendChatMessage(message) end ---@return boolean success function AlyaMC.breakBlock(action, x, y, z, facing) end +---returns the block ID at the given position +---@param x integer +---@param y integer +---@param z integer +---@return integer block ID +function AlyaMC.getBlockId(x, y, z) end + +---sends a rotation packet to the server +---@param yaw number +---@param pitch number +function AlyaMC.sendRotation(yaw, pitch) end + ---@class AlyaFontRenderer ---@field drawString fun(text: string, x: number, y: number, color: integer) ---@field drawStringWithShadow fun(text: string, x: number, y: number, color: integer) @@ -593,6 +609,11 @@ function AlyaCombat.getPlayerPitch() end ---@param pitch number function AlyaCombat.setClientRotation(yaw, pitch) end +---sets the players rotation server side (sends to server) +---@param yaw number +---@param pitch number +function AlyaCombat.setServerRotation(yaw, pitch) end + ---@class client ---@field modules AlyaModules ---@field combat AlyaCombat @@ -619,6 +640,10 @@ function AlyaCombat.setClientRotation(yaw, pitch) end ---@type client alya = {} +---returns the current accent color as integer +---@return integer +function alya.getAccent() end + ---loads and executes Lua script from classpath resource path, returns script's return value ---@param resourcePath string e.g. "/lua/modules/movement/flight/motion.lua" ---@return any diff --git a/src/main/resources/lua/modules/player/fucker.lua b/src/main/resources/lua/modules/player/fucker.lua new file mode 100644 index 00000000..a1a547d7 --- /dev/null +++ b/src/main/resources/lua/modules/player/fucker.lua @@ -0,0 +1,271 @@ +local moduleTable = alya.modules.register("Fucker", "Break special blocks through other blocks", "PLAYER") + +local range = moduleTable.addNumberSetting("Range", "Maximum distance to target", 6, 1, 10, 0.5) +local mode = moduleTable.addModeSetting("Mode", "Breaking mode", "Instant", "Instant", "Legit") +local beds = moduleTable.addBooleanSetting("Beds", "Target beds", true) +local delay = moduleTable.addNumberSetting("Delay", "Delay between break attempts (ms)", 50, 0, 500, 10) +local highlight = moduleTable.addBooleanSetting("Highlight", "Highlight target block", true) + +local timer = alya.timer.create() +local currentTarget = nil +local pathBlocks = {} +local targetBlockPos = nil +local isMiningThrough = false +local currentYaw = 0 +local currentPitch = 0 +local rotationSpeed = 0.15 + +local bedBlockIds = { + [26] = true, -- bed + [355] = true, -- bed (white) +} + +local function isTargetBlock(block) + if beds.isEnabled() and bedBlockIds[block] then + return true + end + return false +end + +local function getBlockId(x, y, z) + return alya.mc.getBlockId(x, y, z) +end + +local function hasLineOfSight(x, y, z) + local result = alya.mc.raycastBlock(alya.mc.getYaw(), alya.mc.getPitch(), range.getValue()) + if result then + return result.x == x and result.y == y and result.z == z + end + return false +end + +local function findPathToTarget(targetX, targetY, targetZ) + local playerX = math.floor(alya.mc.getPlayerX()) + local playerY = math.floor(alya.mc.getPlayerY()) + local playerZ = math.floor(alya.mc.getPlayerZ()) + + local path = {} + local visited = {} + + local function posKey(x, y, z) + return x .. "," .. y .. "," .. z + end + + local queue = { + { x = playerX, y = playerY, z = playerZ, dist = 0 } + } + visited[posKey(playerX, playerY, playerZ)] = true + + local found = nil + local iterations = 0 + local maxIterations = 200 + + while #queue > 0 and iterations < maxIterations do + iterations = iterations + 1 + table.sort(queue, function(a, b) return a.dist < b.dist end) + + local current = table.remove(queue, 1) + + if current.x == targetX and current.y == targetY and current.z == targetZ then + found = current + break + end + + local neighbors = { + { x = current.x + 1, y = current.y, z = current.z }, + { x = current.x - 1, y = current.y, z = current.z }, + { x = current.x, y = current.y, z = current.z + 1 }, + { x = current.x, y = current.y, z = current.z - 1 }, + { x = current.x, y = current.y + 1, z = current.z }, + { x = current.x, y = current.y - 1, z = current.z }, + } + + for _, neighbor in ipairs(neighbors) do + local key = posKey(neighbor.x, neighbor.y, neighbor.z) + if not visited[key] then + local blockId = getBlockId(neighbor.x, neighbor.y, neighbor.z) + if blockId == 0 or isTargetBlock(blockId) then + visited[key] = true + table.insert(queue, { + x = neighbor.x, + y = neighbor.y, + z = neighbor.z, + dist = current.dist + 1, + parent = current + }) + end + end + end + end + + if found then + local result = {} + local curr = found + while curr.parent do + table.insert(result, { x = curr.x, y = curr.y, z = curr.z }) + curr = curr.parent + end + return result + end + + return {} +end + +local function getBreakingOrder(targetX, targetY, targetZ) + local playerX = alya.mc.getPlayerX() + local playerY = alya.mc.getPlayerY() + local playerZ = alya.mc.getPlayerZ() + + local blocks = {} + + local path = findPathToTarget(targetX, targetY, targetZ) + + for i = #path, 1, -1 do + local block = path[i] + local dist = math.sqrt( + (block.x - playerX) ^ 2 + + (block.y - playerY) ^ 2 + + (block.z - playerZ) ^ 2 + ) + table.insert(blocks, { x = block.x, y = block.y, z = block.z, dist = dist }) + end + + table.sort(blocks, function(a, b) return a.dist < b.dist end) + return blocks +end + +local function getRotationToBlock(x, y, z) + local playerX = alya.mc.getPlayerX() + local playerY = alya.mc.getPlayerY() + 1.5 + local playerZ = alya.mc.getPlayerZ() + + local dx = x + 0.5 - playerX + local dy = y + 0.5 - playerY + local dz = z + 0.5 - playerZ + + local yaw = math.atan2(-dx, dz) * (180 / math.pi) + local pitch = math.atan2(dy, math.sqrt(dx * dx + dz * dz)) * (180 / math.pi) + + return yaw, pitch +end + +local function lerpAngle(from, to, factor) + local diff = to - from + while diff > 180 do diff = diff - 360 end + while diff < -180 do diff = diff + 360 end + return from + diff * factor +end + +local function breakBlockInstant(x, y, z) + alya.mc.breakBlock(0, x, y, z, 1) + alya.mc.breakBlock(1, x, y, z, 1) +end + +local function getTargetBlock() + local playerX = alya.mc.getPlayerX() + local playerY = alya.mc.getPlayerY() + local playerZ = alya.mc.getPlayerZ() + local rangeVal = range.getValue() + + local targets = {} + + for x = math.floor(playerX) - rangeVal, math.floor(playerX) + rangeVal do + for z = math.floor(playerZ) - rangeVal, math.floor(playerZ) + rangeVal do + for y = math.floor(playerY) - 2, math.floor(playerY) + 2 do + local blockId = getBlockId(x, y, z) + if isTargetBlock(blockId) then + local dist = math.sqrt( + (x - playerX) ^ 2 + + (y - playerY) ^ 2 + + (z - playerZ) ^ 2 + ) + table.insert(targets, { x = x, y = y, z = z, dist = dist, blockId = blockId }) + end + end + end + end + + table.sort(targets, function(a, b) return a.dist < b.dist end) + return targets[1] +end + +moduleTable.onEnable(function() + timer.reset() + currentTarget = nil + pathBlocks = {} + targetBlockPos = nil + isMiningThrough = false +end) + +moduleTable.onDisable(function() + currentTarget = nil + pathBlocks = {} + targetBlockPos = nil + isMiningThrough = false +end) + +alya.events.on("motion", function(event) + if not moduleTable.isEnabled() then return end + if not event.isPre() then return end + if alya.mc.isPlayerNull() or alya.mc.isWorldNull() then return end + + local target = getTargetBlock() + + if not target then + currentTarget = nil + pathBlocks = {} + targetBlockPos = nil + isMiningThrough = false + return + end + + if not currentTarget or currentTarget.x ~= target.x or currentTarget.y ~= target.y or currentTarget.z ~= target.z then + currentTarget = target + pathBlocks = getBreakingOrder(target.x, target.y, target.z) + targetBlockPos = { x = target.x, y = target.y, z = target.z } + isMiningThrough = #pathBlocks > 1 + timer.reset() + end + + if mode.is("Instant") then + breakBlockInstant(target.x, target.y, target.z) + elseif mode.is("Legit") then + if not timer.hasElapsed(delay.getValueAsInt()) then + return + end + timer.reset() + + if #pathBlocks > 0 then + local nextBlock = pathBlocks[1] + local targetYaw, targetPitch = getRotationToBlock(nextBlock.x, nextBlock.y, nextBlock.z) + + currentYaw = lerpAngle(currentYaw, targetYaw, rotationSpeed) + currentPitch = lerpAngle(currentPitch, targetPitch, rotationSpeed) + + alya.combat.setClientRotation(currentYaw, currentPitch) + + if hasLineOfSight(nextBlock.x, nextBlock.y, nextBlock.z) then + alya.mc.sendRotation(currentYaw, currentPitch) + breakBlockInstant(nextBlock.x, nextBlock.y, nextBlock.z) + end + + local blockId = getBlockId(nextBlock.x, nextBlock.y, nextBlock.z) + if blockId == 0 then + table.remove(pathBlocks, 1) + end + end + end +end) + +alya.events.on("render3d", function(event) + if not moduleTable.isEnabled() then return end + if not highlight.isEnabled() then return end + if not targetBlockPos then return end + + local x = targetBlockPos.x + local y = targetBlockPos.y + local z = targetBlockPos.z + + local color = alya.visual.toARGB(255, 255, 0, 0) + alya.visual.drawBox3D(x + 0.5, y + 0.5, z + 0.5, 1, 1, color, 2.0) +end) \ No newline at end of file diff --git a/src/main/resources/lua/modules/visual/arraylist.lua b/src/main/resources/lua/modules/visual/arraylist.lua index d340c3d7..37367142 100644 --- a/src/main/resources/lua/modules/visual/arraylist.lua +++ b/src/main/resources/lua/modules/visual/arraylist.lua @@ -1,16 +1,19 @@ local moduleTable = alya.modules.register("ArrayList", "Displays enabled modules on screen", "VISUAL") local showVisual = moduleTable.addBooleanSetting("Show Visual Modules", "Show visual modules?", true) +local waveColor = moduleTable.addBooleanSetting("Wave Color", "Enable wave effect?", true) -local categoryColors = { - COMBAT = 0xFFE74C3C, - MOVEMENT = 0xFF2ECC71, - PLAYER = 0xFF8E44AD, - VISUAL = 0xFF3700CE, - OTHER = 0xFFF39C12, -} +local function getWaveFactor(index) + if not waveColor.isEnabled() then return 1.0 end + return (math.sin(os.clock() * 4 - (index * 0.4)) + 1) / 2 * 0.5 + 0.5 +end -local function getCategoryColor(category) - return categoryColors[category] or 0xFFFF55FF +local function applyWave(hex, index) + local factor = getWaveFactor(index) + local a = bit32.extract(hex, 24, 8) + local r = math.floor(bit32.extract(hex, 16, 8) * factor) + local g = math.floor(bit32.extract(hex, 8, 8) * factor) + local b = math.floor(bit32.extract(hex, 0, 8) * factor) + return bit32.bor(bit32.lshift(a, 24), bit32.lshift(r, 16), bit32.lshift(g, 8), b) end alya.events.on("render2d", function(event) @@ -30,6 +33,7 @@ alya.events.on("render2d", function(event) local padding = 4 local height = fontRenderer.getFontHeight() local positionY = 2 + local baseAccent = alya.getAccent() for index = 1, #enabledModules do local currentModule = enabledModules[index] @@ -40,11 +44,11 @@ alya.events.on("render2d", function(event) if showVisual.isEnabled() or category ~= "VISUAL" then local width = fontRenderer.getStringWidth(name) + padding * 2 local positionX = screenWidth - width - 2 - local color = getCategoryColor(category) + local modColor = applyWave(baseAccent, index) alya.visual.drawRect(positionX - 1, positionY - 1, width + 2, height + 2, 0x90000000) - alya.visual.drawRect(screenWidth - 2, positionY - 1, 1, height + 2, color) - fontRenderer.drawString(name, positionX + padding - 2, positionY, 0xFFFFFFFF) + alya.visual.drawRect(screenWidth - 2, positionY - 1, 1, height + 2, modColor) + fontRenderer.drawString(name, positionX + padding - 2, positionY, modColor) positionY = positionY + height + 2 end From 3d60107f1aec74d8bd53ee0e12f5d0aca60a86ab Mon Sep 17 00:00:00 2001 From: thoq Date: Wed, 8 Apr 2026 09:24:00 -0400 Subject: [PATCH 3/4] add no rotate module --- src/main/java/dev/thoq/Alya.java | 1 + .../resources/lua/modules/player/norotate.lua | 46 +++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 src/main/resources/lua/modules/player/norotate.lua diff --git a/src/main/java/dev/thoq/Alya.java b/src/main/java/dev/thoq/Alya.java index c2bb3ed2..135fd7a4 100644 --- a/src/main/java/dev/thoq/Alya.java +++ b/src/main/java/dev/thoq/Alya.java @@ -103,6 +103,7 @@ public String[] initializeModules() { new Script(Category.PLAYER, "scaffold"), new Script(Category.PLAYER, "nuker"), new Script(Category.PLAYER, "fucker"), + new Script(Category.PLAYER, "norotate"), new Script(Category.PLAYER, "timer"), new Script(Category.EXPLOIT, "disabler"), new Script(Category.OTHER, "hackerdetector"), diff --git a/src/main/resources/lua/modules/player/norotate.lua b/src/main/resources/lua/modules/player/norotate.lua new file mode 100644 index 00000000..2a1565bb --- /dev/null +++ b/src/main/resources/lua/modules/player/norotate.lua @@ -0,0 +1,46 @@ +local moduleTable = alya.modules.register("NoRotate", "Prevents server from setting your rotation", "PLAYER") + +local pitch = moduleTable.addBooleanSetting("Pitch", "Lock pitch", true) +local yaw = moduleTable.addBooleanSetting("Yaw", "Lock yaw", true) + +local savedYaw = 0 +local savedPitch = 0 + +moduleTable.onEnable(function() + savedYaw = alya.mc.getYaw() + savedPitch = alya.mc.getPitch() +end) + +moduleTable.onDisable(function() +end) + +alya.events.on("packetsend", function(event) + if not moduleTable.isEnabled() then return end +end) + +alya.events.on("packetreceive", function(event) + if not moduleTable.isEnabled() then return end + local packetClass = event.getPacketClass() + + if packetClass:find("S08") or packetClass:find("PlayerPosLook") then + if yaw.isEnabled() then + alya.mc.setCameraYaw(savedYaw) + alya.combat.setClientRotation(savedYaw, savedPitch) + end + if pitch.isEnabled() then + alya.mc.setCameraPitch(savedPitch) + end + end +end) + +alya.events.on("motion", function(event) + if not moduleTable.isEnabled() then return end + if not event.isPre() then return end + + if yaw.isEnabled() then + savedYaw = alya.mc.getYaw() + end + if pitch.isEnabled() then + savedPitch = alya.mc.getPitch() + end +end) \ No newline at end of file From 025612ed825792128e0f6f972cce3149aba567db Mon Sep 17 00:00:00 2001 From: thoq Date: Wed, 8 Apr 2026 09:45:51 -0400 Subject: [PATCH 4/4] small ui changes: arraylist accent bar and clickgui padding --- .../modules/clickgui/ClickGUIScreen.java | 57 ++++++++++--------- .../lua/modules/visual/arraylist.lua | 3 +- 2 files changed, 32 insertions(+), 28 deletions(-) diff --git a/src/main/java/dev/thoq/module/modules/clickgui/ClickGUIScreen.java b/src/main/java/dev/thoq/module/modules/clickgui/ClickGUIScreen.java index 3fb7a901..5e7b6d39 100644 --- a/src/main/java/dev/thoq/module/modules/clickgui/ClickGUIScreen.java +++ b/src/main/java/dev/thoq/module/modules/clickgui/ClickGUIScreen.java @@ -47,6 +47,8 @@ public final class ClickGUIScreen extends GuiScreen { private static final int DEFAULT_CATEGORY_COLOR = 0x20444444; private static final int ICON_SIZE = 7; private static final int BOTTOM_ICON_SIZE = 7; + private static final int BOTTOM_PANEL_SPACING = 10; + private static final int PANEL_PADDING = 2; private static final AlyaFontRenderer font = new AlyaFontRenderer("client/fonts/Lato-Bold.ttf", 7.5F); private static final AlyaFontRenderer settingsFont = new AlyaFontRenderer("client/fonts/Lato-Bold.ttf", 6.5F); @@ -148,7 +150,7 @@ private void renderCategoryPanel(final Category category, final int mouseX, fina } int totalHeight = PANEL_HEIGHT; if(expandedCategories.get(category)) { - totalHeight += calculateExpandedHeight(modules) + 1; + totalHeight += calculateExpandedHeight(modules) + 1 + PANEL_PADDING / 2; } renderPanelHeader(category, panelX, panelY); if(expandedCategories.get(category)) { @@ -160,7 +162,7 @@ private void renderCategoryPanel(final Category category, final int mouseX, fina private void renderPanelHeader(final Category category, final int panelX, final int panelY) { RenderUtility.drawRect(panelX, panelY, PANEL_WIDTH, PANEL_HEIGHT, BACKGROUND_COLOR); final String categoryName = category.getDisplayName().toLowerCase(); - font.drawString(categoryName, panelX + 4, panelY + 5, TEXT_COLOR); + font.drawString(categoryName, panelX + 4 + PANEL_PADDING, panelY + 5, TEXT_COLOR); final int categoryColor = getCategoryColor(category); final float r = (categoryColor >> 16 & 0xFF) / 255.0F; final float g = (categoryColor >> 8 & 0xFF) / 255.0F; @@ -169,7 +171,7 @@ private void renderPanelHeader(final Category category, final int panelX, final GlStateManager.color(r, g, b, 1.0F); RenderUtility.drawImage( new ResourceLocation("client/icons/categories/" + categoryName + "_good.png"), - panelX + PANEL_WIDTH - ICON_SIZE - 4, iconY, ICON_SIZE, ICON_SIZE); + panelX + PANEL_WIDTH - ICON_SIZE - 4 - PANEL_PADDING, iconY, ICON_SIZE, ICON_SIZE); final boolean expanded = expandedCategories.get(category); if(expanded) { GlStateManager.color(r, g, b, 1.0F); @@ -179,7 +181,7 @@ private void renderPanelHeader(final Category category, final int panelX, final final String eyeIconName = expanded ? "eye_open.png" : "eye_close.png"; RenderUtility.drawImage( new ResourceLocation("client/icons/" + eyeIconName), - panelX + PANEL_WIDTH - (ICON_SIZE * 2) - 6, iconY, ICON_SIZE, ICON_SIZE); + panelX + PANEL_WIDTH - (ICON_SIZE * 2) - 6 - PANEL_PADDING, iconY, ICON_SIZE, ICON_SIZE); } private int calculateExpandedHeight(final List modules) { @@ -225,7 +227,7 @@ private void renderExpandedModules( final int mouseY) { int currentY = startY; for(final Module module : modules) { - renderModuleButton(module, panelX, currentY, category, mouseX, mouseY); + renderModuleButton(module, panelX + PANEL_PADDING, currentY, category, mouseX, mouseY); currentY += MODULE_HEIGHT; if(expandedModules.getOrDefault(module, false)) { currentY = renderModuleSettings(module, panelX, currentY, category, mouseX, mouseY); @@ -241,16 +243,17 @@ private int renderModuleSettings( final int mouseX, final int mouseY) { int currentY = startY; - RenderUtility.drawRect(panelX + 1, currentY, PANEL_WIDTH - 2, SETTING_GROUP_PADDING, SETTING_BACKGROUND_COLOR); + final int paddedWidth = PANEL_WIDTH - PANEL_PADDING * 2; + RenderUtility.drawRect(panelX + PANEL_PADDING + 1, currentY, paddedWidth - 2, SETTING_GROUP_PADDING, SETTING_BACKGROUND_COLOR); currentY += SETTING_GROUP_PADDING; for(final Setting setting : module.getSettings()) { if(!setting.isVisible()) { continue; } - renderSettingButton(setting, panelX, currentY, category, mouseX, mouseY); + renderSettingButton(setting, panelX + PANEL_PADDING, currentY, category, mouseX, mouseY); currentY += SETTING_HEIGHT; } - RenderUtility.drawRect(panelX + 1, currentY, PANEL_WIDTH - 2, SETTING_GROUP_PADDING, SETTING_BACKGROUND_COLOR); + RenderUtility.drawRect(panelX + PANEL_PADDING + 1, currentY, paddedWidth - 2, SETTING_GROUP_PADDING, SETTING_BACKGROUND_COLOR); currentY += SETTING_GROUP_PADDING; return currentY; } @@ -269,9 +272,9 @@ private void renderModuleButton( if(hovered) { backgroundColor = dimColor(backgroundColor, HOVER_DIM); } - RenderUtility.drawRect(positionX + 1, positionY, PANEL_WIDTH - 2, MODULE_HEIGHT, backgroundColor); + RenderUtility.drawRect(positionX + 1, positionY, PANEL_WIDTH - PANEL_PADDING * 2 - 2, MODULE_HEIGHT, backgroundColor); } else { - RenderUtility.drawRect(positionX + 1, positionY, PANEL_WIDTH - 2, MODULE_HEIGHT, BACKGROUND_COLOR); + RenderUtility.drawRect(positionX + 1, positionY, PANEL_WIDTH - PANEL_PADDING * 2 - 2, MODULE_HEIGHT, BACKGROUND_COLOR); } final String moduleName = module.getName().toLowerCase().replace(" ", ""); final int textColor = @@ -286,12 +289,13 @@ private void renderSettingButton( final Category category, final int mouseX, final int mouseY) { + final int paddedWidth = PANEL_WIDTH - PANEL_PADDING * 2; final int settingX = positionX + SETTING_INDENT; - final int settingWidth = PANEL_WIDTH - SETTING_INDENT * 2; + final int settingWidth = paddedWidth - SETTING_INDENT * 2; RenderUtility.drawRect( - positionX + 1, positionY, PANEL_WIDTH - 2, SETTING_HEIGHT, SETTING_BACKGROUND_COLOR); + positionX + 1, positionY, paddedWidth - 2, SETTING_HEIGHT, SETTING_BACKGROUND_COLOR); final int textX = settingX + 3; - final int settingRight = positionX + PANEL_WIDTH - SETTING_INDENT; + final int settingRight = positionX + paddedWidth - SETTING_INDENT; if(setting instanceof BooleanSetting booleanSetting) { final boolean boolHovered = isMouseOver(mouseX, mouseY, positionX, positionY, SETTING_HEIGHT); if(booleanSetting.isEnabled()) { @@ -404,7 +408,7 @@ private void renderSingleNumberSetting( private void renderBottomBar(final int mouseX, final int mouseY) { final int configsPanelX = width - PANEL_WIDTH; - final int scriptsPanelX = configsPanelX - PANEL_WIDTH; + final int scriptsPanelX = configsPanelX - BOTTOM_PANEL_SPACING - PANEL_WIDTH; final int panelY = height - PANEL_HEIGHT; renderBottomPanel("scripts", scriptsPanelX, panelY, scriptsExpanded, getScriptEntries(), new String[0], @@ -428,9 +432,9 @@ private void renderBottomPanel( final int mouseY, final boolean isScripts) { RenderUtility.drawRect(panelX, panelY, PANEL_WIDTH, PANEL_HEIGHT, BACKGROUND_COLOR); - font.drawString(title, panelX + 4, panelY + 5, TEXT_COLOR); + font.drawString(title, panelX + 4 + PANEL_PADDING, panelY + 5, TEXT_COLOR); - int iconX = panelX + PANEL_WIDTH - BOTTOM_ICON_SIZE - 3; + int iconX = panelX + PANEL_WIDTH - BOTTOM_ICON_SIZE - 3 - PANEL_PADDING; final int iconY = panelY + (PANEL_HEIGHT - BOTTOM_ICON_SIZE) / 2; GlStateManager.color(0.6F, 0.6F, 0.6F, 1.0F); @@ -453,7 +457,7 @@ private void renderBottomPanel( i < entries.length; i++) { final String entry = entries[i]; - final boolean hovered = mouseX >= panelX && mouseX <= panelX + PANEL_WIDTH + final boolean hovered = mouseX >= panelX + PANEL_PADDING && mouseX <= panelX + PANEL_PADDING + PANEL_WIDTH - PANEL_PADDING * 2 && mouseY >= entryY && mouseY <= entryY + MODULE_HEIGHT; if(isScripts) { @@ -462,20 +466,20 @@ private void renderBottomPanel( if(hovered) { bgColor = dimColor(bgColor, HOVER_DIM); } - RenderUtility.drawRect(panelX, entryY, PANEL_WIDTH, MODULE_HEIGHT, bgColor); + RenderUtility.drawRect(panelX + PANEL_PADDING, entryY, PANEL_WIDTH - PANEL_PADDING * 2, MODULE_HEIGHT, bgColor); } else { int bgColor = MODULE_BACKGROUND_COLOR; if(hovered) { bgColor = dimColor(bgColor, HOVER_DIM); } - RenderUtility.drawRect(panelX, entryY, PANEL_WIDTH, MODULE_HEIGHT, bgColor); + RenderUtility.drawRect(panelX + PANEL_PADDING, entryY, PANEL_WIDTH - PANEL_PADDING * 2, MODULE_HEIGHT, bgColor); } - font.drawString(entry, panelX + 4, entryY + 5, TEXT_COLOR); + font.drawString(entry, panelX + PANEL_PADDING + 4, entryY + 5, TEXT_COLOR); if(!isScripts && i < entryDates.length && entryDates[i] != null) { final float dateWidth = settingsFont.getStringWidth(entryDates[i]); - settingsFont.drawString(entryDates[i], panelX + PANEL_WIDTH - dateWidth - 4, entryY + 5, 0xFF888888); + settingsFont.drawString(entryDates[i], panelX + PANEL_WIDTH - PANEL_PADDING - dateWidth - 4, entryY + 5, 0xFF888888); } entryY += MODULE_HEIGHT; @@ -543,7 +547,7 @@ private String[] getConfigDates() { private boolean handleBottomBarClick(final int mouseX, final int mouseY, final int mouseButton) { final int configsPanelX = width - PANEL_WIDTH; - final int scriptsPanelX = configsPanelX - PANEL_WIDTH; + final int scriptsPanelX = configsPanelX - BOTTOM_PANEL_SPACING - PANEL_WIDTH; final int panelY = height - PANEL_HEIGHT; if(mouseX >= scriptsPanelX && mouseX <= scriptsPanelX + PANEL_WIDTH @@ -584,7 +588,7 @@ private boolean handleBottomBarClick(final int mouseX, final int mouseY, final i } private boolean handleBottomPanelIconClick(final int mouseX, final int panelX, final boolean isScripts) { - int iconX = panelX + PANEL_WIDTH - BOTTOM_ICON_SIZE - 3; + int iconX = panelX + PANEL_WIDTH - BOTTOM_ICON_SIZE - 3 - PANEL_PADDING; iconX -= BOTTOM_ICON_SIZE + 2; @@ -613,8 +617,9 @@ private boolean handleBottomEntryClick( final int mouseX, final int mouseY, final int mouseButton, final boolean isScripts) { final int entryTotalHeight = entries.length * MODULE_HEIGHT; int entryY = panelY - entryTotalHeight; + final int paddedWidth = PANEL_WIDTH - PANEL_PADDING * 2; for(final String entry : entries) { - if(mouseX >= panelX && mouseX <= panelX + PANEL_WIDTH + if(mouseX >= panelX + PANEL_PADDING && mouseX <= panelX + PANEL_PADDING + paddedWidth && mouseY >= entryY && mouseY <= entryY + MODULE_HEIGHT) { if(mouseButton == 0) { if(isScripts) { @@ -719,14 +724,14 @@ private boolean handleExpandedModulesClick( } int currentY = panelY + PANEL_HEIGHT; for(final Module module : modules) { - if(isMouseOver(mouseX, mouseY, panelX, currentY, MODULE_HEIGHT)) { + if(isMouseOver(mouseX, mouseY, panelX + PANEL_PADDING, currentY, MODULE_HEIGHT)) { handleModuleClick(module, mouseButton); return true; } currentY += MODULE_HEIGHT; if(expandedModules.getOrDefault(module, false)) { currentY += SETTING_GROUP_PADDING; - if(tryHandleSettingClick(module, panelX, currentY, mouseX, mouseY, mouseButton)) { + if(tryHandleSettingClick(module, panelX + PANEL_PADDING, currentY, mouseX, mouseY, mouseButton)) { return true; } currentY += countVisibleSettings(module) * SETTING_HEIGHT + SETTING_GROUP_PADDING; diff --git a/src/main/resources/lua/modules/visual/arraylist.lua b/src/main/resources/lua/modules/visual/arraylist.lua index 37367142..117d19a8 100644 --- a/src/main/resources/lua/modules/visual/arraylist.lua +++ b/src/main/resources/lua/modules/visual/arraylist.lua @@ -43,11 +43,10 @@ alya.events.on("render2d", function(event) if name ~= "arraylist" and name ~= "clickgui" then if showVisual.isEnabled() or category ~= "VISUAL" then local width = fontRenderer.getStringWidth(name) + padding * 2 - local positionX = screenWidth - width - 2 + local positionX = screenWidth - width local modColor = applyWave(baseAccent, index) alya.visual.drawRect(positionX - 1, positionY - 1, width + 2, height + 2, 0x90000000) - alya.visual.drawRect(screenWidth - 2, positionY - 1, 1, height + 2, modColor) fontRenderer.drawString(name, positionX + padding - 2, positionY, modColor) positionY = positionY + height + 2