Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AutoTorch #377

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
- AutoLogin
- AutoPot (Taken from an [unmerged PR](https://github.com/MeteorDevelopment/meteor-client/pull/274))
- AutoSoup (Ported from [Wurst](https://github.com/Wurst-Imperium/Wurst7/tree))
- AutoTorch
- AutoTNT
- AutoWither (Taken from an [unmerged PR](https://github.com/MeteorDevelopment/meteor-client/pull/1070))
- BlockIn
Expand Down
1 change: 1 addition & 0 deletions src/main/java/anticope/rejects/MeteorRejectsAddon.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public void onInitialize() {
modules.add(new AutoLogin());
modules.add(new AutoPot());
modules.add(new AutoSoup());
modules.add(new AutoTorch());
modules.add(new AutoTNT());
modules.add(new AutoWither());
modules.add(new BoatGlitch());
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/anticope/rejects/modules/AutoFarm.java
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ private boolean till(BlockPos pos, Block block) {
block == Blocks.ROOTED_DIRT;
if (moist && tillable && mc.world.getBlockState(pos.up()).isAir()) {
FindItemResult hoe = InvUtils.findInHotbar(itemStack -> itemStack.getItem() instanceof HoeItem);
return WorldUtils.interact(pos, hoe, rotate.get());
return WorldUtils.interact(pos, hoe, rotate.get(), true);
}
return false;
}
Expand Down Expand Up @@ -245,7 +245,7 @@ private boolean bonemeal(BlockPos pos, BlockState state, Block block) {
if (isMature(state, block)) return false;

FindItemResult bonemeal = InvUtils.findInHotbar(Items.BONE_MEAL);
return WorldUtils.interact(pos, bonemeal, rotate.get());
return WorldUtils.interact(pos, bonemeal, rotate.get(), true);
}

private boolean isWaterNearby(WorldView world, BlockPos pos) {
Expand Down
75 changes: 75 additions & 0 deletions src/main/java/anticope/rejects/modules/AutoTorch.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
package anticope.rejects.modules;

import anticope.rejects.MeteorRejectsAddon;
import anticope.rejects.utils.WorldUtils;
import meteordevelopment.meteorclient.events.world.TickEvent;
import meteordevelopment.meteorclient.settings.*;
import meteordevelopment.meteorclient.systems.modules.Module;
import meteordevelopment.meteorclient.utils.player.ChatUtils;
import meteordevelopment.meteorclient.utils.player.FindItemResult;
import meteordevelopment.meteorclient.utils.player.InvUtils;
import meteordevelopment.orbit.EventHandler;
import net.minecraft.item.Item;
import net.minecraft.item.Items;
import net.minecraft.text.Text;
import net.minecraft.world.LightType;

import java.util.List;

//TODO: add setting for replaceable blocks
public class AutoTorch extends Module {

private final SettingGroup sgGeneral = settings.getDefaultGroup();

private final Setting<List<Item>> torches = sgGeneral.add(new ItemListSetting.Builder()
.name("torch-type")
.description("The type of torches to use.")
.defaultValue(Items.TORCH)
.filter(this::torchFilter)
.build()
);

private final Setting<Integer> lightLevel = sgGeneral.add(new IntSetting.Builder()
.name("light-level")
.description("At what light level and below to place torches.")
.defaultValue(7)
.min(0)
.sliderMax(15)
.build()
);

public AutoTorch() {super(MeteorRejectsAddon.CATEGORY, "auto-torch", "Automatically places torches where you stand.");}

@EventHandler
private void onTick(TickEvent.Pre event) {
if (torches.get().isEmpty() || mc.player == null || mc.world == null) return;

boolean torchFound = false;

for (int i = 0; i < torches.get().size(); i++) {
FindItemResult findItemResult = InvUtils.findInHotbar(torches.get().get(i));

if (findItemResult.found()) {
torchFound = true;

if (mc.world.getLightLevel(LightType.BLOCK, mc.player.getBlockPos()) <= lightLevel.get()) {
WorldUtils.interact(mc.player.getBlockPos(), findItemResult, false, false);
return;
}
}
}

if (!torchFound) {
ChatUtils.sendMsg(Text.of("No torches found in hotbar."));
toggle();
}
}


private boolean torchFilter(Item item) {
return item == Items.TORCH ||
item == Items.REDSTONE_TORCH ||
item == Items.SOUL_TORCH;
}

}
2 changes: 1 addition & 1 deletion src/main/java/anticope/rejects/modules/MossBot.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ private void onTick(TickEvent.Pre event) {
mc.interactionManager.updateBlockBreakingProgress(bestBlock.up(), Direction.UP);
}

WorldUtils.interact(bestBlock, findItemResult, rotate.get());
WorldUtils.interact(bestBlock, findItemResult, rotate.get(), true);
mossMap.put(bestBlock, 100);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/anticope/rejects/utils/WorldUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@ public static double distanceBetween(BlockPos pos1, BlockPos pos2) {
return MathHelper.sqrt((float) (d * d + e * e + f * f));
}

public static boolean interact(BlockPos pos, FindItemResult findItemResult, boolean rotate) {
public static boolean interact(BlockPos pos, FindItemResult findItemResult, boolean rotate, boolean swingHand) {
if (!findItemResult.found()) return false;
Runnable action = () -> {
boolean wasSneaking = mc.player.input.sneaking;
mc.player.input.sneaking = false;
InvUtils.swap(findItemResult.slot(), true);
mc.interactionManager.interactBlock(mc.player, Hand.MAIN_HAND, new BlockHitResult(Vec3d.ofCenter(pos), Direction.UP, pos, false));
mc.player.swingHand(Hand.MAIN_HAND);
if (swingHand) {mc.player.swingHand(Hand.MAIN_HAND);}
InvUtils.swapBack();
mc.player.input.sneaking = wasSneaking;
};
Expand Down
Loading