Skip to content

Commit

Permalink
Added an option to ignore fake players created by modules like Blink.
Browse files Browse the repository at this point in the history
This is enabled by default.
  • Loading branch information
0xTas committed Feb 11, 2024
1 parent d61e7e1 commit f0c435a
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions src/main/java/dev/stardust/modules/Honker.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package dev.stardust.modules;

import java.util.Collection;
import dev.stardust.Stardust;
import net.minecraft.util.Hand;
import net.minecraft.item.Item;
Expand All @@ -14,6 +15,7 @@
import meteordevelopment.orbit.EventHandler;
import it.unimi.dsi.fastutil.ints.IntArrayList;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.client.network.PlayerListEntry;
import meteordevelopment.meteorclient.settings.Setting;
import net.minecraft.client.network.ClientPlayerEntity;
import meteordevelopment.meteorclient.settings.BoolSetting;
Expand Down Expand Up @@ -45,6 +47,14 @@ public Honker() {
.build()
);

private final Setting<Boolean> ignoreFakes = settings.getDefaultGroup().add(
new BoolSetting.Builder()
.name("Ignore Fakes")
.description("Ignore fake players created by modules like Blink.")
.defaultValue(true)
.build()
);

private final Setting<Boolean> hornSpam = settings.getDefaultGroup().add(
new BoolSetting.Builder()
.name("Horn Spam")
Expand Down Expand Up @@ -148,9 +158,14 @@ public void onActivate() {

@EventHandler
private void onEntityAdd(EntityAddedEvent event) {
if (this.hornSpam.get()) return;
if (!(event.entity instanceof PlayerEntity)) return;
if (event.entity instanceof ClientPlayerEntity) return;
if (this.hornSpam.get() || mc.player == null) return;
if (!(event.entity instanceof PlayerEntity player)) return;
if (player instanceof ClientPlayerEntity) return;

if (ignoreFakes.get()) {
Collection<PlayerListEntry> players = mc.player.networkHandler.getPlayerList();
if (players.stream().noneMatch(entry -> entry.getProfile().getId().equals(player.getUuid()))) return;
}

if (!this.hornSpam.get()) {
honkDesiredHorn();
Expand Down

0 comments on commit f0c435a

Please sign in to comment.