Skip to content

Commit

Permalink
Fix auto clicker not working while windows are open
Browse files Browse the repository at this point in the history
  • Loading branch information
Toshimichi0915 committed Dec 27, 2024
1 parent 0a17672 commit 27bc663
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ static int getFps() {
@Accessor("resourceReloadLogger")
ResourceReloadLogger getResourceReloadLogger();

@Accessor("attackCooldown")
int getAttackCooldown();

@Accessor("attackCooldown")
void setAttackCooldown(int attackCooldown);

@Invoker("doAttack")
boolean leftClick();

Expand Down
12 changes: 9 additions & 3 deletions src/main/java/meteordevelopment/meteorclient/utils/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -252,8 +252,7 @@ public static void getItemsInContainerItem(ItemStack itemStack, ItemStack[] item
for (int i = 0; i < stacks.size(); i++) {
if (i >= 0 && i < items.length) items[i] = stacks.get(i);
}
}
else if (components.contains(DataComponentTypes.BLOCK_ENTITY_DATA)) {
} else if (components.contains(DataComponentTypes.BLOCK_ENTITY_DATA)) {
NbtComponent nbt2 = components.get(DataComponentTypes.BLOCK_ENTITY_DATA);

if (nbt2.contains("Items")) {
Expand All @@ -262,7 +261,8 @@ else if (components.contains(DataComponentTypes.BLOCK_ENTITY_DATA)) {
for (int i = 0; i < nbt3.size(); i++) {
int slot = nbt3.getCompound(i).getByte("Slot"); // Apparently shulker boxes can store more than 27 items, good job Mojang
// now NPEs when mc.world == null
if (slot >= 0 && slot < items.length) items[slot] = ItemStack.fromNbtOrEmpty(mc.player.getRegistryManager(), nbt3.getCompound(i));
if (slot >= 0 && slot < items.length)
items[slot] = ItemStack.fromNbtOrEmpty(mc.player.getRegistryManager(), nbt3.getCompound(i));
}
}
}
Expand Down Expand Up @@ -514,6 +514,12 @@ public static double random(double min, double max) {
}

public static void leftClick() {
// check if screens are open
int attackCooldown = ((MinecraftClientAccessor) mc).getAttackCooldown();
if (attackCooldown == 10000) {
((MinecraftClientAccessor) mc).setAttackCooldown(0);
}

mc.options.attackKey.setPressed(true);
((MinecraftClientAccessor) mc).leftClick();
mc.options.attackKey.setPressed(false);
Expand Down

0 comments on commit 27bc663

Please sign in to comment.