Reformat & add .editorconfig

This commit is contained in:
dfsek
2020-11-06 15:21:42 -07:00
parent bfa55fdb5d
commit 4f40550465
33 changed files with 527 additions and 280 deletions

View File

@@ -13,7 +13,6 @@ import com.dfsek.terra.population.FloraPopulator;
import com.dfsek.terra.population.OrePopulator;
import com.dfsek.terra.population.SnowPopulator;
import com.dfsek.terra.population.StructurePopulator;
import com.dfsek.terra.structure.StructureSpawnRequirement;
import com.dfsek.terra.util.DataUtil;
import org.bukkit.Chunk;
import org.bukkit.Material;
@@ -26,12 +25,10 @@ import org.bukkit.generator.BlockPopulator;
import org.bukkit.util.Vector;
import org.jetbrains.annotations.NotNull;
import org.polydev.gaea.biome.Biome;
import org.polydev.gaea.biome.BiomeGrid;
import org.polydev.gaea.generation.GaeaChunkGenerator;
import org.polydev.gaea.generation.GenerationPhase;
import org.polydev.gaea.generation.GenerationPopulator;
import org.polydev.gaea.math.ChunkInterpolator;
import org.polydev.gaea.math.FastNoiseLite;
import org.polydev.gaea.population.PopulationManager;
import org.polydev.gaea.profiler.WorldProfiler;
import org.polydev.gaea.world.palette.Palette;
@@ -47,12 +44,10 @@ import java.util.Random;
import java.util.logging.Level;
public class TerraChunkGenerator extends GaeaChunkGenerator {
private final PopulationManager popMan = new PopulationManager(Terra.getInstance());
private boolean needsLoad = true;
private final ConfigPack configPack;
private static final Map<World, PopulationManager> popMap = new HashMap<>();
private final PopulationManager popMan = new PopulationManager(Terra.getInstance());
private final ConfigPack configPack;
private boolean needsLoad = true;
public TerraChunkGenerator(ConfigPack c) {
super(ChunkInterpolator.InterpolationType.TRILINEAR);
@@ -62,6 +57,22 @@ public class TerraChunkGenerator extends GaeaChunkGenerator {
popMan.attach(new SnowPopulator());
}
public static synchronized void saveAll() {
for(Map.Entry<World, PopulationManager> e : popMap.entrySet()) {
try {
e.getValue().saveBlocks(e.getKey());
Debug.info("Saved data for world " + e.getKey().getName());
} catch(IOException ioException) {
ioException.printStackTrace();
}
}
}
public static synchronized void fixChunk(Chunk c) {
if(! (c.getWorld().getGenerator() instanceof TerraChunkGenerator)) throw new IllegalArgumentException();
popMap.get(c.getWorld()).checkNeighbors(c.getX(), c.getZ(), c.getWorld());
}
@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.
@@ -143,28 +154,12 @@ public class TerraChunkGenerator extends GaeaChunkGenerator {
needsLoad = false;
}
public static synchronized void saveAll() {
for(Map.Entry<World, PopulationManager> e : popMap.entrySet()) {
try {
e.getValue().saveBlocks(e.getKey());
Debug.info("Saved data for world " + e.getKey().getName());
} catch(IOException ioException) {
ioException.printStackTrace();
}
}
}
@Override
public void attachProfiler(WorldProfiler p) {
super.attachProfiler(p);
popMan.attachProfiler(p);
}
public static synchronized void fixChunk(Chunk c) {
if(! (c.getWorld().getGenerator() instanceof TerraChunkGenerator)) throw new IllegalArgumentException();
popMap.get(c.getWorld()).checkNeighbors(c.getX(), c.getZ(), c.getWorld());
}
@Override
public int getNoiseOctaves(World world) {
return configPack.octaves;

View File

@@ -19,6 +19,7 @@ import java.util.Map;
import java.util.TreeMap;
public class UserDefinedGenerator extends Generator {
private static final Object noiseLock = new Object();
private final Expression noiseExp;
private final Scope s = new Scope();
private final Variable xVar = s.getVariable("x");
@@ -28,11 +29,8 @@ public class UserDefinedGenerator extends Generator {
private final Palette<BlockData>[] palettes = new Palette[256];
private final NoiseFunction2 n2 = new NoiseFunction2();
private final NoiseFunction3 n3 = new NoiseFunction3();
private final boolean preventSmooth;
private static final Object noiseLock = new Object();
public UserDefinedGenerator(String equation, List<Variable> v, TreeMap<Integer, Palette<BlockData>> pa, boolean preventSmooth) throws ParseException {
Parser p = new Parser();