From 1cfee4cf0704674a87627f01cac49e528bf9d40e Mon Sep 17 00:00:00 2001 From: cqb13 Date: Sat, 17 Aug 2024 22:17:22 -0400 Subject: [PATCH] Raid Captain Detector --- src/main/java/cqb13/NumbyHack/NumbyHack.java | 1 + .../modules/general/RaidCaptainNotifier.java | 64 +++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 src/main/java/cqb13/NumbyHack/modules/general/RaidCaptainNotifier.java diff --git a/src/main/java/cqb13/NumbyHack/NumbyHack.java b/src/main/java/cqb13/NumbyHack/NumbyHack.java index 92b3bf3..ab0a089 100644 --- a/src/main/java/cqb13/NumbyHack/NumbyHack.java +++ b/src/main/java/cqb13/NumbyHack/NumbyHack.java @@ -57,6 +57,7 @@ public void onInitialize() { Modules.get().add(new NewChunks()); Modules.get().add(new NoStrip()); Modules.get().add(new Number81()); + Modules.get().add(new RaidCaptainNotifier()); Modules.get().add(new RideStats()); Modules.get().add(new SafeFire()); Modules.get().add(new SafetyNet()); diff --git a/src/main/java/cqb13/NumbyHack/modules/general/RaidCaptainNotifier.java b/src/main/java/cqb13/NumbyHack/modules/general/RaidCaptainNotifier.java new file mode 100644 index 0000000..4aa0152 --- /dev/null +++ b/src/main/java/cqb13/NumbyHack/modules/general/RaidCaptainNotifier.java @@ -0,0 +1,64 @@ +package cqb13.NumbyHack.modules.general; + +import cqb13.NumbyHack.NumbyHack; +import meteordevelopment.meteorclient.events.world.TickEvent; +import meteordevelopment.meteorclient.settings.BoolSetting; +import meteordevelopment.meteorclient.settings.Setting; +import meteordevelopment.meteorclient.settings.SettingGroup; +import meteordevelopment.meteorclient.systems.modules.Module; +import meteordevelopment.meteorclient.utils.player.ChatUtils; +import meteordevelopment.orbit.EventHandler; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityType; +import net.minecraft.entity.mob.PillagerEntity; +import net.minecraft.nbt.NbtCompound; + +import java.util.HashSet; +import java.util.Set; +import java.util.UUID; + +public class RaidCaptainNotifier extends Module { + private final SettingGroup sgGeneral = settings.getDefaultGroup(); + + private final Setting location = sgGeneral.add(new BoolSetting.Builder() + .name("location") + .description("Includes coordinates in the notification.") + .defaultValue(false) + .build() + ); + + private final Set checkedPillagers = new HashSet<>(); + + public RaidCaptainNotifier() { + super(NumbyHack.CATEGORY, "Raid Captain Notifier", "Notifies you when a raid captain spawns, good for waiting in outposts on bad servers."); + } + + @EventHandler + private void onTick(TickEvent.Pre event) { + if (mc.world == null) return; + + for (Entity entity : mc.world.getEntities()) { + if (entity instanceof PillagerEntity) { + PillagerEntity pillager = (PillagerEntity) entity; + UUID pillagerId = pillager.getUuid(); + + if (checkedPillagers.contains(pillagerId)) continue; + + NbtCompound nbtData = pillager.writeNbt(new NbtCompound()); + String nbtString = nbtData.asString(); + + //TODO: Improve this when not lazy + if (nbtString.contains("translate\":\"block.minecraft.ominous_banner")) { + System.out.println(nbtData); + if (location.get()) { + ChatUtils.info("Raid Captain Spawned at " + pillager.getBlockX() + ", " + pillager.getBlockY() + ", " + pillager.getBlockZ() + "!"); + } else { + ChatUtils.info("Raid Captain Spawned!"); + } + + checkedPillagers.add(pillagerId); + } + } + } + } +}