mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-04-09 17:26:07 +00:00
Fix up issues with code
Signed-off-by: solonovamax <solonovamax@12oclockpoint.com>
This commit is contained in:
@@ -43,6 +43,7 @@ import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.logging.Level;
|
||||
|
||||
|
||||
public class TerraChunkGenerator extends GaeaChunkGenerator {
|
||||
private static final Map<World, PopulationManager> popMap = new HashMap<>();
|
||||
private final PopulationManager popMan = new PopulationManager(Terra.getInstance());
|
||||
@@ -69,16 +70,22 @@ public class TerraChunkGenerator extends GaeaChunkGenerator {
|
||||
}
|
||||
|
||||
public static synchronized void fixChunk(Chunk c) {
|
||||
if(!(c.getWorld().getGenerator() instanceof TerraChunkGenerator)) throw new IllegalArgumentException();
|
||||
if (!(c.getWorld().getGenerator() instanceof TerraChunkGenerator)) throw new IllegalArgumentException();
|
||||
popMap.get(c.getWorld()).checkNeighbors(c.getX(), c.getZ(), c.getWorld());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void attachProfiler(WorldProfiler p) {
|
||||
super.attachProfiler(p);
|
||||
popMan.attachProfiler(p);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChunkData generateBase(@NotNull World world, @NotNull Random random, int chunkX, int chunkZ, ChunkInterpolator interpolator) {
|
||||
if(needsLoad) load(world); // Load population data for world.
|
||||
if (needsLoad) load(world); // Load population data for world.
|
||||
ChunkData chunk = createChunkData(world);
|
||||
TerraWorld tw = TerraWorld.getWorld(world);
|
||||
if(!tw.isSafe()) return chunk;
|
||||
if (!tw.isSafe()) return chunk;
|
||||
ConfigPack config = tw.getConfig();
|
||||
int xOrig = (chunkX << 4);
|
||||
int zOrig = (chunkZ << 4);
|
||||
@@ -98,10 +105,11 @@ public class TerraChunkGenerator extends GaeaChunkGenerator {
|
||||
BlockData data = b.getGenerator().getPalette(y).get(paletteLevel, cx, cz);
|
||||
chunk.setBlock(x, y, z, data);
|
||||
if(paletteLevel == 0 && slab != null && y < 255) {
|
||||
prepareBlockPart(data, chunk.getBlockData(x, y + 1, z), chunk, new Vector(x, y + 1, z), slab.getSlabs(), slab.getStairs(), slab.getSlabThreshold(), interpolator);
|
||||
prepareBlockPart(data, chunk.getBlockData(x, y + 1, z), chunk, new Vector(x, y + 1, z), slab.getSlabs(),
|
||||
slab.getStairs(), slab.getSlabThreshold(), interpolator);
|
||||
}
|
||||
paletteLevel++;
|
||||
} else if(y <= sea) {
|
||||
} else if (y <= sea) {
|
||||
chunk.setBlock(x, y, z, seaPalette.get(sea - y, x + xOrig, z + zOrig));
|
||||
paletteLevel = 0;
|
||||
} else paletteLevel = 0;
|
||||
@@ -111,16 +119,17 @@ public class TerraChunkGenerator extends GaeaChunkGenerator {
|
||||
return chunk;
|
||||
}
|
||||
|
||||
private void prepareBlockPart(BlockData down, BlockData orig, ChunkData chunk, Vector block, Map<Material, Palette<BlockData>> slabs, Map<Material, Palette<BlockData>> stairs, double thresh, ChunkInterpolator interpolator) {
|
||||
if(interpolator.getNoise(block.getBlockX(), block.getBlockY() - 0.4, block.getBlockZ()) > thresh) {
|
||||
if(stairs != null) {
|
||||
private void prepareBlockPart(BlockData down, BlockData orig, ChunkData chunk, Vector block, Map<Material, Palette<BlockData>> slabs,
|
||||
Map<Material, Palette<BlockData>> stairs, double thresh, ChunkInterpolator interpolator) {
|
||||
if (interpolator.getNoise(block.getBlockX(), block.getBlockY() - 0.4, block.getBlockZ()) > thresh) {
|
||||
if (stairs != null) {
|
||||
Palette<BlockData> stairPalette = stairs.get(down.getMaterial());
|
||||
if(stairPalette != null) {
|
||||
if (stairPalette != null) {
|
||||
BlockData stair = stairPalette.get(0, block.getBlockX(), block.getBlockZ());
|
||||
Stairs stairNew = (Stairs) stair.clone();
|
||||
if(interpolator.getNoise(block.getBlockX() - 0.5, block.getBlockY(), block.getBlockZ()) > thresh) {
|
||||
if (interpolator.getNoise(block.getBlockX() - 0.5, block.getBlockY(), block.getBlockZ()) > thresh) {
|
||||
stairNew.setFacing(BlockFace.WEST);
|
||||
} else if(interpolator.getNoise(block.getBlockX(), block.getBlockY(), block.getBlockZ() - 0.5) > thresh) {
|
||||
} else if (interpolator.getNoise(block.getBlockX(), block.getBlockY(), block.getBlockZ() - 0.5) > thresh) {
|
||||
stairNew.setFacing(BlockFace.NORTH);
|
||||
} else if(interpolator.getNoise(block.getBlockX(), block.getBlockY(), block.getBlockZ() + 0.5) > thresh) {
|
||||
stairNew.setFacing(BlockFace.SOUTH);
|
||||
@@ -154,12 +163,6 @@ public class TerraChunkGenerator extends GaeaChunkGenerator {
|
||||
needsLoad = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void attachProfiler(WorldProfiler p) {
|
||||
super.attachProfiler(p);
|
||||
popMan.attachProfiler(p);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNoiseOctaves(World world) {
|
||||
return configPack.octaves;
|
||||
@@ -186,6 +189,11 @@ public class TerraChunkGenerator extends GaeaChunkGenerator {
|
||||
return Arrays.asList(new CavePopulator(), new StructurePopulator(), popMan);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isParallelCapable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldGenerateCaves() {
|
||||
return configPack.vanillaCaves;
|
||||
@@ -206,9 +214,4 @@ public class TerraChunkGenerator extends GaeaChunkGenerator {
|
||||
return configPack.vanillaStructures;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isParallelCapable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ import parsii.tokenizer.ParseException;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
|
||||
|
||||
public class UserDefinedGenerator extends Generator {
|
||||
private static final Object noiseLock = new Object();
|
||||
@@ -32,14 +32,15 @@ public class UserDefinedGenerator extends Generator {
|
||||
private final boolean preventSmooth;
|
||||
|
||||
|
||||
public UserDefinedGenerator(String equation, List<Variable> v, TreeMap<Integer, Palette<BlockData>> pa, boolean preventSmooth) throws ParseException {
|
||||
public UserDefinedGenerator(String equation, List<Variable> userVariables, Map<Integer, Palette<BlockData>> paletteMap, boolean preventSmooth)
|
||||
throws ParseException {
|
||||
Parser p = new Parser();
|
||||
p.registerFunction("noise2", n2);
|
||||
p.registerFunction("noise3", n3);
|
||||
for(int y = 0; y < 256; y++) {
|
||||
Palette<BlockData> d = DataUtil.BLANK_PALETTE;
|
||||
for(Map.Entry<Integer, Palette<BlockData>> e : pa.entrySet()) {
|
||||
if(e.getKey() >= y) {
|
||||
for(Map.Entry<Integer, Palette<BlockData>> e : paletteMap.entrySet()) {
|
||||
if (e.getKey() >= y) {
|
||||
d = e.getValue();
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user