no-interact module

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

1 implementationPlayer

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 ClientPlayersrc/main/java/meteordevelopment/meteorclient/systems/modules/player/NoInteract.javaJava · 233 lines · 8.4 KB

Blocks interactions with certain types of inputs.

Settingsblock-mineblock-mine-modeblock-interactblock-interact-modeblock-interact-handentity-hitentity-hit-modeentity-interactentity-interact-modeentity-interact-handfriendsbabiesnametagged
NoInteract.javaJava · Minecraft 26.2 · 233 lines · 8.4 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.player;
7
8
import meteordevelopment.meteorclient.events.entity.player.AttackEntityEvent;
9
import meteordevelopment.meteorclient.events.entity.player.InteractBlockEvent;
10
import meteordevelopment.meteorclient.events.entity.player.InteractEntityEvent;
11
import meteordevelopment.meteorclient.events.entity.player.StartBreakingBlockEvent;
12
import meteordevelopment.meteorclient.settings.*;
13
import meteordevelopment.meteorclient.systems.friends.Friends;
14
import meteordevelopment.meteorclient.systems.modules.Categories;
15
import meteordevelopment.meteorclient.systems.modules.Module;
16
import meteordevelopment.meteorclient.utils.misc.ListMode;
17
import meteordevelopment.orbit.EventHandler;
18
import meteordevelopment.orbit.EventPriority;
19
import net.minecraft.core.BlockPos;
20
import net.minecraft.world.InteractionHand;
21
import net.minecraft.world.entity.Entity;
22
import net.minecraft.world.entity.EntityType;
23
import net.minecraft.world.entity.animal.Animal;
24
import net.minecraft.world.entity.player.Player;
25
import net.minecraft.world.level.block.Block;
26
import net.minecraft.world.phys.BlockHitResult;
27
28
import java.util.List;
29
import java.util.Set;
30
31
public class NoInteract extends Module {
32
    private final SettingGroup sgBlocks = settings.createGroup("Blocks");
33
    private final SettingGroup sgEntities = settings.createGroup("Entities");
34
35
    // Blocks
36
37
    private final Setting<List<Block>> blockMine = sgBlocks.add(new BlockListSetting.Builder()
38
        .name("block-mine")
39
        .description("Cancels block mining.")
40
        .build()
41
    );
42
43
    private final Setting<ListMode> blockMineMode = sgBlocks.add(new EnumSetting.Builder<ListMode>()
44
        .name("block-mine-mode")
45
        .description("List mode to use for block mine.")
46
        .defaultValue(ListMode.Blacklist)
47
        .build()
48
    );
49
50
    private final Setting<List<Block>> blockInteract = sgBlocks.add(new BlockListSetting.Builder()
51
        .name("block-interact")
52
        .description("Cancels block interaction.")
53
        .build()
54
    );
55
56
    private final Setting<ListMode> blockInteractMode = sgBlocks.add(new EnumSetting.Builder<ListMode>()
57
        .name("block-interact-mode")
58
        .description("List mode to use for block interact.")
59
        .defaultValue(ListMode.Blacklist)
60
        .build()
61
    );
62
63
    private final Setting<HandMode> blockInteractHand = sgBlocks.add(new EnumSetting.Builder<HandMode>()
64
        .name("block-interact-hand")
65
        .description("Cancels block interaction if performed by this hand.")
66
        .defaultValue(HandMode.None)
67
        .build()
68
    );
69
70
    // Entities
71
72
    private final Setting<Set<EntityType<?>>> entityHit = sgEntities.add(new EntityTypeListSetting.Builder()
73
        .name("entity-hit")
74
        .description("Cancel entity hitting.")
75
        .onlyAttackable()
76
        .build()
77
    );
78
79
    private final Setting<ListMode> entityHitMode = sgEntities.add(new EnumSetting.Builder<ListMode>()
80
        .name("entity-hit-mode")
81
        .description("List mode to use for entity hit.")
82
        .defaultValue(ListMode.Blacklist)
83
        .build()
84
    );
85
86
    private final Setting<Set<EntityType<?>>> entityInteract = sgEntities.add(new EntityTypeListSetting.Builder()
87
        .name("entity-interact")
88
        .description("Cancel entity interaction.")
89
        .onlyAttackable()
90
        .build()
91
    );
92
93
    private final Setting<ListMode> entityInteractMode = sgEntities.add(new EnumSetting.Builder<ListMode>()
94
        .name("entity-interact-mode")
95
        .description("List mode to use for entity interact.")
96
        .defaultValue(ListMode.Blacklist)
97
        .build()
98
    );
99
100
    private final Setting<HandMode> entityInteractHand = sgEntities.add(new EnumSetting.Builder<HandMode>()
101
        .name("entity-interact-hand")
102
        .description("Cancels entity interaction if performed by this hand.")
103
        .defaultValue(HandMode.None)
104
        .build()
105
    );
106
107
    private final Setting<InteractMode> friends = sgEntities.add(new EnumSetting.Builder<InteractMode>()
108
        .name("friends")
109
        .description("Friends cancel mode.")
110
        .defaultValue(InteractMode.None)
111
        .build()
112
    );
113
114
    private final Setting<InteractMode> babies = sgEntities.add(new EnumSetting.Builder<InteractMode>()
115
        .name("babies")
116
        .description("Baby entity cancel mode.")
117
        .defaultValue(InteractMode.None)
118
        .build()
119
    );
120
121
    private final Setting<InteractMode> nametagged = sgEntities.add(new EnumSetting.Builder<InteractMode>()
122
        .name("nametagged")
123
        .description("Nametagged entity cancel mode.")
124
        .defaultValue(InteractMode.None)
125
        .build()
126
    );
127
128
    public NoInteract() {
129
        super(Categories.Player, "no-interact", "Blocks interactions with certain types of inputs.");
130
    }
131
132
    @EventHandler(priority = EventPriority.HIGH)
133
    private void onStartBreakingBlockEvent(StartBreakingBlockEvent event) {
134
        if (!shouldAttackBlock(event.blockPos)) event.cancel();
135
    }
136
137
    @EventHandler
138
    private void onInteractBlock(InteractBlockEvent event) {
139
        if (!shouldInteractBlock(event.result, event.hand)) event.cancel();
140
    }
141
142
    @EventHandler(priority = EventPriority.HIGH)
143
    private void onAttackEntity(AttackEntityEvent event) {
144
        if (!shouldAttackEntity(event.entity)) event.cancel();
145
    }
146
147
    @EventHandler
148
    private void onInteractEntity(InteractEntityEvent event) {
149
        if (!shouldInteractEntity(event.entity, event.hand)) event.cancel();
150
    }
151
152
    private boolean shouldAttackBlock(BlockPos blockPos) {
153
        boolean blockInList = blockMine.get().contains(mc.level.getBlockState(blockPos).getBlock());
154
        return blockMineMode.get().allows(blockInList);
155
    }
156
157
    private boolean shouldInteractBlock(BlockHitResult hitResult, InteractionHand hand) {
158
        // Hand Interactions
159
        if (blockInteractHand.get() == HandMode.Both ||
160
            (blockInteractHand.get() == HandMode.Mainhand && hand == InteractionHand.MAIN_HAND) ||
161
            (blockInteractHand.get() == HandMode.Offhand && hand == InteractionHand.OFF_HAND)) {
162
            return false;
163
        }
164
165
        // Blocks
166
        boolean blockInList = blockInteract.get().contains(mc.level.getBlockState(hitResult.getBlockPos()).getBlock());
167
        return blockInteractMode.get().allows(blockInList);
168
    }
169
170
    private boolean shouldAttackEntity(Entity entity) {
171
        // Friends
172
        if ((friends.get() == InteractMode.Both || friends.get() == InteractMode.Hit) &&
173
            entity instanceof Player player && !Friends.get().shouldAttack(player)) {
174
            return false;
175
        }
176
177
        // Babies
178
        if ((babies.get() == InteractMode.Both || babies.get() == InteractMode.Hit) &&
179
            entity instanceof Animal animal && animal.isBaby()) {
180
            return false;
181
        }
182
183
        // NameTagged
184
        if ((nametagged.get() == InteractMode.Both || nametagged.get() == InteractMode.Hit) && entity.hasCustomName())
185
            return false;
186
187
        // Entities
188
        return entityHitMode.get().allows(entityHit.get().contains(entity.getType()));
189
    }
190
191
    private boolean shouldInteractEntity(Entity entity, InteractionHand hand) {
192
        // Hand Interactions
193
        if (entityInteractHand.get() == HandMode.Both ||
194
            (entityInteractHand.get() == HandMode.Mainhand && hand == InteractionHand.MAIN_HAND) ||
195
            (entityInteractHand.get() == HandMode.Offhand && hand == InteractionHand.OFF_HAND)) {
196
            return false;
197
        }
198
199
        // Friends
200
        if ((friends.get() == InteractMode.Both || friends.get() == InteractMode.Interact) &&
201
            entity instanceof Player player && !Friends.get().shouldAttack(player)) {
202
            return false;
203
        }
204
205
        // Babies
206
        if ((babies.get() == InteractMode.Both || babies.get() == InteractMode.Interact) &&
207
            entity instanceof Animal animal && animal.isBaby()) {
208
            return false;
209
        }
210
211
        // NameTagged
212
        if ((nametagged.get() == InteractMode.Both || nametagged.get() == InteractMode.Interact) && entity.hasCustomName())
213
            return false;
214
215
        // Entities
216
        return entityInteractMode.get().allows(entityInteract.get().contains(entity.getType()));
217
    }
218
219
    public enum HandMode {
220
        Mainhand,
221
        Offhand,
222
        Both,
223
        None
224
    }
225
226
    public enum InteractMode {
227
        Hit,
228
        Interact,
229
        Both,
230
        None
231
    }
232
}
233