mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-04-11 02:06:07 +00:00
Implement basic structure gen
This commit is contained in:
@@ -22,7 +22,7 @@ import java.util.Set;
|
||||
public class StructurePopulator extends BlockPopulator {
|
||||
StructureSpawn spawnTest = new StructureSpawn(250, 250);
|
||||
GaeaStructure struc = GaeaStructure.load(new File(Terra.getInstance().getDataFolder() + File.separator + "export" + File.separator + "structures", "demo2.tstructure"));
|
||||
double horizontal = struc.getStructureInfo().getMaxHorizontal()/16D + 1D;
|
||||
double horizontal = struc.getStructureInfo().getMaxHorizontal();
|
||||
|
||||
public StructurePopulator() throws IOException {
|
||||
}
|
||||
@@ -30,7 +30,16 @@ public class StructurePopulator extends BlockPopulator {
|
||||
@Override
|
||||
public void populate(@NotNull World world, @NotNull Random random, @NotNull Chunk chunk) {
|
||||
try(ProfileFuture ignored = TerraProfiler.fromWorld(world).measure("StructureTime")) {
|
||||
|
||||
int cx = (chunk.getX() << 4);
|
||||
int cz = (chunk.getZ() << 4);
|
||||
Location spawn = spawnTest.getNearestSpawn(cx+ 8, cz + 8, world.getSeed()).toLocation(world);
|
||||
spawn.setY(72);
|
||||
if(Math.abs((cx+8)-spawn.getBlockX()) <= horizontal && Math.abs((cz+8)-spawn.getBlockZ()) <= horizontal) {
|
||||
try(ProfileFuture ignore = TerraProfiler.fromWorld(world).measure("StructurePasteTime")) {
|
||||
struc.paste(spawn, chunk);
|
||||
}
|
||||
Bukkit.getLogger().info("Pasted at " + spawn);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user