improved structure data logic
This commit is contained in:
@@ -3,6 +3,7 @@ package kaptainwutax.seedcracker;
|
||||
import io.netty.util.internal.ConcurrentSet;
|
||||
import kaptainwutax.seedcracker.cracker.*;
|
||||
import kaptainwutax.seedcracker.cracker.population.DecoratorData;
|
||||
import kaptainwutax.seedcracker.cracker.structure.StructureData;
|
||||
import kaptainwutax.seedcracker.finder.FinderQueue;
|
||||
import kaptainwutax.seedcracker.render.RenderQueue;
|
||||
import kaptainwutax.seedcracker.util.Log;
|
||||
|
||||
@@ -1,193 +0,0 @@
|
||||
package kaptainwutax.seedcracker.cracker;
|
||||
|
||||
import kaptainwutax.seedcracker.util.Seeds;
|
||||
import kaptainwutax.seedcracker.util.Rand;
|
||||
import net.minecraft.util.math.ChunkPos;
|
||||
|
||||
public class StructureData {
|
||||
|
||||
private int chunkX;
|
||||
private int chunkZ;
|
||||
private int regionX;
|
||||
private int regionZ;
|
||||
private int offsetX;
|
||||
private int offsetZ;
|
||||
private FeatureType featureType;
|
||||
|
||||
public StructureData(ChunkPos chunkPos, FeatureType featureType) {
|
||||
this.featureType = featureType;
|
||||
this.featureType.build(this, chunkPos);
|
||||
}
|
||||
|
||||
public int getChunkX() {
|
||||
return this.chunkX;
|
||||
}
|
||||
|
||||
public int getChunkZ() {
|
||||
return this.chunkZ;
|
||||
}
|
||||
|
||||
public int getRegionX() {
|
||||
return this.regionX;
|
||||
}
|
||||
|
||||
public int getRegionZ() {
|
||||
return this.regionZ;
|
||||
}
|
||||
|
||||
public int getOffsetX() {
|
||||
return this.offsetX;
|
||||
}
|
||||
|
||||
public int getOffsetZ() {
|
||||
return this.offsetZ;
|
||||
}
|
||||
|
||||
public int getSalt() {
|
||||
return this.featureType.salt;
|
||||
}
|
||||
|
||||
public FeatureType getFeatureType() {
|
||||
return this.featureType;
|
||||
}
|
||||
|
||||
public boolean test(long structureSeed, Rand rand) {
|
||||
Seeds.setStructureSeed(rand, structureSeed, this.regionX, this.regionZ, this.getSalt());
|
||||
return this.featureType.test(rand, this, structureSeed);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if(obj == this)return true;
|
||||
|
||||
if(obj instanceof StructureData) {
|
||||
StructureData structureData = ((StructureData)obj);
|
||||
return structureData.regionX == this.regionX && structureData.regionZ == this.regionZ && structureData.featureType == this.featureType;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public abstract static class FeatureType {
|
||||
public final int salt;
|
||||
public final int distance;
|
||||
|
||||
public FeatureType(int salt, int distance) {
|
||||
this.salt = salt;
|
||||
this.distance = distance;
|
||||
}
|
||||
|
||||
public void build(StructureData data, ChunkPos chunkPos) {
|
||||
int chunkX = chunkPos.x;
|
||||
int chunkZ = chunkPos.z;
|
||||
|
||||
data.chunkX = chunkX;
|
||||
data.chunkZ = chunkZ;
|
||||
|
||||
chunkX = chunkX < 0 ? chunkX - this.distance + 1 : chunkX;
|
||||
chunkZ = chunkZ < 0 ? chunkZ - this.distance + 1 : chunkZ;
|
||||
|
||||
//Pick out in which region the chunk is.
|
||||
int regionX = (chunkX / this.distance);
|
||||
int regionZ = (chunkZ / this.distance);
|
||||
|
||||
data.regionX = regionX;
|
||||
data.regionZ = regionZ;
|
||||
|
||||
regionX *= this.distance;
|
||||
regionZ *= this.distance;
|
||||
|
||||
data.offsetX = chunkPos.x - regionX;
|
||||
data.offsetZ = chunkPos.z - regionZ;
|
||||
}
|
||||
|
||||
public abstract boolean test(Rand rand, StructureData data, long structureSeed);
|
||||
}
|
||||
|
||||
public static final FeatureType DESERT_PYRAMID = new FeatureType(14357617, 32) {
|
||||
@Override
|
||||
public boolean test(Rand rand, StructureData data, long structureSeed) {
|
||||
return rand.nextInt(24) == data.getOffsetX() && rand.nextInt(24) == data.getOffsetZ();
|
||||
}
|
||||
};
|
||||
|
||||
public static final FeatureType IGLOO = new FeatureType(14357618, 32) {
|
||||
@Override
|
||||
public boolean test(Rand rand, StructureData data, long structureSeed) {
|
||||
return rand.nextInt(24) == data.getOffsetX() && rand.nextInt(24) == data.getOffsetZ();
|
||||
}
|
||||
};
|
||||
|
||||
public static final FeatureType JUNGLE_TEMPLE = new FeatureType(14357619, 32) {
|
||||
@Override
|
||||
public boolean test(Rand rand, StructureData data, long structureSeed) {
|
||||
return rand.nextInt(24) == data.getOffsetX() && rand.nextInt(24) == data.getOffsetZ();
|
||||
}
|
||||
};
|
||||
|
||||
public static final FeatureType SWAMP_HUT = new FeatureType(14357620, 32) {
|
||||
@Override
|
||||
public boolean test(Rand rand, StructureData data, long structureSeed) {
|
||||
return rand.nextInt(24) == data.getOffsetX() && rand.nextInt(24) == data.getOffsetZ();
|
||||
}
|
||||
};
|
||||
|
||||
public static final FeatureType OCEAN_RUIN = new FeatureType(14357621, 16) {
|
||||
@Override
|
||||
public boolean test(Rand rand, StructureData data, long structureSeed) {
|
||||
return rand.nextInt(8) == data.getOffsetX() && rand.nextInt(8) == data.getOffsetZ();
|
||||
}
|
||||
};
|
||||
|
||||
public static final FeatureType SHIPWRECK = new FeatureType(165745295, 16) {
|
||||
@Override
|
||||
public boolean test(Rand rand, StructureData data, long structureSeed) {
|
||||
return rand.nextInt(8) == data.getOffsetX() && rand.nextInt(8) == data.getOffsetZ();
|
||||
}
|
||||
};
|
||||
|
||||
public static final FeatureType PILLAGER_OUTPOST = new FeatureType(165745296, 32) {
|
||||
@Override
|
||||
public boolean test(Rand rand, StructureData data, long structureSeed) {
|
||||
if(rand.nextInt(24) != data.getOffsetX() || rand.nextInt(24) != data.getOffsetZ())return false;
|
||||
|
||||
int xo = data.getChunkX() >> 4;
|
||||
int zo = data.getChunkZ() >> 4;
|
||||
rand.setSeed((long)(xo ^ zo << 4) ^ structureSeed, true);
|
||||
rand.nextInt();
|
||||
return rand.nextInt(5) == 0;
|
||||
}
|
||||
};
|
||||
|
||||
public static final FeatureType END_CITY = new FeatureType(10387313, 20) {
|
||||
@Override
|
||||
public boolean test(Rand rand, StructureData data, long structureSeed) {
|
||||
return (rand.nextInt(9) + rand.nextInt(9)) / 2 == data.getOffsetX()
|
||||
&& (rand.nextInt(9) + rand.nextInt(9)) / 2 == data.getOffsetZ();
|
||||
}
|
||||
};
|
||||
|
||||
public static final FeatureType OCEAN_MONUMENT = new FeatureType(10387313, 32) {
|
||||
@Override
|
||||
public boolean test(Rand rand, StructureData data, long structureSeed) {
|
||||
return (rand.nextInt(27) + rand.nextInt(27)) / 2 == data.getOffsetX()
|
||||
&& (rand.nextInt(27) + rand.nextInt(27)) / 2 == data.getOffsetZ();
|
||||
}
|
||||
};
|
||||
|
||||
public static final FeatureType BURIED_TREASURE = new FeatureType(10387320, 1) {
|
||||
@Override
|
||||
public boolean test(Rand rand, StructureData data, long structureSeed) {
|
||||
return rand.nextFloat() < 0.01f;
|
||||
}
|
||||
};
|
||||
|
||||
public static final FeatureType WOODLAND_MANSION = new FeatureType(10387319, 80) {
|
||||
@Override
|
||||
public boolean test(Rand rand, StructureData data, long structureSeed) {
|
||||
return (rand.nextInt(60) + rand.nextInt(60)) / 2 == data.getOffsetX()
|
||||
&& (rand.nextInt(60) + rand.nextInt(60)) / 2 == data.getOffsetZ();
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package kaptainwutax.seedcracker.cracker;
|
||||
|
||||
import kaptainwutax.seedcracker.cracker.population.DecoratorData;
|
||||
import kaptainwutax.seedcracker.cracker.structure.StructureData;
|
||||
import kaptainwutax.seedcracker.util.Log;
|
||||
import kaptainwutax.seedcracker.util.Rand;
|
||||
import kaptainwutax.seedcracker.util.math.LCG;
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
package kaptainwutax.seedcracker.cracker.structure;
|
||||
|
||||
import kaptainwutax.seedcracker.cracker.structure.type.FeatureType;
|
||||
import kaptainwutax.seedcracker.util.Seeds;
|
||||
import kaptainwutax.seedcracker.util.Rand;
|
||||
import net.minecraft.util.math.ChunkPos;
|
||||
|
||||
public class StructureData {
|
||||
|
||||
public int chunkX;
|
||||
public int chunkZ;
|
||||
public int regionX;
|
||||
public int regionZ;
|
||||
public int offsetX;
|
||||
public int offsetZ;
|
||||
private final int salt;
|
||||
private FeatureType<StructureData> featureType;
|
||||
|
||||
public StructureData(ChunkPos chunkPos, FeatureType<StructureData> featureType) {
|
||||
this.featureType = featureType;
|
||||
this.salt = this.featureType.salt;
|
||||
this.featureType.build(this, chunkPos);
|
||||
}
|
||||
|
||||
public boolean test(long structureSeed, Rand rand) {
|
||||
Seeds.setRegionSeed(rand, structureSeed, this.regionX, this.regionZ, this.salt);
|
||||
return this.featureType.test(rand, this, structureSeed);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if(obj == this)return true;
|
||||
|
||||
if(obj instanceof StructureData) {
|
||||
StructureData structureData = ((StructureData)obj);
|
||||
return structureData.regionX == this.regionX && structureData.regionZ == this.regionZ && structureData.featureType == this.featureType;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package kaptainwutax.seedcracker.cracker.structure;
|
||||
|
||||
import kaptainwutax.seedcracker.cracker.structure.type.AbstractTempleType;
|
||||
import kaptainwutax.seedcracker.cracker.structure.type.FeatureType;
|
||||
import kaptainwutax.seedcracker.cracker.structure.type.RarityType;
|
||||
import kaptainwutax.seedcracker.cracker.structure.type.TriangularType;
|
||||
import kaptainwutax.seedcracker.util.Rand;
|
||||
import kaptainwutax.seedcracker.util.Seeds;
|
||||
|
||||
public class StructureFeatures {
|
||||
|
||||
public static final FeatureType<StructureData> DESERT_PYRAMID = new AbstractTempleType(14357617, 32, 24);
|
||||
|
||||
public static final FeatureType<StructureData> IGLOO = new AbstractTempleType(14357618, 32, 24);
|
||||
|
||||
public static final FeatureType<StructureData> JUNGLE_TEMPLE = new AbstractTempleType(14357619, 32, 24);
|
||||
|
||||
public static final FeatureType<StructureData> SWAMP_HUT = new AbstractTempleType(14357620, 32, 24);
|
||||
|
||||
public static final FeatureType<StructureData> OCEAN_RUIN = new AbstractTempleType(14357621, 16, 8);
|
||||
|
||||
public static final FeatureType<StructureData> SHIPWRECK = new AbstractTempleType(165745295, 16, 8);
|
||||
|
||||
public static final FeatureType<StructureData> PILLAGER_OUTPOST = new AbstractTempleType(165745296, 32, 24) {
|
||||
@Override
|
||||
public boolean test(Rand rand, StructureData data, long structureSeed) {
|
||||
if(!super.test(rand, data, structureSeed))return false;
|
||||
Seeds.setWeakSeed(rand, structureSeed, data.chunkX, data.chunkZ);
|
||||
return rand.nextInt(5) == 0;
|
||||
}
|
||||
};
|
||||
|
||||
public static final FeatureType<StructureData> VILLAGE = new AbstractTempleType(10387312, 32, 24);
|
||||
|
||||
public static final FeatureType<StructureData> END_CITY = new TriangularType(10387313, 20, 9);
|
||||
|
||||
public static final FeatureType<StructureData> OCEAN_MONUMENT = new TriangularType(10387313, 32, 27);
|
||||
|
||||
public static final FeatureType<StructureData> WOODLAND_MANSION = new TriangularType(10387319, 80, 60);
|
||||
|
||||
public static final FeatureType<StructureData> BURIED_TREASURE = new RarityType(10387320, 1, 0.01F);
|
||||
|
||||
public static final FeatureType<StructureData> NETHER_FORTRESS = new FeatureType<StructureData>(-1, 1) {
|
||||
@Override
|
||||
public boolean test(Rand rand, StructureData data, long structureSeed) {
|
||||
Seeds.setWeakSeed(rand, structureSeed, data.chunkX, data.chunkZ);
|
||||
|
||||
return rand.nextInt(3) == 0
|
||||
&& data.chunkX == ((data.chunkX >> 4) << 4) + 4 + rand.nextInt(8)
|
||||
&& data.chunkZ == ((data.chunkZ >> 4) << 4) + 4 + rand.nextInt(8);
|
||||
}
|
||||
};
|
||||
|
||||
public static final FeatureType<StructureData> MINESHAFT = new FeatureType<StructureData>(-1, 1) {
|
||||
@Override
|
||||
public boolean test(Rand rand, StructureData data, long structureSeed) {
|
||||
Seeds.setStructureStartSeed(rand, structureSeed, data.chunkX, data.chunkZ);
|
||||
return rand.nextDouble() < 0.004D;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package kaptainwutax.seedcracker.cracker.structure.type;
|
||||
|
||||
import kaptainwutax.seedcracker.cracker.structure.StructureData;
|
||||
import kaptainwutax.seedcracker.util.Rand;
|
||||
|
||||
public class AbstractTempleType extends FeatureType<StructureData> {
|
||||
|
||||
protected final int offset;
|
||||
|
||||
public AbstractTempleType(int salt, int distance, int offset) {
|
||||
super(salt, distance);
|
||||
this.offset = offset;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean test(Rand rand, StructureData data, long structureSeed) {
|
||||
return rand.nextInt(this.offset) == data.offsetX && rand.nextInt(this.offset) == data.offsetZ;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package kaptainwutax.seedcracker.cracker.structure.type;
|
||||
|
||||
import kaptainwutax.seedcracker.cracker.structure.StructureData;
|
||||
import kaptainwutax.seedcracker.util.Rand;
|
||||
import net.minecraft.util.math.ChunkPos;
|
||||
|
||||
public abstract class FeatureType<T extends StructureData> {
|
||||
|
||||
public final int salt;
|
||||
public final int distance;
|
||||
|
||||
public FeatureType(int salt, int distance) {
|
||||
this.salt = salt;
|
||||
this.distance = distance;
|
||||
}
|
||||
|
||||
public void build(T data, ChunkPos chunkPos) {
|
||||
int chunkX = chunkPos.x;
|
||||
int chunkZ = chunkPos.z;
|
||||
|
||||
data.chunkX = chunkX;
|
||||
data.chunkZ = chunkZ;
|
||||
|
||||
chunkX = chunkX < 0 ? chunkX - this.distance + 1 : chunkX;
|
||||
chunkZ = chunkZ < 0 ? chunkZ - this.distance + 1 : chunkZ;
|
||||
|
||||
//Pick out in which region the chunk is.
|
||||
int regionX = (chunkX / this.distance);
|
||||
int regionZ = (chunkZ / this.distance);
|
||||
|
||||
data.regionX = regionX;
|
||||
data.regionZ = regionZ;
|
||||
|
||||
regionX *= this.distance;
|
||||
regionZ *= this.distance;
|
||||
|
||||
data.offsetX = chunkPos.x - regionX;
|
||||
data.offsetZ = chunkPos.z - regionZ;
|
||||
}
|
||||
|
||||
public abstract boolean test(Rand rand, T data, long structureSeed);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package kaptainwutax.seedcracker.cracker.structure.type;
|
||||
|
||||
import kaptainwutax.seedcracker.cracker.structure.StructureData;
|
||||
import kaptainwutax.seedcracker.util.Rand;
|
||||
|
||||
public class RarityType extends FeatureType<StructureData> {
|
||||
|
||||
private float rarity;
|
||||
|
||||
public RarityType(int salt, int distance, float rarity) {
|
||||
super(salt, distance);
|
||||
this.rarity = rarity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean test(Rand rand, StructureData data, long structureSeed) {
|
||||
return rand.nextFloat() < this.rarity;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package kaptainwutax.seedcracker.cracker.structure.type;
|
||||
|
||||
|
||||
import kaptainwutax.seedcracker.cracker.structure.StructureData;
|
||||
import kaptainwutax.seedcracker.util.Rand;
|
||||
|
||||
public class TriangularType extends FeatureType<StructureData> {
|
||||
|
||||
protected final int peak;
|
||||
|
||||
public TriangularType(int salt, int distance, int peak) {
|
||||
super(salt, distance);
|
||||
this.peak = peak;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean test(Rand rand, StructureData data, long structureSeed) {
|
||||
return (rand.nextInt(this.peak) + rand.nextInt(this.peak)) / 2 == data.offsetX
|
||||
&& (rand.nextInt(this.peak) + rand.nextInt(this.peak)) / 2 == data.offsetZ;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -54,16 +54,17 @@ public abstract class Finder {
|
||||
DimensionType playerDim = mc.player.world.dimension.getType();
|
||||
|
||||
if(finderDim != playerDim)return false;
|
||||
Vec3d playerPos = mc.player.getPos();
|
||||
|
||||
double distance = playerPos.squaredDistanceTo(
|
||||
this.chunkPos.x * 16,
|
||||
playerPos.y,
|
||||
this.chunkPos.z * 16
|
||||
);
|
||||
|
||||
int renderDistance = mc.options.viewDistance * 16 + 16;
|
||||
return distance <= renderDistance * renderDistance + 32;
|
||||
Vec3d playerPos = mc.player.getPos();
|
||||
|
||||
for(Renderer renderer: this.renderers) {
|
||||
BlockPos pos = renderer.getPos();
|
||||
double distance = playerPos.squaredDistanceTo(pos.getX(), playerPos.y, pos.getZ());
|
||||
if(distance <= renderDistance * renderDistance + 32)return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void render() {
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
package kaptainwutax.seedcracker.finder.structure;
|
||||
|
||||
import kaptainwutax.seedcracker.SeedCracker;
|
||||
import kaptainwutax.seedcracker.cracker.StructureData;
|
||||
import kaptainwutax.seedcracker.cracker.structure.StructureData;
|
||||
import kaptainwutax.seedcracker.cracker.structure.StructureFeatures;
|
||||
import kaptainwutax.seedcracker.finder.BlockFinder;
|
||||
import kaptainwutax.seedcracker.finder.Finder;
|
||||
import kaptainwutax.seedcracker.render.Cube;
|
||||
@@ -71,7 +72,7 @@ public class BuriedTreasureFinder extends BlockFinder {
|
||||
});
|
||||
|
||||
result.forEach(pos -> {
|
||||
if(SeedCracker.get().onStructureData(new StructureData(this.chunkPos, StructureData.BURIED_TREASURE))) {
|
||||
if(SeedCracker.get().onStructureData(new StructureData(this.chunkPos, StructureFeatures.BURIED_TREASURE))) {
|
||||
this.renderers.add(new Cube(pos, new Vector4f(1.0f, 1.0f, 0.0f, 1.0f)));
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
package kaptainwutax.seedcracker.finder.structure;
|
||||
|
||||
import kaptainwutax.seedcracker.SeedCracker;
|
||||
import kaptainwutax.seedcracker.cracker.StructureData;
|
||||
import kaptainwutax.seedcracker.cracker.structure.StructureData;
|
||||
import kaptainwutax.seedcracker.cracker.structure.StructureFeatures;
|
||||
import kaptainwutax.seedcracker.finder.Finder;
|
||||
import kaptainwutax.seedcracker.render.Cuboid;
|
||||
import net.minecraft.block.BlockState;
|
||||
@@ -35,7 +36,7 @@ public class DesertTempleFinder extends AbstractTempleFinder {
|
||||
combinedResult.addAll(positions);
|
||||
|
||||
positions.forEach(pos -> {
|
||||
if( SeedCracker.get().onStructureData(new StructureData(this.chunkPos, StructureData.DESERT_PYRAMID))) {
|
||||
if( SeedCracker.get().onStructureData(new StructureData(this.chunkPos, StructureFeatures.DESERT_PYRAMID))) {
|
||||
this.renderers.add(new Cuboid(pos, pieceFinder.getLayout(), new Vector4f(1.0f, 0.0f, 1.0f, 1.0f)));
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
package kaptainwutax.seedcracker.finder.structure;
|
||||
|
||||
import kaptainwutax.seedcracker.SeedCracker;
|
||||
import kaptainwutax.seedcracker.cracker.StructureData;
|
||||
import kaptainwutax.seedcracker.cracker.structure.StructureData;
|
||||
import kaptainwutax.seedcracker.cracker.structure.StructureFeatures;
|
||||
import kaptainwutax.seedcracker.finder.Finder;
|
||||
import kaptainwutax.seedcracker.render.Cube;
|
||||
import kaptainwutax.seedcracker.render.Cuboid;
|
||||
@@ -85,7 +86,7 @@ public class EndCityFinder extends Finder {
|
||||
combinedResult.addAll(positions);
|
||||
|
||||
positions.forEach(pos -> {
|
||||
if(SeedCracker.get().onStructureData(new StructureData(this.chunkPos, StructureData.END_CITY))) {
|
||||
if(SeedCracker.get().onStructureData(new StructureData(this.chunkPos, StructureFeatures.END_CITY))) {
|
||||
this.renderers.add(new Cuboid(pos, pieceFinder.getLayout(), new Vector4f(0.6f, 0.0f, 0.6f, 1.0f)));
|
||||
this.renderers.add(new Cube(pos, new Vector4f(0.6f, 0.0f, 0.6f, 1.0f)));
|
||||
}
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
package kaptainwutax.seedcracker.finder.structure;
|
||||
|
||||
import kaptainwutax.seedcracker.SeedCracker;
|
||||
import kaptainwutax.seedcracker.cracker.StructureData;
|
||||
import kaptainwutax.seedcracker.cracker.structure.StructureData;
|
||||
import kaptainwutax.seedcracker.cracker.structure.StructureFeatures;
|
||||
import kaptainwutax.seedcracker.finder.Finder;
|
||||
import kaptainwutax.seedcracker.render.Cube;
|
||||
import kaptainwutax.seedcracker.render.Cuboid;
|
||||
@@ -44,7 +45,7 @@ public class IglooFinder extends AbstractTempleFinder {
|
||||
combinedResult.addAll(positions);
|
||||
|
||||
positions.forEach(pos -> {
|
||||
if(SeedCracker.get().onStructureData(new StructureData(this.chunkPos, StructureData.IGLOO))) {
|
||||
if(SeedCracker.get().onStructureData(new StructureData(this.chunkPos, StructureFeatures.IGLOO))) {
|
||||
this.renderers.add(new Cuboid(pos, pieceFinder.getLayout(), new Vector4f(0.0f, 1.0f, 1.0f, 1.0f)));
|
||||
this.renderers.add(new Cube(pos, new Vector4f(0.0f, 1.0f, 1.0f, 1.0f)));
|
||||
}
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
package kaptainwutax.seedcracker.finder.structure;
|
||||
|
||||
import kaptainwutax.seedcracker.SeedCracker;
|
||||
import kaptainwutax.seedcracker.cracker.StructureData;
|
||||
import kaptainwutax.seedcracker.cracker.structure.StructureData;
|
||||
import kaptainwutax.seedcracker.cracker.structure.StructureFeatures;
|
||||
import kaptainwutax.seedcracker.finder.Finder;
|
||||
import kaptainwutax.seedcracker.render.Cuboid;
|
||||
import net.minecraft.block.*;
|
||||
@@ -35,7 +36,7 @@ public class JungleTempleFinder extends AbstractTempleFinder {
|
||||
combinedResult.addAll(positions);
|
||||
|
||||
positions.forEach(pos -> {
|
||||
if(SeedCracker.get().onStructureData(new StructureData(this.chunkPos, StructureData.JUNGLE_TEMPLE))) {
|
||||
if(SeedCracker.get().onStructureData(new StructureData(this.chunkPos, StructureFeatures.JUNGLE_TEMPLE))) {
|
||||
this.renderers.add(new Cuboid(pos, pieceFinder.getLayout(), new Vector4f(1.0f, 0.0f, 1.0f, 1.0f)));
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
package kaptainwutax.seedcracker.finder.structure;
|
||||
|
||||
import kaptainwutax.seedcracker.SeedCracker;
|
||||
import kaptainwutax.seedcracker.cracker.StructureData;
|
||||
import kaptainwutax.seedcracker.cracker.structure.StructureData;
|
||||
import kaptainwutax.seedcracker.cracker.structure.StructureFeatures;
|
||||
import kaptainwutax.seedcracker.finder.Finder;
|
||||
import kaptainwutax.seedcracker.render.Cube;
|
||||
import kaptainwutax.seedcracker.render.Cuboid;
|
||||
@@ -61,7 +62,7 @@ public class MansionFinder extends Finder {
|
||||
combinedResult.addAll(positions);
|
||||
|
||||
positions.forEach(pos -> {
|
||||
if(SeedCracker.get().onStructureData(new StructureData(this.chunkPos, StructureData.WOODLAND_MANSION))) {
|
||||
if(SeedCracker.get().onStructureData(new StructureData(this.chunkPos, StructureFeatures.WOODLAND_MANSION))) {
|
||||
this.renderers.add(new Cuboid(pos, pieceFinder.getLayout(), new Vector4f(0.4f, 0.26f, 0.13f, 1.0f)));
|
||||
this.renderers.add(new Cube(this.chunkPos.getCenterBlockPos().add(0, pos.getY(), 0), new Vector4f(0.4f, 0.26f, 0.13f, 1.0f)));
|
||||
}
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
package kaptainwutax.seedcracker.finder.structure;
|
||||
|
||||
import kaptainwutax.seedcracker.SeedCracker;
|
||||
import kaptainwutax.seedcracker.cracker.StructureData;
|
||||
import kaptainwutax.seedcracker.cracker.structure.StructureData;
|
||||
import kaptainwutax.seedcracker.cracker.structure.StructureFeatures;
|
||||
import kaptainwutax.seedcracker.finder.Finder;
|
||||
import kaptainwutax.seedcracker.render.Cube;
|
||||
import kaptainwutax.seedcracker.render.Cuboid;
|
||||
@@ -57,7 +58,7 @@ public class OceanMonumentFinder extends Finder {
|
||||
positions.forEach(pos -> {
|
||||
ChunkPos monumentStart = new ChunkPos(this.chunkPos.x + 1, this.chunkPos.z + 1);
|
||||
|
||||
if(SeedCracker.get().onStructureData(new StructureData(monumentStart, StructureData.OCEAN_MONUMENT))) {
|
||||
if(SeedCracker.get().onStructureData(new StructureData(monumentStart, StructureFeatures.OCEAN_MONUMENT))) {
|
||||
this.renderers.add(new Cuboid(pos, pieceFinder.getLayout(), new Vector4f(0.0f, 0.0f, 1.0f, 1.0f)));
|
||||
this.renderers.add(new Cube(monumentStart.getCenterBlockPos().add(0, pos.getY(), 0), new Vector4f(0.0f, 0.0f, 1.0f, 1.0f)));
|
||||
}
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
package kaptainwutax.seedcracker.finder.structure;
|
||||
|
||||
import kaptainwutax.seedcracker.SeedCracker;
|
||||
import kaptainwutax.seedcracker.cracker.StructureData;
|
||||
import kaptainwutax.seedcracker.cracker.structure.StructureData;
|
||||
import kaptainwutax.seedcracker.cracker.structure.StructureFeatures;
|
||||
import kaptainwutax.seedcracker.finder.BlockFinder;
|
||||
import kaptainwutax.seedcracker.finder.Finder;
|
||||
import kaptainwutax.seedcracker.render.Cube;
|
||||
@@ -174,7 +175,7 @@ public class ShipwreckFinder extends BlockFinder {
|
||||
mutablePos.setOffset(-4, -chestY, -15);
|
||||
|
||||
if((mutablePos.getX() & 0xf) == 0 && (mutablePos.getZ() & 0xf) == 0) {
|
||||
if(SeedCracker.get().onStructureData(new StructureData(new ChunkPos(mutablePos), StructureData.SHIPWRECK))) {
|
||||
if(SeedCracker.get().onStructureData(new StructureData(new ChunkPos(mutablePos), StructureFeatures.SHIPWRECK))) {
|
||||
this.renderers.add(new Cuboid(box, new Vector4f(1.0f, 0.0f, 1.0f, 1.0f)));
|
||||
this.renderers.add(new Cube(new ChunkPos(mutablePos).getCenterBlockPos().offset(Direction.UP, mutablePos.getY()), new Vector4f(1.0f, 0.0f, 1.0f, 1.0f)));
|
||||
return true;
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
package kaptainwutax.seedcracker.finder.structure;
|
||||
|
||||
import kaptainwutax.seedcracker.SeedCracker;
|
||||
import kaptainwutax.seedcracker.cracker.StructureData;
|
||||
import kaptainwutax.seedcracker.cracker.structure.StructureData;
|
||||
import kaptainwutax.seedcracker.cracker.structure.StructureFeatures;
|
||||
import kaptainwutax.seedcracker.finder.Finder;
|
||||
import kaptainwutax.seedcracker.render.Cuboid;
|
||||
import net.minecraft.block.BlockState;
|
||||
@@ -36,7 +37,7 @@ public class SwampHutFinder extends AbstractTempleFinder {
|
||||
combinedResult.addAll(positions);
|
||||
|
||||
positions.forEach(pos -> {
|
||||
if(SeedCracker.get().onStructureData(new StructureData(this.chunkPos, StructureData.SWAMP_HUT))) {
|
||||
if(SeedCracker.get().onStructureData(new StructureData(this.chunkPos, StructureFeatures.SWAMP_HUT))) {
|
||||
this.renderers.add(new Cuboid(pos, pieceFinder.getLayout(), new Vector4f(1.0f, 0.0f, 1.0f, 1.0f)));
|
||||
}
|
||||
});
|
||||
|
||||
@@ -18,4 +18,9 @@ public class Cube extends Cuboid {
|
||||
super(pos, new Vec3i(1, 1, 1), color);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockPos getPos() {
|
||||
return this.start;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -57,4 +57,9 @@ public class Cuboid extends Renderer {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockPos getPos() {
|
||||
return this.start.add(this.size.getX() / 2, this.size.getY() / 2, this.size.getZ() / 2);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import net.minecraft.client.render.BufferBuilder;
|
||||
import net.minecraft.client.render.Tessellator;
|
||||
import net.minecraft.client.render.VertexFormats;
|
||||
import net.minecraft.client.util.math.Vector4f;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
|
||||
public class Line extends Renderer {
|
||||
@@ -60,4 +61,12 @@ public class Line extends Renderer {
|
||||
).next();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockPos getPos() {
|
||||
double x = (this.end.getX() - this.start.getX()) / 2 + this.start.getX();
|
||||
double y = (this.end.getY() - this.start.getY()) / 2 + this.start.getY();
|
||||
double z = (this.end.getZ() - this.start.getZ()) / 2 + this.start.getZ();
|
||||
return new BlockPos(x, y, z);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -10,6 +10,8 @@ public abstract class Renderer {
|
||||
|
||||
public abstract void render();
|
||||
|
||||
public abstract BlockPos getPos();
|
||||
|
||||
protected Vec3d toVec3d(BlockPos pos) {
|
||||
return new Vec3d(pos.getX(), pos.getY(), pos.getZ());
|
||||
}
|
||||
|
||||
@@ -2,6 +2,8 @@ package kaptainwutax.seedcracker.util;
|
||||
|
||||
import kaptainwutax.seedcracker.util.math.LCG;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class Rand implements Cloneable {
|
||||
|
||||
public static final LCG JAVA_LCG = new LCG(0x5DEECE66DL, 0xBL, 1L << 48);
|
||||
@@ -69,6 +71,10 @@ public class Rand implements Cloneable {
|
||||
return (((long)this.next(27) << 27) + this.next(27)) / (double)(1L << 54);
|
||||
}
|
||||
|
||||
public Random toRandom() {
|
||||
return new Random(this.seed ^ JAVA_LCG.multiplier);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if(obj == this)return true;
|
||||
|
||||
@@ -2,10 +2,28 @@ package kaptainwutax.seedcracker.util;
|
||||
|
||||
public class Seeds {
|
||||
|
||||
public static long setStructureSeed(Rand rand, long worldSeed, int regionX, int regionZ, int salt) {
|
||||
public static long setRegionSeed(Rand rand, long worldSeed, int regionX, int regionZ, int salt) {
|
||||
long seed = (long)regionX * 341873128712L + (long)regionZ * 132897987541L + worldSeed + (long)salt;
|
||||
rand.setSeed(seed, true);
|
||||
return seed;
|
||||
}
|
||||
|
||||
public static long setStructureStartSeed(Rand rand, long worldSeed, int chunkX, int chunkZ) {
|
||||
rand.setSeed(worldSeed, true);
|
||||
long a = rand.nextLong();
|
||||
long b = rand.nextLong();
|
||||
long seed = (long)chunkX * a ^ (long)chunkZ * b ^ worldSeed;
|
||||
rand.setSeed(seed, true);
|
||||
return seed;
|
||||
}
|
||||
|
||||
public static long setWeakSeed(Rand rand, long worldSeed, int chunkX, int chunkZ) {
|
||||
int sX = chunkX >> 4;
|
||||
int sZ = chunkZ >> 4;
|
||||
long seed = (long)(sX ^ sZ << 4) ^ worldSeed;
|
||||
rand.setSeed(seed, true);
|
||||
rand.nextInt();
|
||||
return seed;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user