Skip to content

Instantly share code, notes, and snippets.

@hube12
Last active October 11, 2021 21:53
Show Gist options
  • Save hube12/e9d4f86c96c94cb887714e313b12f995 to your computer and use it in GitHub Desktop.
Save hube12/e9d4f86c96c94cb887714e313b12f995 to your computer and use it in GitHub Desktop.
2b2t nether seed 146008555100680
package com.seedfinding.neil;
import kaptainwutax.biomeutils.source.BiomeSource;
import kaptainwutax.featureutils.structure.Fortress;
import kaptainwutax.mcutils.block.Block;
import kaptainwutax.mcutils.block.Blocks;
import kaptainwutax.mcutils.rand.ChunkRand;
import kaptainwutax.mcutils.state.Dimension;
import kaptainwutax.mcutils.util.pos.BPos;
import kaptainwutax.mcutils.util.pos.CPos;
import kaptainwutax.mcutils.util.pos.RPos;
import kaptainwutax.mcutils.version.MCVersion;
import kaptainwutax.terrainutils.terrain.NetherTerrainGenerator;
import java.io.*;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.atomic.AtomicLong;
import java.util.stream.Collectors;
public class Data {
public static MCVersion VERSION = MCVersion.v1_12;
public static Fortress FORTRESS = new Fortress(VERSION);
public static List<CPos> fortresses = new ArrayList<CPos>() {{
add(new CPos(-46522, 17751));
add(new CPos(-46440, 17687));
add(new CPos(-46442, 17669));
add(new CPos(-46522, 17751));
add(new CPos(-46587, 17798));
add(new CPos(-46600, 17657));
add(new CPos(-46582, 17684));
add(new CPos(-46603, 17620));
add(new CPos(-46601, 17606));
add(new CPos(-46602, 17562));
}};
public static void main(String[] args) throws IOException {
List<Long> seeds = readFile();
System.out.println("File read");
long count = seeds.size();
BufferedWriter writer = new BufferedWriter(new FileWriter("final.txt", false));
seeds.stream().parallel().filter(s -> process(s, count))
.filter(Data::processTerrain)
.forEach(x -> {
try {
writer.write(x + "\n");
} catch (IOException e) {
e.printStackTrace();
}
})
;
writer.flush();
writer.close();
}
public static AtomicLong atomicLong = new AtomicLong(0);
public static boolean process(long seed, long max) {
long current = atomicLong.getAndIncrement();
if (current % (max / 100) == 0) {
System.out.println((int) (((double) current) / (((double) max / 100.0))) + "%");
}
ChunkRand rand = new ChunkRand();
for (CPos fortress : fortresses) {
RPos rPos = fortress.toRegionPos(FORTRESS.getSpacing());
CPos pos = FORTRESS.getInRegion(seed, rPos.getX(), rPos.getZ(), rand);
if (pos == null || !pos.equals(fortress)) {
// System.out.println("WRONG: "+seed);
return false;
}
}
return true;
}
public static List<BPos> terrain = new ArrayList<>() {{
add(new BPos(-745705, 53, 280525));
add(new BPos(-745700, 56, 280525));
add(new BPos(-745700, 55, 280526));
add(new BPos(-745706, 53, 280519));
add(new BPos(-745706, 53, 280521));
add(new BPos(-745705, 54, 280521));
add(new BPos(-745705, 54, 280519));
add(new BPos(-745704, 55, 280519));
add(new BPos(-745703, 56, 280519));
add(new BPos(-745700, 57, 280519));
add(new BPos(-745700, 58, 280520));
}};
///tp NeilCaffrei -745706 53 280521
public static boolean processTerrain(long seed) {
BiomeSource biomeSource = BiomeSource.of(Dimension.NETHER, VERSION, seed);
NetherTerrainGenerator netherChunkGenerator = (NetherTerrainGenerator) NetherTerrainGenerator.of(biomeSource);
for (BPos pos : terrain) {
Block[] column = netherChunkGenerator.getColumnAt(pos.getX(), pos.getZ());
if (column[pos.getY()-1] != netherChunkGenerator.getDefaultBlock() || column[pos.getY() ] != Blocks.AIR) {
return false;
}
}
System.out.println(seed);
return true;
}
public static List<Long> readFile() {
InputStream in = Data.class.getResourceAsStream("/out.txt");
assert in != null;
BufferedReader reader = new BufferedReader(new InputStreamReader(in));
return reader.lines().parallel().map(x -> Long.parseLong(x, 16)).collect(Collectors.toList());
}
}
// use GPUExample binaries
#include <jrand.cl>
static inline Random get_random_with_structure_seed (long world_seed, int x, int z, int salt) {
return get_random(x * 341873128712L + z * 132897987541L + world_seed + salt);
}
static inline int temple_at(ulong world_seed, int salt, int x, int z) {
int rSize = 32;
int rSep = 8;
int int_7 = x + rSize * 0;
int int_8 = z + rSize * 0;
int int_9 = int_7 < 0 ? int_7 - rSize + 1 : int_7;
int int_10 = int_8 < 0 ? int_8 - rSize + 1 : int_8;
int rx = int_9 / rSize;
int rz = int_10 / rSize;
Random r = get_random_with_structure_seed(world_seed, rx, rz, salt);
if (random_next_int(&r, rSize - rSep) != x - rx * rSize) return 0;
if (random_next_int(&r, rSize - rSep) != z - rz * rSize) return 0;
return 1;
}
static inline int monument_at(ulong world_seed, int x, int z) {
int rSize = 32;
int rSep = 5;
int int_7 = x + rSize * 0;
int int_8 = z + rSize * 0;
int int_9 = int_7 < 0 ? int_7 - rSize + 1 : int_7;
int int_10 = int_8 < 0 ? int_8 - rSize + 1 : int_8;
int rx = int_9 / rSize;
int rz = int_10 / rSize;
Random r = get_random_with_structure_seed(world_seed, rx, rz, 10387313);
if ((random_next_int(&r, rSize - rSep) + random_next_int(&r, rSize - rSep)) / 2 != x - rx * rSize) return 0;
if ((random_next_int(&r, rSize - rSep) + random_next_int(&r, rSize - rSep)) / 2 != z - rz * rSize) return 0;
return 1;
}
static inline int buried_treasure_at(long world_seed, int x, int z) {
Random r = get_random_with_structure_seed(world_seed, x, z, 10387320);
return random_next(&r, 24) < 167773;
}
static inline int bastion_remnant_at(ulong world_seed, int x, int z) {
int rSize = 27;
int rSep = 4;
int constrained_x = x < 0 ? x - rSize + 1 : x;
int constrained_z = z < 0 ? z - rSize + 1 : z;
int rx = constrained_x / rSize;
int rz = constrained_z / rSize;
Random r = get_random_with_structure_seed(world_seed, rx, rz, 30084232);
if (random_next_int(&r, rSize - rSep) != x - rx * rSize) return 0;
if (random_next_int(&r, rSize - rSep) != z - rz * rSize) return 0;
if (random_next_int(&r,5) < 2) return 0;
return 1;
}
static inline int fortress_at(ulong world_seed, int x, int z) {
int rSize = 27;
int rSep = 4;
int constrained_x = x < 0 ? x - rSize + 1 : x;
int constrained_z = z < 0 ? z - rSize + 1 : z;
int rx = constrained_x / rSize;
int rz = constrained_z / rSize;
Random r = get_random_with_structure_seed(world_seed, rx, rz, 30084232);
if (random_next_int(&r, rSize - rSep) != x - rx * rSize) return 0;
if (random_next_int(&r, rSize - rSep) != z - rz * rSize) return 0;
if (random_next_int(&r,5) >= 2) return 0;
return 1;
}
static inline int end_city_at(ulong world_seed, int x, int z) {
int rSize = 20;
int rSep = 11;
int constrained_x = x < 0 ? x - rSize + 1 : x;
int constrained_z = z < 0 ? z - rSize + 1 : z;
int rx = constrained_x / rSize;
int rz = constrained_z / rSize;
Random r = get_random_with_structure_seed(world_seed, rx, rz, 10387313);
if ((random_next_int(&r, rSize - rSep) + random_next_int(&r, rSize - rSep)) / 2 != x - rx * rSize) return 0;
if ((random_next_int(&r, rSize - rSep) + random_next_int(&r, rSize - rSep)) / 2 != z - rz * rSize) return 0;
return 1;
}
static inline int fortress_old_at(ulong world_seed, int x, int z) {
int shift_x = x >> 4;
int shift_z = z >> 4;
Random r = get_random((ulong)(shift_x ^ shift_z << 4) ^ world_seed );
random_next(&r,32);
if (random_next_int(&r,3) != 0) {
return 0;
}
if (x != (shift_x << 4) + 4 + random_next_int(&r,8)) {
return 0;
}
if (z != (shift_z << 4) + 4 + random_next_int(&r,8)) {
return 0;
}
return 1;
}
__kernel void start(ulong offset, ulong stride, __global ulong *seeds, __global ushort *ret) {
size_t id = get_global_id(0);
uchar max_count = 0;
uchar max_last = 0;
ulong seed_base = (offset + id) * stride;
for (ulong i = 0; i < stride; i++) {
ulong worldSeed = seed_base|i;
if (!fortress_old_at(worldSeed,-46585, 17816))continue; //fortress
if (!fortress_old_at(worldSeed,-46522, 17751))continue; //fortress
if (!fortress_old_at(worldSeed,-46440, 17687))continue; //fortress
if (!fortress_old_at(worldSeed,-46442, 17669))continue; //fortress
if (!fortress_old_at(worldSeed,-46587, 17798))continue; //fortress
if (!fortress_old_at(worldSeed,-46600, 17657))continue; //fortress
if (!fortress_old_at(worldSeed,-46582, 17684))continue; //fortress
max_count++;
seeds[id] = worldSeed;
}
ret[id] = (max_count << 8) | max_last;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment