mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-04-20 23:30:29 +00:00
Rewrite basically the whole generator again. Get rid of failsafe biomes because they are dumb
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
package com.dfsek.terra.biome;
|
||||
|
||||
import com.dfsek.terra.config.genconfig.biome.GeneratorOptions;
|
||||
import com.dfsek.terra.generation.UserDefinedDecorator;
|
||||
import com.dfsek.terra.generation.UserDefinedGenerator;
|
||||
import org.bukkit.World;
|
||||
import org.polydev.gaea.biome.Biome;
|
||||
import org.polydev.gaea.biome.Decorator;
|
||||
import org.polydev.gaea.biome.Generator;
|
||||
@@ -13,14 +14,14 @@ import java.util.List;
|
||||
* Class representing a config-defined biome
|
||||
*/
|
||||
public class UserDefinedBiome implements Biome {
|
||||
private final UserDefinedGenerator gen;
|
||||
private final GeneratorOptions gen;
|
||||
private final UserDefinedDecorator decorator;
|
||||
private final org.bukkit.block.Biome vanilla;
|
||||
private final String id;
|
||||
private final boolean erode;
|
||||
|
||||
|
||||
public UserDefinedBiome(org.bukkit.block.Biome vanilla, UserDefinedDecorator dec, UserDefinedGenerator gen, boolean erode, String id) {
|
||||
public UserDefinedBiome(org.bukkit.block.Biome vanilla, UserDefinedDecorator dec, GeneratorOptions gen, boolean erode, String id) {
|
||||
this.vanilla = vanilla;
|
||||
this.decorator = dec;
|
||||
this.gen = gen;
|
||||
@@ -45,7 +46,7 @@ public class UserDefinedBiome implements Biome {
|
||||
*/
|
||||
@Override
|
||||
public Generator getGenerator() {
|
||||
return gen;
|
||||
return gen.getGenerator(0);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -75,4 +76,9 @@ public class UserDefinedBiome implements Biome {
|
||||
public boolean isErodible() {
|
||||
return erode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Generator getGenerator(World w) {
|
||||
return gen.getGenerator(w.getSeed());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,61 +0,0 @@
|
||||
package com.dfsek.terra.biome.failsafe;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.polydev.gaea.biome.Biome;
|
||||
import parsii.tokenizer.ParseException;
|
||||
|
||||
/**
|
||||
* What happens if terrain generation is attempted with an unrecoverable config error.
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public enum FailType {
|
||||
/**
|
||||
* Return failover biome, then shut down server to minimize damage.
|
||||
* Generally the safest option.
|
||||
*/
|
||||
SHUTDOWN {
|
||||
@Override
|
||||
public Biome fail() {
|
||||
Bukkit.getServer().shutdown();
|
||||
try {
|
||||
return new FailoverBiome();
|
||||
} catch(ParseException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
},
|
||||
/**
|
||||
* Returns null, hard crashing the server, but not generating any corrupted terrain.<br>
|
||||
* This option is <b>NOT</b> stable, but it has the least risk of blank chunks being generated.
|
||||
* However, it has the highest risk of corruption!
|
||||
*/
|
||||
CRASH {
|
||||
@Override
|
||||
public Biome fail() {
|
||||
return null;
|
||||
}
|
||||
},
|
||||
/**
|
||||
* Returns a failover biome, which generates completely blank chunks.
|
||||
* Recommended for debugging.
|
||||
*/
|
||||
FAILOVER {
|
||||
@Override
|
||||
public Biome fail() {
|
||||
try {
|
||||
return new FailoverBiome();
|
||||
} catch(ParseException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Performs the action specified by the enum type to occur on failure of terrain generation.
|
||||
*
|
||||
* @return Failover biome, if specified, null if not.
|
||||
*/
|
||||
public abstract Biome fail();
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
package com.dfsek.terra.biome.failsafe;
|
||||
|
||||
import com.dfsek.terra.biome.UserDefinedBiome;
|
||||
import parsii.tokenizer.ParseException;
|
||||
|
||||
/**
|
||||
* Blank biome to generate in case of a severe config error
|
||||
*/
|
||||
public final class FailoverBiome extends UserDefinedBiome {
|
||||
public FailoverBiome() throws ParseException {
|
||||
super(org.bukkit.block.Biome.PLAINS, new FailoverDecorator(), new FailoverGenerator(), false, "FAILSAFE");
|
||||
}
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
package com.dfsek.terra.biome.failsafe;
|
||||
|
||||
import com.dfsek.terra.generation.UserDefinedDecorator;
|
||||
import org.polydev.gaea.math.ProbabilityCollection;
|
||||
|
||||
public final class FailoverDecorator extends UserDefinedDecorator {
|
||||
public FailoverDecorator() {
|
||||
super(new ProbabilityCollection<>(), new ProbabilityCollection<>(), 0, 0);
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
package com.dfsek.terra.biome.failsafe;
|
||||
|
||||
import com.dfsek.terra.generation.UserDefinedGenerator;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.polydev.gaea.world.palette.Palette;
|
||||
import org.polydev.gaea.world.palette.RandomPalette;
|
||||
import parsii.tokenizer.ParseException;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Random;
|
||||
import java.util.TreeMap;
|
||||
|
||||
public final class FailoverGenerator extends UserDefinedGenerator {
|
||||
private static final TreeMap<Integer, Palette<BlockData>> palette = new TreeMap<>();
|
||||
|
||||
static {
|
||||
palette.put(255, new RandomPalette<BlockData>(new Random(2403)).add(Material.STONE.createBlockData(), 1));
|
||||
}
|
||||
|
||||
public FailoverGenerator() throws ParseException {
|
||||
super("0", null, new HashMap<>(), palette, new TreeMap<>(), new HashMap<>(), false);
|
||||
}
|
||||
}
|
||||
@@ -57,7 +57,7 @@ public class TerraBiomeGrid extends BiomeGrid {
|
||||
if(failNum % 256 == 0)
|
||||
LangUtil.log("error.severe-config", Level.SEVERE, String.valueOf(x), String.valueOf(z));
|
||||
failNum++;
|
||||
return ConfigUtil.failType.fail();
|
||||
return null;
|
||||
}
|
||||
if(erode != null && b.isErodible() && erode.isEroded(xp, zp)) {
|
||||
return erosionGrid.getBiome(xp, zp, phase);
|
||||
|
||||
Reference in New Issue
Block a user