Skip to content

Commit d6e888a

Browse files
committed
More lua api
1 parent 7f3eedc commit d6e888a

7 files changed

Lines changed: 364 additions & 192 deletions

File tree

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package com.nekiplay.hypixelcry.utils;
2+
3+
import net.minecraft.screen.slot.SlotActionType;
4+
5+
import static com.nekiplay.hypixelcry.HypixelCry.mc;
6+
7+
public class InventoryUtils {
8+
public static void clickSlotWithId(int slotId, int button, SlotActionType actionType, int syncId) {
9+
if (mc.interactionManager != null && mc.player != null) {
10+
mc.interactionManager.clickSlot(syncId, slotId, button, actionType, mc.player);
11+
}
12+
}
13+
14+
public static void clickContainerSlot(int slot, int button, SlotActionType actionType) {
15+
if (mc.player != null && mc.player.currentScreenHandler != null) {
16+
clickSlotWithId(slot, button, actionType, mc.player.currentScreenHandler.syncId);
17+
}
18+
}
19+
20+
public static void clickSlot(int slot, int button, SlotActionType actionType) {
21+
if (mc.player != null && mc.player.playerScreenHandler != null) {
22+
clickSlotWithId(slot, button, actionType, mc.player.playerScreenHandler.syncId);
23+
}
24+
}
25+
26+
public static void swapSlots(int slot, int hotbarSlot) {
27+
if (mc.player != null && mc.player.playerScreenHandler != null) {
28+
clickSlotWithId(slot, hotbarSlot, SlotActionType.SWAP, mc.player.playerScreenHandler.syncId);
29+
}
30+
}
31+
32+
// Дополнительные полезные методы
33+
public static void leftClickSlot(int slot) {
34+
clickSlot(slot, 0, SlotActionType.PICKUP);
35+
}
36+
37+
public static void rightClickSlot(int slot) {
38+
clickSlot(slot, 1, SlotActionType.PICKUP);
39+
}
40+
41+
public static void dropSlot(int slot) {
42+
clickSlot(slot, 0, SlotActionType.THROW);
43+
}
44+
45+
public static void dropAllFromSlot(int slot) {
46+
clickSlot(slot, 1, SlotActionType.THROW);
47+
}
48+
}

src/main/kotlin/com/nekiplay/hypixelcry/features/commands/impl/LuaCommand.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,10 @@ object LuaCommand {
9090
val loaded = luaManager.unloadScript(scriptFile.nameWithoutExtension)
9191
val result = luaManager.executeScript(scriptFile)
9292
if (!loaded) {
93-
source.sendFeedback(Text.literal("§aScript '${scriptFile.name}' executed successfully, result: '${result}'"))
93+
source.sendFeedback(Text.literal("§aScript '${scriptFile.nameWithoutExtension}' executed successfully, result: '${result}'"))
9494
}
9595
else {
96-
source.sendFeedback(Text.literal("§aScript '${scriptFile.name}' restarted successfully, result: '${result}'"))
96+
source.sendFeedback(Text.literal("§aScript '${scriptFile.nameWithoutExtension}' restarted successfully, result: '${result}'"))
9797
}
9898
} catch (e: Exception) {
9999
source.sendFeedback(Text.literal("§cScript execution error: ${e.message}"))
@@ -105,8 +105,8 @@ object LuaCommand {
105105
val luaManager = HypixelCry.LUA_MANAGER
106106
// Remove either .lua or .luac extension for script name
107107
val scriptName = when {
108-
filename.endsWith(".luac") -> filename.removeSuffix(".luac")
109108
filename.endsWith(".lua") -> filename.removeSuffix(".lua")
109+
filename.endsWith(".luac") -> filename.removeSuffix(".luac")
110110
else -> filename
111111
}
112112

0 commit comments

Comments
 (0)