Skip to content

Commit

Permalink
v1.3.1 Deactivated spawner detection 4 ActivatedSpawnerDetecter
Browse files Browse the repository at this point in the history
**Deactivated Spawner Detector for the ActivatedSpawnederDetector**
- Added a detector for this which flags spawners that have light blocks within a certain radius of them
  • Loading branch information
etianl authored Dec 13, 2024
1 parent b48cef9 commit 96736a6
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 12 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ yarn_mappings=1.21.3+build.2
loader_version=0.16.9

# Mod Properties
mod_version=1.3.0-1.21.3
mod_version=1.3.1-1.21.3
maven_group=pwn.noobs
archives_base_name=1trouser-streak

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import meteordevelopment.meteorclient.utils.render.color.Color;
import meteordevelopment.meteorclient.utils.render.color.SettingColor;
import meteordevelopment.orbit.EventHandler;
import net.minecraft.block.*;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.block.entity.MobSpawnerBlockEntity;
import net.minecraft.text.Text;
Expand Down Expand Up @@ -39,6 +40,21 @@ public class ActivatedSpawnerDetector extends Module {
.defaultValue(true)
.build()
);
private final Setting<Boolean> deactivatedSpawner = sgGeneral.add(new BoolSetting.Builder()
.name("De-Activated Spawner Detector")
.description("Detects spawners with torches on them.")
.defaultValue(true)
.build()
);
public final Setting<Integer> deactivatedSpawnerdistance = sgGeneral.add(new IntSetting.Builder()
.name("Torch Scan distance")
.description("How many blocks from the spawner to look for blocks that make light")
.defaultValue(1)
.min(1)
.sliderRange(1,10)
.visible(() -> deactivatedSpawner.get())
.build()
);
public final Setting<Integer> renderDistance = sgRender.add(new IntSetting.Builder()
.name("Render-Distance(Chunks)")
.description("How many chunks from the character to render the detected chunks.")
Expand All @@ -47,6 +63,12 @@ public class ActivatedSpawnerDetector extends Module {
.sliderRange(6,1024)
.build()
);
private final Setting<Boolean> removerenderdist = sgRender.add(new BoolSetting.Builder()
.name("RemoveOutsideRenderDistance")
.description("Removes the cached chunks when they leave the defined render distance.")
.defaultValue(true)
.build()
);
private final Setting<ShapeMode> shapeMode = sgRender.add(new EnumSetting.Builder<ShapeMode>()
.name("shape-mode")
.description("How the shapes are rendered.")
Expand All @@ -67,6 +89,20 @@ public class ActivatedSpawnerDetector extends Module {
.visible(() -> (shapeMode.get() == ShapeMode.Lines || shapeMode.get() == ShapeMode.Both))
.build()
);
private final Setting<SettingColor> despawnerSideColor = sgRender.add(new ColorSetting.Builder()
.name("deactivated-spawner-side-color")
.description("Color of the spawner with torches.")
.defaultValue(new SettingColor(251, 5, 251, 70))
.visible(() -> deactivatedSpawner.get() && (shapeMode.get() == ShapeMode.Sides || shapeMode.get() == ShapeMode.Both))
.build()
);
private final Setting<SettingColor> despawnerLineColor = sgRender.add(new ColorSetting.Builder()
.name("deactivated-spawner-line-color")
.description("Color of the spawner with torches.")
.defaultValue(new SettingColor(251, 5, 251, 235))
.visible(() -> deactivatedSpawner.get() && (shapeMode.get() == ShapeMode.Lines || shapeMode.get() == ShapeMode.Both))
.build()
);
private final Setting<Boolean> rangerendering = sgRender.add(new BoolSetting.Builder()
.name("spawner-range-rendering")
.description("Renders the rough active range of a mob spawner block.")
Expand All @@ -87,25 +123,22 @@ public class ActivatedSpawnerDetector extends Module {
.visible(() -> rangerendering.get() && (shapeMode.get() == ShapeMode.Lines || shapeMode.get() == ShapeMode.Both))
.build()
);
private final Setting<Boolean> removerenderdist = sgRender.add(new BoolSetting.Builder()
.name("RemoveOutsideRenderDistance")
.description("Removes the cached chunks when they leave the defined render distance.")
.defaultValue(true)
.build()
);

private final Set<BlockPos> spawnerPositions = Collections.synchronizedSet(new HashSet<>());
private final Set<BlockPos> deactivatedSpawnerPositions = Collections.synchronizedSet(new HashSet<>());

public ActivatedSpawnerDetector() {
super(Trouser.Main,"ActivatedSpawnerDetector", "Detects if a player has been near a mob spawner in the past. May be useful for finding player made stashes in dungeons, mineshafts, and other places.");
}
@Override
public void onActivate() {
spawnerPositions.clear();
deactivatedSpawnerPositions.clear();
}
@Override
public void onDeactivate() {
spawnerPositions.clear();
deactivatedSpawnerPositions.clear();
}
@EventHandler
private void onPreTick(TickEvent.Pre event) {
Expand All @@ -122,12 +155,28 @@ private void onPreTick(TickEvent.Pre event) {
if (blockEntity instanceof MobSpawnerBlockEntity){
MobSpawnerBlockEntity spawner = (MobSpawnerBlockEntity) blockEntity;
BlockPos pos = spawner.getPos();
if (!spawnerPositions.contains(pos) && spawner.getLogic().spawnDelay != 20) {
if (!deactivatedSpawnerPositions.contains(pos) && !spawnerPositions.contains(pos) && spawner.getLogic().spawnDelay != 20) {
if (mc.world.getRegistryKey() == World.NETHER && spawner.getLogic().spawnDelay == 0) return;
if (displaycoords.get()) ChatUtils.sendMsg(Text.of("Detected Triggered Spawner! Block Position: " + pos));
else ChatUtils.sendMsg(Text.of("Detected Triggered Spawner!"));
if (displaycoords.get()) ChatUtils.sendMsg(Text.of("Detected Activated Spawner! Block Position: " + pos));
else ChatUtils.sendMsg(Text.of("Detected Activated Spawner!"));
if (extramessage.get()) error("There may be stashed items in the storage near the spawners!");
spawnerPositions.add(pos);
if (deactivatedSpawner.get()){
boolean lightsFound = false;
for (int x = -deactivatedSpawnerdistance.get(); x < deactivatedSpawnerdistance.get()+1; x++) {
for (int y = -deactivatedSpawnerdistance.get(); y < deactivatedSpawnerdistance.get()+1; y++) {
for (int z = -deactivatedSpawnerdistance.get(); z < deactivatedSpawnerdistance.get()+1; z++) {
BlockPos bpos = new BlockPos(pos.getX()+x,pos.getY()+y,pos.getZ()+z);
if (mc.world.getBlockState(bpos).getBlock() == Blocks.TORCH || mc.world.getBlockState(bpos).getBlock() == Blocks.SOUL_TORCH || mc.world.getBlockState(bpos).getBlock() == Blocks.REDSTONE_TORCH || mc.world.getBlockState(bpos).getBlock() == Blocks.JACK_O_LANTERN || mc.world.getBlockState(bpos).getBlock() == Blocks.GLOWSTONE || mc.world.getBlockState(bpos).getBlock() == Blocks.SHROOMLIGHT || mc.world.getBlockState(bpos).getBlock() == Blocks.OCHRE_FROGLIGHT || mc.world.getBlockState(bpos).getBlock() == Blocks.PEARLESCENT_FROGLIGHT || mc.world.getBlockState(bpos).getBlock() == Blocks.PEARLESCENT_FROGLIGHT || mc.world.getBlockState(bpos).getBlock() == Blocks.SEA_LANTERN || mc.world.getBlockState(bpos).getBlock() == Blocks.LANTERN || mc.world.getBlockState(bpos).getBlock() == Blocks.SOUL_LANTERN || mc.world.getBlockState(bpos).getBlock() == Blocks.CAMPFIRE || mc.world.getBlockState(bpos).getBlock() == Blocks.SOUL_CAMPFIRE){
lightsFound = true;
deactivatedSpawnerPositions.add(pos);
break;
}
}
}
}
if (lightsFound == true) ChatUtils.sendMsg(Text.of("The Spawner has torches or other light blocks!"));
}
}
}
}
Expand All @@ -148,7 +197,8 @@ private void onRender(Render3DEvent event) {
int endY = pos.getY();
int endZ = pos.getZ();
if (rangerendering.get())render(new Box(new Vec3d(startX+15, startY+15, startZ+15), new Vec3d(endX-14, endY-14, endZ-14)), rangeSideColor.get(), rangeLineColor.get(), shapeMode.get(), event);
render(new Box(new Vec3d(startX+1, startY+1, startZ+1), new Vec3d(endX, endY, endZ)), spawnerSideColor.get(), spawnerLineColor.get(), shapeMode.get(), event);
if (deactivatedSpawnerPositions.contains(pos)) render(new Box(new Vec3d(startX+1, startY+1, startZ+1), new Vec3d(endX, endY, endZ)), despawnerSideColor.get(), despawnerLineColor.get(), shapeMode.get(), event);
else render(new Box(new Vec3d(startX+1, startY+1, startZ+1), new Vec3d(endX, endY, endZ)), spawnerSideColor.get(), spawnerLineColor.get(), shapeMode.get(), event);
}
}
}
Expand All @@ -163,6 +213,7 @@ private void removeChunksOutsideRenderDistance() {
double renderDistanceBlocks = renderDistance.get() * 16;

removeChunksOutsideRenderDistance(spawnerPositions, cameraPos, renderDistanceBlocks);
removeChunksOutsideRenderDistance(deactivatedSpawnerPositions, cameraPos, renderDistanceBlocks);
}
private void removeChunksOutsideRenderDistance(Set<BlockPos> chunkSet, BlockPos cameraPos, double renderDistanceBlocks) {
chunkSet.removeIf(chunkPos -> !cameraPos.isWithinDistance(chunkPos, renderDistanceBlocks));
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"schemaVersion": 1,
"id": "streak-addon",
"version": "1.3.0",
"version": "1.3.1",
"name": "TrouserStreak",
"description": "Trouser-Streak is a compilation of modules, updated to the latest version and optimized for maximum grief. I did not make all of these.",
"authors": [
Expand Down

0 comments on commit 96736a6

Please sign in to comment.