auto-nametag module

auto-nametag: Minecraft 26.3 cheat module, full source for every implementation (1 client: Meteor Client).

1 implementationWorld

Clients with this module

Full module source: 1 implementation

Every implementation below is the complete module file, verbatim. Expand a client to read its code.

Meteor ClientWorldsrc/main/java/meteordevelopment/meteorclient/systems/modules/world/AutoNametag.javaJava · 138 lines · 4.8 KB

Automatically uses nametags on entities without a nametag. WILL nametag ALL entities in the specified distance.

Settingsentitiesrangepriorityrenametagrotate
AutoNametag.javaJava · Minecraft 26.2 · 138 lines · 4.8 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Meteor Client distribution (https://github.com/MeteorDevelopment/meteor-client).
3
 * Copyright (c) Meteor Development.
4
 */
5
6
package meteordevelopment.meteorclient.systems.modules.world;
7
8
import it.unimi.dsi.fastutil.objects.Object2IntMap;
9
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
10
import meteordevelopment.meteorclient.events.world.TickEvent;
11
import meteordevelopment.meteorclient.settings.*;
12
import meteordevelopment.meteorclient.systems.modules.Categories;
13
import meteordevelopment.meteorclient.systems.modules.Module;
14
import meteordevelopment.meteorclient.utils.entity.SortPriority;
15
import meteordevelopment.meteorclient.utils.entity.TargetUtils;
16
import meteordevelopment.meteorclient.utils.player.FindItemResult;
17
import meteordevelopment.meteorclient.utils.player.InvUtils;
18
import meteordevelopment.meteorclient.utils.player.PlayerUtils;
19
import meteordevelopment.meteorclient.utils.player.Rotations;
20
import meteordevelopment.orbit.EventHandler;
21
import net.minecraft.world.InteractionHand;
22
import net.minecraft.world.entity.Entity;
23
import net.minecraft.world.entity.EntityType;
24
import net.minecraft.world.item.Items;
25
import net.minecraft.world.phys.EntityHitResult;
26
27
import java.util.Iterator;
28
import java.util.Set;
29
30
public class AutoNametag extends Module {
31
    private final SettingGroup sgGeneral = settings.getDefaultGroup();
32
33
    private final Setting<Set<EntityType<?>>> entities = sgGeneral.add(new EntityTypeListSetting.Builder()
34
        .name("entities")
35
        .description("Which entities to nametag.")
36
        .build()
37
    );
38
39
    private final Setting<Double> range = sgGeneral.add(new DoubleSetting.Builder()
40
        .name("range")
41
        .description("The maximum range an entity can be to be nametagged.")
42
        .defaultValue(5)
43
        .min(0)
44
        .sliderMax(6)
45
        .build()
46
    );
47
48
    private final Setting<SortPriority> priority = sgGeneral.add(new EnumSetting.Builder<SortPriority>()
49
        .name("priority")
50
        .description("Priority sort")
51
        .defaultValue(SortPriority.LowestDistance)
52
        .build()
53
    );
54
55
    private final Setting<Boolean> renametag = sgGeneral.add(new BoolSetting.Builder()
56
        .name("renametag")
57
        .description("Allows already nametagged entities to be renamed.")
58
        .defaultValue(true)
59
        .build()
60
    );
61
62
    private final Setting<Boolean> rotate = sgGeneral.add(new BoolSetting.Builder()
63
        .name("rotate")
64
        .description("Automatically faces towards the mob being nametagged.")
65
        .defaultValue(true)
66
        .build()
67
    );
68
69
    private final Object2IntMap<Entity> entityCooldowns = new Object2IntOpenHashMap<>();
70
71
    private Entity target;
72
    private boolean offHand;
73
74
    public AutoNametag() {
75
        super(Categories.World, "auto-nametag", "Automatically uses nametags on entities without a nametag. WILL nametag ALL entities in the specified distance.");
76
    }
77
78
    @Override
79
    public void onDeactivate() {
80
        entityCooldowns.clear();
81
    }
82
83
    @EventHandler
84
    private void onTickPre(TickEvent.Pre event) {
85
        // Find nametag in hotbar
86
        FindItemResult findNametag = InvUtils.findInHotbar(Items.NAME_TAG);
87
88
        if (!findNametag.found()) {
89
            error("No Nametag in Hotbar");
90
            toggle();
91
            return;
92
        }
93
94
        // Target
95
        target = TargetUtils.get(entity -> {
96
            if (!PlayerUtils.isWithin(entity, range.get())) return false;
97
            if (!entities.get().contains(entity.getType())) return false;
98
99
            if (entity.hasCustomName() && (!renametag.get() || entity.getCustomName().equals(mc.player.getInventory().getItem(findNametag.slot()).getDisplayName())))
100
                return false;
101
102
            return entityCooldowns.getInt(entity) <= 0;
103
        }, priority.get());
104
105
        if (target == null)
106
            return;
107
108
        // Swapping slots
109
        InvUtils.swap(findNametag.slot(), true);
110
111
        offHand = findNametag.isOffhand();
112
113
        // Interaction
114
        if (rotate.get()) Rotations.rotate(Rotations.getYaw(target), Rotations.getPitch(target), -100, this::interact);
115
        else interact();
116
    }
117
118
    @EventHandler
119
    private void onTickPost(TickEvent.Post event) {
120
        for (Iterator<Entity> it = entityCooldowns.keySet().iterator(); it.hasNext(); ) {
121
            Entity entity = it.next();
122
            int cooldown = entityCooldowns.getInt(entity) - 1;
123
124
            if (cooldown <= 0) it.remove();
125
            else entityCooldowns.put(entity, cooldown);
126
        }
127
    }
128
129
    private void interact() {
130
        InteractionHand hand = offHand ? InteractionHand.OFF_HAND : InteractionHand.MAIN_HAND;
131
        EntityHitResult location = new EntityHitResult(target, target.getBoundingBox().getCenter());
132
        mc.gameMode.interact(mc.player, target, location, hand);
133
        InvUtils.swapBack();
134
135
        entityCooldowns.put(target, 20);
136
    }
137
}
138