Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .luarc.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"lowercase-global",
"missing-fields",
"undefined-global",
"param-type-mismatch"
"param-type-mismatch",
"undefined-field"
]
}
2 changes: 1 addition & 1 deletion jars/run_config/Start.run.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Start" type="Application" factoryName="Application">
<option name="MAIN_CLASS_NAME" value="start.Main" />
<module name="dev.thoq.Alya.main" />
<module name="Alya.main" />
<option name="VM_PARAMETERS" value="-Xms2G -Xmx4G --sun-misc-unsafe-memory-access=allow --enable-native-access=ALL-UNNAMED -Dalya.dev.resources=$PROJECT_DIR$/src/main/resources" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/jars" />
<method v="2">
Expand Down
4 changes: 2 additions & 2 deletions scripts/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

OS_FLAGS=""
if [[ "$OSTYPE" == "darwin"* ]]; then
OS_FLAGS="-XstartOnFirstThread"
OS_FLAGS="-XstartOnFirstThread"
fi

JDK_PATH="$HOME/Library/Java/JavaVirtualMachines/azul-26/Contents/Home/bin/java"
JDK_PATH="$HOME/.sdkman/candidates/java/26-zulu/bin/java"
echo "JDK PATH: $JDK_PATH"

SCRIPT_DIR=$(pwd)
Expand Down
6 changes: 4 additions & 2 deletions src/main/java/dev/thoq/Alya.java
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,12 @@ public String[] initializeModules() {
new Script(Category.PLAYER, "norotate"),
new Script(Category.PLAYER, "timer"),
new Script(Category.EXPLOIT, "disabler"),
new Script(Category.EXPLOIT, "chatfilter"),
new Script(Category.EXPLOIT, "femboyify"),
new Script(Category.EXPLOIT, "pingspoofer"),
new Script(Category.OTHER, "hackerdetector"),
new Script(Category.OTHER, "worldtime"),
new Script(Category.OTHER, "chatfilter"),
new Script(Category.OTHER, "femboyify")
new Script(Category.OTHER, "dev")
);
}

Expand Down
8 changes: 8 additions & 0 deletions src/main/java/dev/thoq/lua/LuaEngine.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public final class LuaEngine {
private final Globals globals;
private final List<String> loadedScripts = new ArrayList<>();
private final Set<String> loadedExternalScripts = new LinkedHashSet<>();
private boolean isLoadingExternalScript = false;
private LuaEventApi eventApi;

public LuaEngine() {
Expand Down Expand Up @@ -228,6 +229,7 @@ public void loadExternalScripts() {
}

public void loadExternalScript(final File file) {
isLoadingExternalScript = true;
try(final FileInputStream fis = new FileInputStream(file)) {
final LuaValue chunk = globals.load(new InputStreamReader(fis), file.getName());
chunk.call();
Expand All @@ -239,6 +241,8 @@ public void loadExternalScript(final File file) {
ChatUtil.sendError("[Lua] " + file.getName() + ": " + luaError.getMessage());
} catch(final Exception exception) {
Alya.getInstance().getLogger().error("Error loading {}: {}", file.getName(), exception.getMessage());
} finally {
isLoadingExternalScript = false;
}
}

Expand Down Expand Up @@ -310,6 +314,10 @@ public boolean isExternalScriptLoaded(final String fileName) {
return loadedExternalScripts.contains(fileName);
}

public boolean isLoadingExternalScript() {
return isLoadingExternalScript;
}

public void toggleExternalScript(final String fileName) {
final boolean wasLoaded = loadedExternalScripts.contains(fileName);
if(wasLoaded) {
Expand Down
14 changes: 5 additions & 9 deletions src/main/java/dev/thoq/lua/api/LuaCombatApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@

import dev.thoq.util.IUtil;
import net.minecraft.client.Minecraft;
import net.minecraft.client.settings.KeyBinding;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.monster.IMob;
import net.minecraft.entity.passive.IAnimals;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemSword;
import net.minecraft.network.play.client.C02PacketUseEntity;
import net.minecraft.network.play.client.C03PacketPlayer;
Expand Down Expand Up @@ -420,7 +422,7 @@ public LuaValue call() {
return LuaValue.NIL;
}
mc.leftClickCounter = 0;
mc.clickMouse();
KeyBinding.onTick(mc.gameSettings.keyBindAttack.getKeyCode());
return LuaValue.NIL;
}
});
Expand All @@ -432,13 +434,7 @@ public LuaValue call() {
if(mc.thePlayer == null) {
return LuaValue.NIL;
}
try {
java.lang.reflect.Method m =
net.minecraft.client.Minecraft.class.getDeclaredMethod("rightClickMouse");
m.setAccessible(true);
m.invoke(mc);
} catch(Exception ignored) {
}
KeyBinding.onTick(mc.gameSettings.keyBindUseItem.getKeyCode());
return LuaValue.NIL;
}
});
Expand Down Expand Up @@ -599,7 +595,7 @@ public LuaValue call(LuaValue slotValue) {
if(mc.thePlayer == null) {
return LuaValue.valueOf("");
}
net.minecraft.item.ItemStack stack =
ItemStack stack =
mc.thePlayer.inventory.getStackInSlot(slotValue.toint());
if(stack == null) {
return LuaValue.valueOf("");
Expand Down
45 changes: 45 additions & 0 deletions src/main/java/dev/thoq/lua/api/LuaEventApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import dev.thoq.event.IEventListener;
import dev.thoq.event.events.*;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.network.Packet;
import net.minecraft.network.play.INetHandlerPlayClient;
import net.minecraft.network.play.client.C0BPacketEntityAction;
import net.minecraft.network.play.server.S12PacketEntityVelocity;
import net.minecraft.network.play.server.S27PacketExplosion;
Expand Down Expand Up @@ -387,6 +389,27 @@ public LuaValue call() {
return LuaValue.NIL;
}
});
eventTable.set(
"delayProcessing",
new OneArgFunction() {
@Override
public LuaValue call(LuaValue delayValue) {
long delay = delayValue.tolong();
net.minecraft.network.Packet<?> packet = packetSendEvent.getPacket();
packetSendEvent.cancel();
new Thread(() -> {
try {
Thread.sleep(delay);
} catch(InterruptedException ignored) {}
mc.addScheduledTask(() -> {
if(mc.getNetHandler() != null && mc.getNetHandler().getNetworkManager() != null) {
mc.getNetHandler().getNetworkManager().sendPacketNoEvent(packet);
}
});
}).start();
return LuaValue.NIL;
}
});
eventTable.set(
"getAttackedEntityId",
new ZeroArgFunction() {
Expand Down Expand Up @@ -519,6 +542,28 @@ public LuaValue call(LuaValue val) {
return LuaValue.NIL;
}
});
eventTable.set(
"delayProcessing",
new OneArgFunction() {
@SuppressWarnings("unchecked")
@Override
public LuaValue call(LuaValue delayValue) {
long delay = delayValue.tolong();
net.minecraft.network.Packet<?> packet = packetReceiveEvent.getPacket();
packetReceiveEvent.cancel();
new Thread(() -> {
try {
Thread.sleep(delay);
} catch(InterruptedException ignored) {}
mc.addScheduledTask(() -> {
if(mc.getNetHandler() != null) {
((Packet<INetHandlerPlayClient>) packet).processPacket(mc.getNetHandler());
}
});
}).start();
return LuaValue.NIL;
}
});
eventTable.set(
"getEntityId",
new ZeroArgFunction() {
Expand Down
31 changes: 30 additions & 1 deletion src/main/java/dev/thoq/lua/api/LuaMinecraftApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@
import dev.thoq.event.events.PacketSendEvent;
import dev.thoq.event.events.ReachEvent;
import net.minecraft.block.BlockLiquid;
import net.minecraft.block.material.Material;
import net.minecraft.client.Minecraft;
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.network.play.client.C0BPacketEntityAction;
import net.minecraft.util.*;
import org.jspecify.annotations.NonNull;
import org.luaj.vm2.LuaTable;
Expand Down Expand Up @@ -597,7 +599,7 @@ public LuaValue call() {
if(minecraft.thePlayer == null || minecraft.theWorld == null) {
return LuaValue.FALSE;
}
java.util.List<?> boxes =
List<?> boxes =
minecraft.theWorld.getCollidingBoundingBoxes(
minecraft.thePlayer,
minecraft
Expand Down Expand Up @@ -1109,5 +1111,32 @@ public LuaValue call(LuaValue yawValue, LuaValue pitchValue) {
return LuaValue.NIL;
}
});
set(
"sendSprintPacket",
new OneArgFunction() {
@Override
public LuaValue call(LuaValue stateValue) {
if(minecraft.thePlayer != null) {
boolean state = stateValue.toboolean();
C0BPacketEntityAction.Action action = state ? C0BPacketEntityAction.Action.START_SPRINTING : C0BPacketEntityAction.Action.STOP_SPRINTING;
minecraft.getNetHandler().addToSendQueue(new C0BPacketEntityAction(minecraft.thePlayer, action));
}
return LuaValue.NIL;
}
});
set(
"isOnSolidBlock",
new ZeroArgFunction() {
@Override
public LuaValue call() {
if(minecraft.thePlayer == null || minecraft.theWorld == null) {
return LuaValue.FALSE;
}
final BlockPos blockPos = new BlockPos(minecraft.thePlayer.posX, minecraft.thePlayer.posY - 1, minecraft.thePlayer.posZ);
final Material material = minecraft.theWorld.getBlockState(blockPos).getBlock().getMaterial();
return LuaValue.valueOf(material.isOpaque() || material.isLiquid());
}
}
);
}
}
14 changes: 9 additions & 5 deletions src/main/java/dev/thoq/lua/api/LuaModuleApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,16 @@ public LuaModuleApi() {
@Override
public LuaValue call(
LuaValue nameValue, LuaValue descriptionValue, LuaValue categoryString) {
final String categoryName = categoryString.tojstring().toUpperCase();
Category category;
try {
category = Category.valueOf(categoryName);
} catch(IllegalArgumentException illegalArgumentException) {
category = Category.OTHER;
if(Alya.getInstance().getLuaEngine().isLoadingExternalScript()) {
category = Category.SCRIPTS;
} else {
final String categoryName = categoryString.tojstring().toUpperCase();
try {
category = Category.valueOf(categoryName);
} catch(IllegalArgumentException illegalArgumentException) {
category = Category.OTHER;
}
}
final LuaModule luaModule =
new LuaModule(nameValue.tojstring(), descriptionValue.tojstring(), category);
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/dev/thoq/lua/api/LuaMovementApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public LuaValue call() {
new ZeroArgFunction() {
@Override
public LuaValue call() {
return LuaValue.valueOf((double) MovementUtil.getMoveYaw());
return LuaValue.valueOf(MovementUtil.getMoveYaw());
}
});
set(
Expand All @@ -55,7 +55,7 @@ public LuaValue call() {
new ZeroArgFunction() {
@Override
public LuaValue call() {
return LuaValue.valueOf((double) MovementUtil.getSpeed());
return LuaValue.valueOf(MovementUtil.getSpeed());
}
});
set(
Expand Down Expand Up @@ -84,7 +84,7 @@ public LuaValue call(LuaValue speedValue, LuaValue strafePercentage) {
return LuaValue.NIL;
}
});
set("SPRINT_SPEED", LuaValue.valueOf((double) MovementUtil.SPRINT_SPEED));
set("WALK_SPEED", LuaValue.valueOf((double) MovementUtil.WALK_SPEED));
set("SPRINT_SPEED", LuaValue.valueOf(MovementUtil.SPRINT_SPEED));
set("WALK_SPEED", LuaValue.valueOf(MovementUtil.WALK_SPEED));
}
}
23 changes: 12 additions & 11 deletions src/main/java/dev/thoq/module/modules/clickgui/ClickGUIScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public final class ClickGUIScreen extends GuiScreen {
private static final int SETTING_GROUP_PADDING = 2;
private static final int PANEL_SPACING = 130;
private static final int SETTING_INDENT = 6;
private static final int CATEGORY_PANEL_BACKGROUND_COLOR = 0xFF1A181A;
private static final int BACKGROUND_COLOR = 0xFF181A17;
private static final int MODULE_BACKGROUND_COLOR = 0xFF232623;
private static final int SETTING_BACKGROUND_COLOR = 0xFF111311;
Expand All @@ -47,10 +48,10 @@ 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 int BOTTOM_PANEL_SPACING = 2;
private static final int PANEL_PADDING = 1;

private static final AlyaFontRenderer font = new AlyaFontRenderer("client/fonts/Lato-Bold.ttf", 7.5F);
private static final AlyaFontRenderer boldFont = new AlyaFontRenderer("client/fonts/Lato-Bold.ttf", 7.5F);
private static final AlyaFontRenderer settingsFont = new AlyaFontRenderer("client/fonts/Lato-Bold.ttf", 6.5F);
private static final Map<Category, Integer> CATEGORY_COLORS = new HashMap<>();

Expand Down Expand Up @@ -150,20 +151,20 @@ private void renderCategoryPanel(final Category category, final int mouseX, fina
}
int totalHeight = PANEL_HEIGHT;
if(expandedCategories.get(category)) {
totalHeight += calculateExpandedHeight(modules) + 1 + PANEL_PADDING / 2;
totalHeight += calculateExpandedHeight(modules) + 1 + PANEL_PADDING;
}
renderPanelHeader(category, panelX, panelY);
if(expandedCategories.get(category)) {
RenderUtility.drawRect(panelX, panelY + PANEL_HEIGHT, PANEL_WIDTH, totalHeight - PANEL_HEIGHT, BACKGROUND_COLOR);
RenderUtility.drawRect(panelX, panelY + PANEL_HEIGHT, PANEL_WIDTH, totalHeight - PANEL_HEIGHT, CATEGORY_PANEL_BACKGROUND_COLOR);
renderExpandedModules(modules, panelX, panelY + PANEL_HEIGHT, category, mouseX, mouseY);
}
RenderUtility.drawRectOutline(panelX, panelY, PANEL_WIDTH, totalHeight, getCategoryColor(category), BORDER_WIDTH);
}

private void renderPanelHeader(final Category category, final int panelX, final int panelY) {
RenderUtility.drawRect(panelX, panelY, PANEL_WIDTH, PANEL_HEIGHT, BACKGROUND_COLOR);
RenderUtility.drawRect(panelX, panelY, PANEL_WIDTH, PANEL_HEIGHT, CATEGORY_PANEL_BACKGROUND_COLOR);
final String categoryName = category.getDisplayName().toLowerCase();
font.drawString(categoryName, panelX + 4 + PANEL_PADDING, panelY + 5, TEXT_COLOR);
boldFont.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;
Expand Down Expand Up @@ -280,7 +281,7 @@ private void renderModuleButton(
final String moduleName = module.getName().toLowerCase().replace(" ", "");
final int textColor =
extended ? (module.isEnabled() ? getCategoryColor(category) : TEXT_COLOR) : TEXT_COLOR;
font.drawString(moduleName, positionX + 4, positionY + 5, textColor);
boldFont.drawString(moduleName, positionX + 4, positionY + 5, textColor);
}

private void renderSettingButton(
Expand Down Expand Up @@ -314,7 +315,7 @@ private void renderSettingButton(
RenderUtility.drawRect(settingX, positionY, settingWidth, SETTING_HEIGHT, dimColor(SETTING_BACKGROUND_COLOR, HOVER_DIM));
}
settingsFont.drawString(setting.getName(), textX, positionY + 1, TEXT_COLOR);
final String modeValue = modeSetting.getValue();
final String modeValue = modeSetting.getValue().toUpperCase().replace(" ", "_");
final float modeWidth = settingsFont.getStringWidth(modeValue);
settingsFont.drawString(modeValue, settingRight - modeWidth - 2, positionY + 1, TEXT_COLOR);
} else if(setting instanceof NumberSetting numberSetting) {
Expand Down Expand Up @@ -433,7 +434,7 @@ private void renderBottomPanel(
final int mouseY,
final boolean isScripts) {
RenderUtility.drawRect(panelX, panelY, PANEL_WIDTH, PANEL_HEIGHT, BACKGROUND_COLOR);
font.drawString(title, panelX + 4 + PANEL_PADDING, panelY + 5, TEXT_COLOR);
boldFont.drawString(title, panelX + 4 + PANEL_PADDING, panelY + 5, TEXT_COLOR);

int iconX = panelX + PANEL_WIDTH - BOTTOM_ICON_SIZE - 3 - PANEL_PADDING;
final int iconY = panelY + (PANEL_HEIGHT - BOTTOM_ICON_SIZE) / 2;
Expand Down Expand Up @@ -476,7 +477,7 @@ private void renderBottomPanel(
RenderUtility.drawRect(panelX + PANEL_PADDING, entryY, PANEL_WIDTH - PANEL_PADDING * 2, MODULE_HEIGHT, bgColor);
}

font.drawString(entry, panelX + PANEL_PADDING + 4, entryY + 5, TEXT_COLOR);
boldFont.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]);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/dev/thoq/util/movement/MovementUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public static void setSpeed(final double speed) {

public static void setSpeed(final double speed, double strafePercentage) {
strafePercentage /= 100;
strafePercentage = Math.min(1, Math.max(0, strafePercentage));
strafePercentage = Math.clamp(strafePercentage, 0, 1);
if(!isMoving()) return;
final double currentSpeed = getMoveSpeed();
if(currentSpeed == 0) {
Expand Down
Loading
Loading