-
-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fef076a
commit b8fc3c7
Showing
6 changed files
with
82 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters