ActiveSpawner module

ActiveSpawner: Minecraft 26.3 cheat module, full source for every implementation (1 client: Nicotine).

1 implementationRender

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.

NicotineRendersrc/client/java/nicotine/mod/mods/render/ActiveSpawner.javaJava · 73 lines · 2.8 KB

Shows active spawners for stash hunting

ActiveSpawner.javaJava · Minecraft 26.3 · 73 lines · 2.8 KB · complete file, verbatimOriginal ↗
1
package nicotine.mod.mods.render;
2
3
import net.minecraft.core.BlockPos;
4
import net.minecraft.sounds.SoundEvents;
5
import net.minecraft.sounds.SoundSource;
6
import net.minecraft.util.CommonColors;
7
import net.minecraft.world.level.BaseSpawner;
8
import net.minecraft.world.level.block.entity.BlockEntity;
9
import net.minecraft.world.level.block.entity.SpawnerBlockEntity;
10
import net.minecraft.world.phys.Vec3;
11
import nicotine.events.ClientLevelTickEvent;
12
import nicotine.events.RenderEvent;
13
import nicotine.mixininterfaces.IBaseSpawner;
14
import nicotine.mod.Mod;
15
import nicotine.mod.ModCategory;
16
import nicotine.util.BlockEntityUtil;
17
import nicotine.util.EventBus;
18
import nicotine.util.Message;
19
import nicotine.util.Player;
20
import nicotine.util.render.Render3D;
21
import nicotine.util.math.BoxUtil;
22
23
import java.util.ArrayList;
24
import java.util.List;
25
26
import static nicotine.util.Common.*;
27
28
public class ActiveSpawner extends Mod {
29
    public static List<BlockPos> activeSpawners = new ArrayList<>();
30
31
    public ActiveSpawner() {
32
        super(ModCategory.Render, "ActiveSpawner", "Shows active spawners for stash hunting");
33
    }
34
35
    @Override
36
    protected void init() {
37
        EventBus.register(ClientLevelTickEvent.class, event -> {
38
            if (!this.enabled)
39
                return true;
40
41
            for (BlockEntity blockEntity : BlockEntityUtil.getBlockEntities()) {
42
                if (blockEntity instanceof SpawnerBlockEntity spawnerBlockEntity) {
43
                    BaseSpawner mobSpawnerLogic = spawnerBlockEntity.getSpawner();
44
                    if (((IBaseSpawner)mobSpawnerLogic).getSpawnDelay() != 20) {
45
                        if (!activeSpawners.contains(spawnerBlockEntity.getBlockPos())) {
46
                            Message.sendInfo(String.format("Found an active spawner at %d %d %d!",
47
                                    spawnerBlockEntity.getBlockPos().getX(), spawnerBlockEntity.getBlockPos().getY(), spawnerBlockEntity.getBlockPos().getZ())
48
                            );
49
                            mc.level.playLocalSound(mc.player.blockPosition(), SoundEvents.PLAYER_LEVELUP, SoundSource.PLAYERS, 1.0f, 1.0f, false);
50
                            activeSpawners.add(spawnerBlockEntity.getBlockPos());
51
                        }
52
                    }
53
                } 
54
            }
55
            
56
            return true;
57
        });
58
        
59
        EventBus.register(RenderEvent.class, event -> {
60
            if (!this.enabled)
61
                return true;
62
            
63
            for (BlockPos blockPos : activeSpawners) {
64
                if (Player.isPositionInRenderDistance(Vec3.atCenterOf(blockPos))) {
65
                    Render3D.drawFilledBox(event.submitNodeStorage, event.camera, event.matrixStack, BoxUtil.getBlockBoundingBoxf(blockPos), CommonColors.GREEN);
66
                }
67
            }
68
            
69
            return true;
70
        });
71
    }
72
}
73