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: 3 additions & 0 deletions src/main/java/dev/thoq/Alya.java
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ 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, "fucker"),
new Script(Category.PLAYER, "norotate"),
new Script(Category.PLAYER, "timer"),
new Script(Category.EXPLOIT, "disabler"),
new Script(Category.OTHER, "hackerdetector"),
Expand Down
24 changes: 21 additions & 3 deletions src/main/java/dev/thoq/lua/LuaEngine.java
Original file line number Diff line number Diff line change
@@ -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.*;
Expand Down Expand Up @@ -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",
Expand All @@ -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());
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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);
Expand Down
283 changes: 197 additions & 86 deletions src/main/java/dev/thoq/lua/api/LuaCombatApi.java

Large diffs are not rendered by default.

204 changes: 173 additions & 31 deletions src/main/java/dev/thoq/lua/api/LuaMinecraftApi.java

Large diffs are not rendered by default.

57 changes: 31 additions & 26 deletions src/main/java/dev/thoq/module/modules/clickgui/ClickGUIScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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)) {
Expand All @@ -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;
Expand All @@ -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);
Expand All @@ -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<Module> modules) {
Expand Down Expand Up @@ -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);
Expand All @@ -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;
}
Expand All @@ -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 =
Expand All @@ -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()) {
Expand Down Expand Up @@ -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],
Expand All @@ -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);
Expand All @@ -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) {
Expand All @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
Expand Down
40 changes: 20 additions & 20 deletions src/main/java/net/minecraft/client/renderer/EntityRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 _) {
}
}

Expand Down
34 changes: 34 additions & 0 deletions src/main/resources/lua/alya.d.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -447,6 +451,27 @@ 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

---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)
Expand Down Expand Up @@ -584,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
Expand All @@ -610,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
Expand Down
Loading
Loading