Implement basic structure gen

This commit is contained in:
dfsek
2020-09-28 02:16:49 -07:00
parent 3e2fada357
commit 080a6d98f9
4 changed files with 19 additions and 4 deletions

View File

@@ -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);
}
}
}
}