Fix structure location issue.

This commit is contained in:
dfsek
2020-12-06 01:45:43 -07:00
parent 2d24a7bf00
commit c9b2c83dc4
5 changed files with 18 additions and 18 deletions

View File

@@ -55,7 +55,7 @@ dependencies {
implementation("net.jafama:jafama:2.3.2")
implementation(name = "Tectonic-1.0.2", group = "")
implementation(name = "Tectonic-1.0.3", group = "")
// JUnit.

View File

@@ -11,15 +11,15 @@ import org.jetbrains.annotations.NotNull;
import java.util.function.Consumer;
public abstract class AsyncFeatureFinder<T> implements Runnable {
private final TerraBiomeGrid grid;
private final T target;
private final int startRadius;
private final int maxRadius;
private final int centerX;
private final int centerZ;
private final World world;
protected final TerraBiomeGrid grid;
protected final T target;
protected final int startRadius;
protected final int maxRadius;
protected final int centerX;
protected final int centerZ;
protected final World world;
private final Consumer<Vector> callback;
private int searchSize = 1;
protected int searchSize = 1;
public AsyncFeatureFinder(TerraBiomeGrid grid, T target, @NotNull Location origin, int startRadius, int maxRadius, Consumer<Vector> callback) {
this.grid = grid;

View File

@@ -3,6 +3,7 @@ package com.dfsek.terra.async;
import com.dfsek.terra.biome.UserDefinedBiome;
import com.dfsek.terra.biome.grid.TerraBiomeGrid;
import com.dfsek.terra.generation.items.TerraStructure;
import com.dfsek.terra.procgen.GridSpawn;
import com.dfsek.terra.structure.Rotation;
import com.dfsek.terra.structure.Structure;
import org.bukkit.Location;
@@ -33,12 +34,11 @@ public class AsyncStructureFinder extends AsyncFeatureFinder<TerraStructure> {
public boolean isValid(int x, int z, TerraStructure target) {
World world = getWorld();
Location spawn = target.getSpawn().getChunkSpawn(x, z, world.getSeed()).toLocation(world);
if(!((UserDefinedBiome) getGrid().getBiome(spawn)).getConfig().getStructures().contains(target))
return false;
if(!((UserDefinedBiome) grid.getBiome(spawn)).getConfig().getStructures().contains(target)) return false;
Random r2 = new FastRandom(spawn.hashCode());
Structure struc = target.getStructures().get(r2);
Rotation rotation = Rotation.fromDegrees(r2.nextInt(4) * 90);
for(int y = target.getSpawnStart().get(r2); y > 0; y--) {
for(int y = target.getSpawnStart().get(r2); y > target.getBound().getMin(); y--) {
if(!target.getBound().isInRange(y)) return false;
spawn.setY(y);
if(!struc.checkSpawns(spawn, rotation)) continue;
@@ -49,6 +49,7 @@ public class AsyncStructureFinder extends AsyncFeatureFinder<TerraStructure> {
@Override
public Vector finalizeVector(Vector orig) {
return getTarget().getSpawn().getNearestSpawn(orig.getBlockX() * getSearchSize(), orig.getBlockZ() * getSearchSize(), getWorld().getSeed());
GridSpawn spawn = target.getSpawn();
return spawn.getChunkSpawn(orig.getBlockX(), orig.getBlockZ(), world.getSeed());
}
}

View File

@@ -77,16 +77,15 @@ public class UserDefinedCarver extends Carver {
return new UserDefinedWorm(length.get(r) / 2, r, vector, topCut, bottomCut);
}
public Variable getSeedVar() {
protected Variable getSeedVar() {
return seedVar;
}
public Variable getLengthVar() {
protected Variable getLengthVar() {
return lengthVar;
}
public Variable getPosition() {
protected Variable getPosition() {
return position;
}
@@ -106,7 +105,7 @@ public class UserDefinedCarver extends Carver {
for(int z = chunkZ - carvingRadius; z <= chunkZ + carvingRadius; z++) {
cache.getPoints(x, z, this).forEach(point -> {
Vector origin = point.getOrigin();
if(FastMath.floorDiv(origin.getBlockX(), 16) != chunkX && FastMath.floorDiv(origin.getBlockZ(), 16) != chunkZ)
if(FastMath.floorDiv(origin.getBlockX(), 16) != chunkX && FastMath.floorDiv(origin.getBlockZ(), 16) != chunkZ) // We only want to carve this chunk.
return;
point.carve(chunkX, chunkZ, consumer);
});