Files
src
build.gradle
gradle.properties
settings.gradle
Code
5 126
src/main/java/com/kodari/seedobserver/SeedObserverClient.java
package com.kodari.seedobserver;
import java.util.HashSet;
import java.util.Set;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.command.v2.ClientCommandManager;
import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.minecraft.text.Text;
import net.minecraft.util.math.BlockPos;
public final class SeedObserverClient implements ClientModInitializer {
private static final int MAX_OBSERVATIONS = 4096;
private final Set<BlockPos> positions = new HashSet<>();
private final Set<Object> biomes = new HashSet<>();
private Object observedWorld;
@Override
public void onInitializeClient() {
ClientTickEvents.END_CLIENT_TICK.register(client -> {
if (client.world != observedWorld) {
observedWorld = client.world;
positions.clear();
biomes.clear();
}
if (client.world == null || client.player == null || positions.size() >= MAX_OBSERVATIONS) {
return;
}
BlockPos playerPos = client.player.getBlockPos();
BlockPos samplePos = new BlockPos(
Math.floorDiv(playerPos.getX(), 4) * 4,
Math.floorDiv(playerPos.getY(), 4) * 4,
Math.floorDiv(playerPos.getZ(), 4) * 4);
if (positions.add(samplePos)) {
biomes.add(client.world.getBiome(samplePos).value());
}
});
ClientCommandRegistrationCallback.EVENT.register((dispatcher, registryAccess) ->
dispatcher.register(ClientCommandManager.literal("getseed")
.executes(context -> {
context.getSource().sendFeedback(Text.literal(
"Insufficient evidence to infer a world seed. Observed "
+ positions.size() + " biome positions across " + biomes.size()
+ " biome types in this dimension."));
context.getSource().sendFeedback(Text.literal(
"Biome observations alone do not establish a unique seed; "
+ "this mod does not currently implement seed recovery."));
return 1;
})));
}
}