mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-06-19 07:11:14 +00:00
Fix structure location issue.
This commit is contained in:
+1
-1
@@ -55,7 +55,7 @@ dependencies {
|
|||||||
|
|
||||||
implementation("net.jafama:jafama:2.3.2")
|
implementation("net.jafama:jafama:2.3.2")
|
||||||
|
|
||||||
implementation(name = "Tectonic-1.0.2", group = "")
|
implementation(name = "Tectonic-1.0.3", group = "")
|
||||||
|
|
||||||
|
|
||||||
// JUnit.
|
// JUnit.
|
||||||
|
|||||||
Binary file not shown.
@@ -11,15 +11,15 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
public abstract class AsyncFeatureFinder<T> implements Runnable {
|
public abstract class AsyncFeatureFinder<T> implements Runnable {
|
||||||
private final TerraBiomeGrid grid;
|
protected final TerraBiomeGrid grid;
|
||||||
private final T target;
|
protected final T target;
|
||||||
private final int startRadius;
|
protected final int startRadius;
|
||||||
private final int maxRadius;
|
protected final int maxRadius;
|
||||||
private final int centerX;
|
protected final int centerX;
|
||||||
private final int centerZ;
|
protected final int centerZ;
|
||||||
private final World world;
|
protected final World world;
|
||||||
private final Consumer<Vector> callback;
|
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) {
|
public AsyncFeatureFinder(TerraBiomeGrid grid, T target, @NotNull Location origin, int startRadius, int maxRadius, Consumer<Vector> callback) {
|
||||||
this.grid = grid;
|
this.grid = grid;
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package com.dfsek.terra.async;
|
|||||||
import com.dfsek.terra.biome.UserDefinedBiome;
|
import com.dfsek.terra.biome.UserDefinedBiome;
|
||||||
import com.dfsek.terra.biome.grid.TerraBiomeGrid;
|
import com.dfsek.terra.biome.grid.TerraBiomeGrid;
|
||||||
import com.dfsek.terra.generation.items.TerraStructure;
|
import com.dfsek.terra.generation.items.TerraStructure;
|
||||||
|
import com.dfsek.terra.procgen.GridSpawn;
|
||||||
import com.dfsek.terra.structure.Rotation;
|
import com.dfsek.terra.structure.Rotation;
|
||||||
import com.dfsek.terra.structure.Structure;
|
import com.dfsek.terra.structure.Structure;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@@ -33,12 +34,11 @@ public class AsyncStructureFinder extends AsyncFeatureFinder<TerraStructure> {
|
|||||||
public boolean isValid(int x, int z, TerraStructure target) {
|
public boolean isValid(int x, int z, TerraStructure target) {
|
||||||
World world = getWorld();
|
World world = getWorld();
|
||||||
Location spawn = target.getSpawn().getChunkSpawn(x, z, world.getSeed()).toLocation(world);
|
Location spawn = target.getSpawn().getChunkSpawn(x, z, world.getSeed()).toLocation(world);
|
||||||
if(!((UserDefinedBiome) getGrid().getBiome(spawn)).getConfig().getStructures().contains(target))
|
if(!((UserDefinedBiome) grid.getBiome(spawn)).getConfig().getStructures().contains(target)) return false;
|
||||||
return false;
|
|
||||||
Random r2 = new FastRandom(spawn.hashCode());
|
Random r2 = new FastRandom(spawn.hashCode());
|
||||||
Structure struc = target.getStructures().get(r2);
|
Structure struc = target.getStructures().get(r2);
|
||||||
Rotation rotation = Rotation.fromDegrees(r2.nextInt(4) * 90);
|
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;
|
if(!target.getBound().isInRange(y)) return false;
|
||||||
spawn.setY(y);
|
spawn.setY(y);
|
||||||
if(!struc.checkSpawns(spawn, rotation)) continue;
|
if(!struc.checkSpawns(spawn, rotation)) continue;
|
||||||
@@ -49,6 +49,7 @@ public class AsyncStructureFinder extends AsyncFeatureFinder<TerraStructure> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Vector finalizeVector(Vector orig) {
|
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());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -77,16 +77,15 @@ public class UserDefinedCarver extends Carver {
|
|||||||
return new UserDefinedWorm(length.get(r) / 2, r, vector, topCut, bottomCut);
|
return new UserDefinedWorm(length.get(r) / 2, r, vector, topCut, bottomCut);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Variable getSeedVar() {
|
protected Variable getSeedVar() {
|
||||||
return seedVar;
|
return seedVar;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected Variable getLengthVar() {
|
||||||
public Variable getLengthVar() {
|
|
||||||
return lengthVar;
|
return lengthVar;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Variable getPosition() {
|
protected Variable getPosition() {
|
||||||
return position;
|
return position;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -106,7 +105,7 @@ public class UserDefinedCarver extends Carver {
|
|||||||
for(int z = chunkZ - carvingRadius; z <= chunkZ + carvingRadius; z++) {
|
for(int z = chunkZ - carvingRadius; z <= chunkZ + carvingRadius; z++) {
|
||||||
cache.getPoints(x, z, this).forEach(point -> {
|
cache.getPoints(x, z, this).forEach(point -> {
|
||||||
Vector origin = point.getOrigin();
|
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;
|
return;
|
||||||
point.carve(chunkX, chunkZ, consumer);
|
point.carve(chunkX, chunkZ, consumer);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user