From 097e5ac57fca11ac5c45419dc691b0900933d17d Mon Sep 17 00:00:00 2001 From: 0xTas Date: Sun, 7 Apr 2024 09:45:23 -0700 Subject: [PATCH] Honker - No longer spams horns when nobody's around. - unless of course you enable the new 'When Alone' option. Go ahead, I won't judge. --- .../java/dev/stardust/modules/Honker.java | 35 ++++++++++++++++--- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/src/main/java/dev/stardust/modules/Honker.java b/src/main/java/dev/stardust/modules/Honker.java index f4688fc..8451126 100644 --- a/src/main/java/dev/stardust/modules/Honker.java +++ b/src/main/java/dev/stardust/modules/Honker.java @@ -4,7 +4,6 @@ import dev.stardust.Stardust; import net.minecraft.util.Hand; import net.minecraft.item.Item; -import net.minecraft.item.Items; import net.minecraft.entity.Entity; import net.minecraft.nbt.NbtElement; import net.minecraft.item.ItemStack; @@ -15,6 +14,7 @@ import meteordevelopment.orbit.EventHandler; import it.unimi.dsi.fastutil.ints.IntArrayList; import net.minecraft.entity.player.PlayerEntity; +import meteordevelopment.meteorclient.utils.Utils; import net.minecraft.client.network.PlayerListEntry; import meteordevelopment.meteorclient.settings.Setting; import net.minecraft.client.network.ClientPlayerEntity; @@ -60,7 +60,17 @@ public Honker() { .name("Horn Spam") .description("Spam the desired horn as soon as it's done cooling down (every 7 seconds.)") .defaultValue(false) - .onChanged(it -> {if (it) honkDesiredHorn();}) + .onChanged(it -> { if (it) this.ticksSinceUsedHorn = 420; }) + .build() + ); + + private final Setting hornSpamAlone = settings.getDefaultGroup().add( + new BoolSetting.Builder() + .name("When Alone") + .description("If you really want to, I guess..") + .defaultValue(false) + .visible(hornSpam::get) + .onChanged(it -> { if (it) this.ticksSinceUsedHorn = 420; }) .build() ); @@ -147,6 +157,10 @@ public void onActivate() { for (Entity entity : mc.world.getEntities()) { if (entity instanceof PlayerEntity && !(entity instanceof ClientPlayerEntity)) { + if (ignoreFakes.get()) { + Collection players = mc.player.networkHandler.getPlayerList(); + if (players.stream().noneMatch(entry -> entry.getProfile().getId().equals(entity.getUuid()))) continue; + } honkDesiredHorn(); break; } @@ -174,10 +188,23 @@ private void onEntityAdd(EntityAddedEvent event) { @EventHandler private void onTick(TickEvent.Post event) { - if (!hornSpam.get() || mc.player == null) return; + if (!hornSpam.get() || mc.player == null || mc.world == null) return; + + boolean playerNearby = false; + for (Entity entity : mc.world.getEntities()) { + if (entity instanceof PlayerEntity && !(entity instanceof ClientPlayerEntity)) { + if (ignoreFakes.get()) { + Collection players = mc.player.networkHandler.getPlayerList(); + if (players.stream().noneMatch(entry -> entry.getProfile().getId().equals(entity.getUuid()))) continue; + } + playerNearby = true; + break; + } + } + if (!playerNearby && !hornSpamAlone.get()) return; Item activeItem = mc.player.getActiveItem().getItem(); - if (activeItem.isFood() || activeItem == Items.BOW || activeItem == Items.TRIDENT && mc.mouse.wasRightButtonClicked()) return; + if (activeItem.isFood() || Utils.isThrowable(activeItem) && mc.player.getItemUseTime() > 0) return; ++ticksSinceUsedHorn; if (ticksSinceUsedHorn > 150) {