Implement rotating rails/axes

This commit is contained in:
dfsek
2020-10-05 01:05:54 -07:00
parent 277fbccc07
commit 96d293eec5
6 changed files with 109 additions and 46 deletions

View File

@@ -2,6 +2,7 @@ package com.dfsek.terra.population;
import com.dfsek.terra.TerraProfiler;
import com.dfsek.terra.TerraWorld;
import com.dfsek.terra.carving.SimplexCarver;
import com.dfsek.terra.config.base.ConfigPack;
import com.dfsek.terra.config.base.ConfigUtil;
import com.dfsek.terra.config.genconfig.CarverConfig;
@@ -81,7 +82,15 @@ public class CavePopulator extends BlockPopulator {
}
/*for(Map.Entry<Vector, CarvingData.CarvingType> e : new SimplexCarver(chunk.getX(), chunk.getZ()).carve(chunk.getX(), chunk.getZ(), world).getCarvedBlocks().entrySet()) {
Vector v = e.getKey();
chunk.getBlock(v.getBlockX(), v.getBlockY(), v.getBlockZ()).setBlockData(AIR, false);
switch(e.getValue()) {
case TOP:
case CENTER:
chunk.getBlock(v.getBlockX(), v.getBlockY(), v.getBlockZ()).setBlockData(AIR, false);
break;
case BOTTOM:
chunk.getBlock(v.getBlockX(), v.getBlockY(), v.getBlockZ()).setBlockData(Material.MYCELIUM.createBlockData(), false);
}
}*/
}

View File

@@ -44,7 +44,7 @@ public class StructurePopulator extends BlockPopulator {
double horizontal = struc.getStructureInfo().getMaxHorizontal();
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, GaeaStructure.Rotation.fromDegrees(r2.nextInt(4) * 90), Collections.emptyList());
struc.paste(spawn, chunk, GaeaStructure.Rotation.fromDegrees(r2.nextInt(4) * 90));
break;
}
}

View File

@@ -30,7 +30,7 @@ public class TreePopulator extends GaeaBlockPopulator {
try(ProfileFuture ignored = TerraProfiler.fromWorld(world).measure("TreeGenTime")) {
TerraWorld tw = TerraWorld.getWorld(world);
TerraBiomeGrid grid = tw.getGrid();;
int x = random.nextInt(16); // Decrease chances of chunk-crossing trees
int x = random.nextInt(16);
int z = random.nextInt(16);
int origX = chunk.getX() << 4;
int origZ = chunk.getZ() << 4;
@@ -40,16 +40,11 @@ public class TreePopulator extends GaeaBlockPopulator {
int att = 0;
for(int i = 0; i < b.getDecorator().getTreeDensity() && att < max; ) {
att++;
int y = 255;
while(y > 1) {
if(chunk.getBlock(x, y, z).getType().isAir() && chunk.getBlock(x, y-1, z).getType().isSolid()) break;
y--;
}
Tree tree = b.getDecorator().getTrees().get(random);
Range range = tw.getConfig().getBiome((UserDefinedBiome) b).getTreeRange(tree);
if(!tw.getConfig().getBiome((UserDefinedBiome) b).getTreeRange(tree).isInRange(y)) continue;
b = grid.getBiome(x+origX, z+origZ, GenerationPhase.POPULATE);
for(Block block : getValidSpawnsAt(chunk, x, z, range)) {
for(Block block : getValidSpawnsAt(chunk, x, z, new Range(0, 254))) {
Tree tree = b.getDecorator().getTrees().get(random);
Range range = tw.getConfig().getBiome((UserDefinedBiome) b).getTreeRange(tree);
if(!range.isInRange(block.getY())) continue;
b = grid.getBiome(x+origX, z+origZ, GenerationPhase.POPULATE);
try {
if(tree.plant(block.getLocation(), random, false, Terra.getInstance())) i++;
} catch(NullPointerException ignore) {}