Created
May 22, 2017 21:21
-
-
Save haydenmuhl/834216d3c24cf3625563d65969ea0e31 to your computer and use it in GitHub Desktop.
Quick and dirty tool to find a new Minecraft spawn point
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package amidst.me; | |
import java.io.File; | |
import java.io.PrintStream; | |
import java.util.ArrayList; | |
import java.util.HashSet; | |
import java.util.List; | |
import java.util.Random; | |
import java.util.Set; | |
import amidst.mojangapi.file.directory.VersionDirectory; | |
import amidst.mojangapi.file.directory.DotMinecraftDirectory; | |
import amidst.mojangapi.minecraftinterface.MinecraftInterface; | |
import amidst.mojangapi.world.WorldType; | |
import amidst.mojangapi.world.biome.Biome; | |
import amidst.mojangapi.world.oracle.BiomeDataOracle; | |
import amidst.mojangapi.world.coordinates.CoordinatesInWorld; | |
public class Main { | |
public static PrintStream out = System.out; | |
public static final long REAL_SEED = 6028332263323738540L; | |
public static final long SEED = 12345; | |
public static final String MC_PATH = "/Users/hayden/Library/Application Support/minecraft"; | |
public static final Set<Biome> forbiddenBiomes = new HashSet<>(); | |
static { | |
forbiddenBiomes.add(Biome.ocean); | |
forbiddenBiomes.add(Biome.desert); | |
forbiddenBiomes.add(Biome.swampland); | |
forbiddenBiomes.add(Biome.river); | |
forbiddenBiomes.add(Biome.frozenOcean); | |
forbiddenBiomes.add(Biome.frozenRiver); | |
forbiddenBiomes.add(Biome.icePlains); | |
forbiddenBiomes.add(Biome.iceMountains); | |
forbiddenBiomes.add(Biome.beach); | |
forbiddenBiomes.add(Biome.desertHills); | |
forbiddenBiomes.add(Biome.deepOcean); | |
forbiddenBiomes.add(Biome.stoneBeach); | |
forbiddenBiomes.add(Biome.coldBeach); | |
forbiddenBiomes.add(Biome.coldTaiga); | |
forbiddenBiomes.add(Biome.coldTaigaHills); | |
forbiddenBiomes.add(Biome.oceanM); | |
forbiddenBiomes.add(Biome.desertM); | |
forbiddenBiomes.add(Biome.swamplandM); | |
forbiddenBiomes.add(Biome.riverM); | |
forbiddenBiomes.add(Biome.frozenOceanM); | |
forbiddenBiomes.add(Biome.frozenRiverM); | |
forbiddenBiomes.add(Biome.icePlainsSpikes); | |
forbiddenBiomes.add(Biome.iceMountainsM); | |
forbiddenBiomes.add(Biome.beachM); | |
forbiddenBiomes.add(Biome.desertHillsM); | |
forbiddenBiomes.add(Biome.deepOceanM); | |
forbiddenBiomes.add(Biome.stoneBeachM); | |
forbiddenBiomes.add(Biome.coldBeachM); | |
forbiddenBiomes.add(Biome.coldTaigaM); | |
forbiddenBiomes.add(Biome.coldTaigaHillsM); | |
} | |
public static void main(String[] args) throws Exception { | |
Main main = new Main(); | |
try { | |
main.run(); | |
} catch (Exception e) { | |
out.println(e.getClass().getName()); | |
out.println(e.getMessage()); | |
e.printStackTrace(out); | |
} | |
} | |
public static List<Biome> allowedBiomes() { | |
List<Biome> allowed = new ArrayList<>(); | |
for (Biome biome : Biome.biomes) { | |
if (biome != null && !forbiddenBiomes.contains(biome)) { | |
allowed.add(biome); | |
} | |
} | |
return allowed; | |
} | |
public static List<Biome> forbiddenBiomes() { | |
return new ArrayList<Biome>(forbiddenBiomes); | |
} | |
public static List<Biome> singleBiome() { | |
List<Biome> biomes = new ArrayList<>(); | |
biomes.add(Biome.taiga); | |
biomes.add(Biome.desert); | |
return biomes; | |
} | |
private void run() throws Exception { | |
MinecraftInterface iface = makeInterface(); | |
iface.createWorld(SEED, WorldType.DEFAULT, ""); | |
BiomeDataOracle oracle = new BiomeDataOracle(iface); | |
CoordinatesInWorld coords = oracle.findValidLocation(0, 10000, 250, allowedBiomes(), new Random()); | |
out.println(coords.getX()); | |
out.println(coords.getY()); | |
out.println("Done."); | |
} | |
private MinecraftInterface makeInterface() throws Exception { | |
File path = new File(MC_PATH); | |
DotMinecraftDirectory gameDir = new DotMinecraftDirectory(path); | |
File vdir = gameDir.getVersions(); | |
File jar = new File(vdir, "1.11.2/1.11.2.jar"); | |
File json = new File(vdir, "1.11.2/1.11.2.json"); | |
VersionDirectory versionDir = new VersionDirectory(gameDir, "1.11.2", jar, json); | |
MinecraftInterface iface = versionDir.createLocalMinecraftInterface(); | |
return iface; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment