mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2025-07-18 18:42:30 +00:00
Begin work on languages, general cleanup, fix minor local sea level issues.
This commit is contained in:
parent
605dd6aadc
commit
c107f98550
@ -8,6 +8,9 @@ import org.bukkit.entity.Player;
|
|||||||
import org.polydev.gaea.biome.Biome;
|
import org.polydev.gaea.biome.Biome;
|
||||||
import org.polydev.gaea.generation.GenerationPhase;
|
import org.polydev.gaea.generation.GenerationPhase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Runnable that locates a biome
|
||||||
|
*/
|
||||||
public class AsyncBiomeFinder implements Runnable {
|
public class AsyncBiomeFinder implements Runnable {
|
||||||
private final TerraBiomeGrid grid;
|
private final TerraBiomeGrid grid;
|
||||||
private final int centerX;
|
private final int centerX;
|
||||||
|
@ -1,11 +1,22 @@
|
|||||||
package com.dfsek.terra.biome;
|
package com.dfsek.terra.biome;
|
||||||
|
|
||||||
|
import com.dfsek.terra.procgen.math.Vector2;
|
||||||
import org.polydev.gaea.math.FastNoise;
|
import org.polydev.gaea.math.FastNoise;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Offset a coordinate pair by an amount.
|
||||||
|
*/
|
||||||
public class CoordinatePerturb {
|
public class CoordinatePerturb {
|
||||||
private final FastNoise perturbX;
|
private final FastNoise perturbX;
|
||||||
private final FastNoise perturbZ;
|
private final FastNoise perturbZ;
|
||||||
private final int amplitude;
|
private final int amplitude;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a CoordinatePerturb object with a given frequency, amplitude, and seed.
|
||||||
|
* @param frequency Noise frequency
|
||||||
|
* @param amplitude Offset amplitude
|
||||||
|
* @param seed Noise seed
|
||||||
|
*/
|
||||||
public CoordinatePerturb(float frequency, int amplitude, long seed) {
|
public CoordinatePerturb(float frequency, int amplitude, long seed) {
|
||||||
perturbX = new FastNoise((int) seed);
|
perturbX = new FastNoise((int) seed);
|
||||||
perturbX.setNoiseType(FastNoise.NoiseType.Simplex);
|
perturbX.setNoiseType(FastNoise.NoiseType.Simplex);
|
||||||
@ -15,7 +26,14 @@ public class CoordinatePerturb {
|
|||||||
perturbZ.setFrequency(frequency);
|
perturbZ.setFrequency(frequency);
|
||||||
this.amplitude = amplitude;
|
this.amplitude = amplitude;
|
||||||
}
|
}
|
||||||
public int[] getShiftedCoords(int x, int z) {
|
|
||||||
return new int[] {(int) (perturbX.getNoise(x, z)*amplitude+x), (int) (perturbZ.getNoise(x, z)*amplitude+z)};
|
/**
|
||||||
|
* Offset a coordinate pair
|
||||||
|
* @param x X coordinate
|
||||||
|
* @param z Z coordinate
|
||||||
|
* @return Vector2 containing offset coordinates
|
||||||
|
*/
|
||||||
|
public Vector2 getShiftedCoords(int x, int z) {
|
||||||
|
return new Vector2(perturbX.getNoise(x, z)*amplitude+x, perturbZ.getNoise(x, z)*amplitude+z);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ package com.dfsek.terra.biome;
|
|||||||
|
|
||||||
import com.dfsek.terra.config.base.ConfigPack;
|
import com.dfsek.terra.config.base.ConfigPack;
|
||||||
import com.dfsek.terra.config.base.ConfigUtil;
|
import com.dfsek.terra.config.base.ConfigUtil;
|
||||||
|
import com.dfsek.terra.procgen.math.Vector2;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
@ -19,14 +20,12 @@ public class TerraBiomeGrid extends BiomeGrid {
|
|||||||
private UserDefinedGrid erosionGrid;
|
private UserDefinedGrid erosionGrid;
|
||||||
|
|
||||||
private final BiomeZone zone;
|
private final BiomeZone zone;
|
||||||
private final boolean perturbPaletteOnly;
|
|
||||||
|
|
||||||
public TerraBiomeGrid(World w, float freq1, float freq2, BiomeZone zone, ConfigPack c, UserDefinedGrid erosion) {
|
public TerraBiomeGrid(World w, float freq1, float freq2, BiomeZone zone, ConfigPack c, UserDefinedGrid erosion) {
|
||||||
super(w, freq1, freq2);
|
super(w, freq1, freq2);
|
||||||
if(c.biomeBlend) {
|
if(c.biomeBlend) {
|
||||||
perturb = new CoordinatePerturb(c.blendFreq, c.blendAmp, w.getSeed());
|
perturb = new CoordinatePerturb(c.blendFreq, c.blendAmp, w.getSeed());
|
||||||
}
|
}
|
||||||
perturbPaletteOnly = c.perturbPaletteOnly;
|
|
||||||
this.zone = zone;
|
this.zone = zone;
|
||||||
if(c.erosionEnable) {
|
if(c.erosionEnable) {
|
||||||
erode = new ErosionNoise(c.erosionFreq, c.erosionThresh, w.getSeed());
|
erode = new ErosionNoise(c.erosionFreq, c.erosionThresh, w.getSeed());
|
||||||
@ -38,10 +37,10 @@ public class TerraBiomeGrid extends BiomeGrid {
|
|||||||
public Biome getBiome(int x, int z, GenerationPhase phase) {
|
public Biome getBiome(int x, int z, GenerationPhase phase) {
|
||||||
int xp = x;
|
int xp = x;
|
||||||
int zp = z;
|
int zp = z;
|
||||||
if(perturb != null && (!perturbPaletteOnly || phase.equals(GenerationPhase.PALETTE_APPLY))) {
|
if(perturb != null && phase.equals(GenerationPhase.PALETTE_APPLY)) {
|
||||||
int[] perturbCoords = perturb.getShiftedCoords(x, z);
|
Vector2 perturbCoords = perturb.getShiftedCoords(x, z);
|
||||||
xp = perturbCoords[0];
|
xp = (int) perturbCoords.getX();
|
||||||
zp = perturbCoords[1];
|
zp = (int) perturbCoords.getZ();
|
||||||
}
|
}
|
||||||
|
|
||||||
UserDefinedBiome b;
|
UserDefinedBiome b;
|
||||||
|
@ -9,6 +9,9 @@ import org.polydev.gaea.structures.features.Feature;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class representing a config-defined biome
|
||||||
|
*/
|
||||||
public class UserDefinedBiome implements Biome {
|
public class UserDefinedBiome implements Biome {
|
||||||
private final UserDefinedGenerator gen;
|
private final UserDefinedGenerator gen;
|
||||||
private final UserDefinedDecorator decorator;
|
private final UserDefinedDecorator decorator;
|
||||||
|
@ -27,7 +27,7 @@ public abstract class WorldCommand extends PlayerCommand {
|
|||||||
if(sender.getWorld().getGenerator() instanceof TerraChunkGenerator) {
|
if(sender.getWorld().getGenerator() instanceof TerraChunkGenerator) {
|
||||||
return execute(sender, command, label, args, sender.getWorld());
|
return execute(sender, command, label, args, sender.getWorld());
|
||||||
} else {
|
} else {
|
||||||
sender.sendMessage("World is not a Terra world!");
|
sender.sendMessage("This world is not a Terra world!");
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -60,7 +60,6 @@ public class ConfigPack extends YamlConfiguration {
|
|||||||
public int blendAmp;
|
public int blendAmp;
|
||||||
public boolean biomeBlend;
|
public boolean biomeBlend;
|
||||||
public float blendFreq;
|
public float blendFreq;
|
||||||
public boolean perturbPaletteOnly;
|
|
||||||
|
|
||||||
public ConfigPack(JavaPlugin main, File file) throws IOException, InvalidConfigurationException {
|
public ConfigPack(JavaPlugin main, File file) throws IOException, InvalidConfigurationException {
|
||||||
long l = System.nanoTime();
|
long l = System.nanoTime();
|
||||||
@ -94,7 +93,6 @@ public class ConfigPack extends YamlConfiguration {
|
|||||||
biomeBlend = getBoolean("blend.enable", false);
|
biomeBlend = getBoolean("blend.enable", false);
|
||||||
blendAmp = getInt("blend.amplitude", 8);
|
blendAmp = getInt("blend.amplitude", 8);
|
||||||
blendFreq = (float) getDouble("blend.frequency", 0.01);
|
blendFreq = (float) getDouble("blend.frequency", 0.01);
|
||||||
perturbPaletteOnly = getBoolean("blend.ignore-terrain", true);
|
|
||||||
|
|
||||||
erosionEnable = getBoolean("erode.enable", false);
|
erosionEnable = getBoolean("erode.enable", false);
|
||||||
erosionFreq = (float) getDouble("erode.frequency", 0.01);
|
erosionFreq = (float) getDouble("erode.frequency", 0.01);
|
||||||
|
@ -1,4 +0,0 @@
|
|||||||
package com.dfsek.terra.config.base;
|
|
||||||
|
|
||||||
public final class LangUtil {
|
|
||||||
}
|
|
24
src/main/java/com/dfsek/terra/config/lang/LangUtil.java
Normal file
24
src/main/java/com/dfsek/terra/config/lang/LangUtil.java
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
package com.dfsek.terra.config.lang;
|
||||||
|
|
||||||
|
import com.dfsek.terra.Terra;
|
||||||
|
import org.bukkit.configuration.InvalidConfigurationException;
|
||||||
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
public final class LangUtil {
|
||||||
|
private static Language language;
|
||||||
|
private static Logger logger;
|
||||||
|
public static void load(String langID, JavaPlugin main) {
|
||||||
|
logger = main.getLogger();
|
||||||
|
try {
|
||||||
|
language = new Language(new File(Terra.getInstance().getDataFolder(), "lang" + File.separator + langID + ".yml"));
|
||||||
|
} catch(InvalidConfigurationException | IOException e) {
|
||||||
|
logger.severe("Unable to load language: " + langID);
|
||||||
|
e.printStackTrace();
|
||||||
|
logger.severe("Double-check your configuration before reporting this to Terra!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
29
src/main/java/com/dfsek/terra/config/lang/Language.java
Normal file
29
src/main/java/com/dfsek/terra/config/lang/Language.java
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
package com.dfsek.terra.config.lang;
|
||||||
|
|
||||||
|
import org.bukkit.configuration.InvalidConfigurationException;
|
||||||
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class Language extends YamlConfiguration {
|
||||||
|
private final Map<String, Message> messages;
|
||||||
|
public Language(File file) throws IOException, InvalidConfigurationException {
|
||||||
|
load(file);
|
||||||
|
messages = new HashMap<>();
|
||||||
|
messages.put("enable", new MultiLineMessage(getStringList("enable")));
|
||||||
|
messages.put("disable", new MultiLineMessage(getStringList("disable")));
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void load(@NotNull File file) throws IOException, InvalidConfigurationException {
|
||||||
|
super.load(file);
|
||||||
|
}
|
||||||
|
public Message getMessage(String id) {
|
||||||
|
Message temp = messages.get(id);
|
||||||
|
if(temp == null || temp.isEmpty()) return new SingleLineMessage(id + ":translation_undefined");
|
||||||
|
return temp;
|
||||||
|
}
|
||||||
|
}
|
12
src/main/java/com/dfsek/terra/config/lang/Message.java
Normal file
12
src/main/java/com/dfsek/terra/config/lang/Message.java
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
package com.dfsek.terra.config.lang;
|
||||||
|
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
public interface Message {
|
||||||
|
void log(Logger logger, Level level);
|
||||||
|
void send(CommandSender sender);
|
||||||
|
boolean isEmpty();
|
||||||
|
}
|
@ -0,0 +1,32 @@
|
|||||||
|
package com.dfsek.terra.config.lang;
|
||||||
|
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
public class MultiLineMessage implements Message {
|
||||||
|
private final List<String> message;
|
||||||
|
public MultiLineMessage(List<String> message) {
|
||||||
|
this.message = message;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void log(Logger logger, Level level) {
|
||||||
|
for(String line: message) {
|
||||||
|
logger.log(level, line);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void send(CommandSender sender) {
|
||||||
|
for(String line: message) {
|
||||||
|
sender.sendMessage(line);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isEmpty() {
|
||||||
|
return message == null || message.isEmpty();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,27 @@
|
|||||||
|
package com.dfsek.terra.config.lang;
|
||||||
|
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
public class SingleLineMessage implements Message {
|
||||||
|
private final String message;
|
||||||
|
public SingleLineMessage(String message) {
|
||||||
|
this.message = message;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void log(Logger logger, Level level) {
|
||||||
|
logger.log(level, message);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void send(CommandSender sender) {
|
||||||
|
sender.sendMessage(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isEmpty() {
|
||||||
|
return message == null || message.equals("");
|
||||||
|
}
|
||||||
|
}
|
@ -14,6 +14,7 @@ import com.dfsek.terra.population.SnowPopulator;
|
|||||||
import com.dfsek.terra.population.StructurePopulator;
|
import com.dfsek.terra.population.StructurePopulator;
|
||||||
import com.dfsek.terra.population.TreePopulator;
|
import com.dfsek.terra.population.TreePopulator;
|
||||||
import com.dfsek.terra.structure.StructureSpawnRequirement;
|
import com.dfsek.terra.structure.StructureSpawnRequirement;
|
||||||
|
import com.dfsek.terra.util.DataUtil;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
@ -70,10 +71,11 @@ public class TerraChunkGenerator extends GaeaChunkGenerator {
|
|||||||
int paletteLevel = 0;
|
int paletteLevel = 0;
|
||||||
int cx = xOrig + x;
|
int cx = xOrig + x;
|
||||||
int cz = zOrig + z;
|
int cz = zOrig + z;
|
||||||
|
Biome orig = getBiomeGrid(world).getBiome(xOrig+x, zOrig+z, GenerationPhase.BASE);
|
||||||
Biome b = getBiomeGrid(world).getBiome(xOrig+x, zOrig+z, GenerationPhase.PALETTE_APPLY);
|
Biome b = getBiomeGrid(world).getBiome(xOrig+x, zOrig+z, GenerationPhase.PALETTE_APPLY);
|
||||||
BiomeConfig c = config.getBiome((UserDefinedBiome) b);
|
BiomeConfig c = config.getBiome((UserDefinedBiome) b);
|
||||||
BiomeSlabConfig slab = c.getSlabs();
|
BiomeSlabConfig slab = c.getSlabs();
|
||||||
int sea = c.getOcean().getSeaLevel();
|
int sea = config.getBiome((UserDefinedBiome) orig).getOcean().getSeaLevel();
|
||||||
Palette<BlockData> seaPalette = c.getOcean().getOcean();
|
Palette<BlockData> seaPalette = c.getOcean().getOcean();
|
||||||
for(int y = world.getMaxHeight()-1; y >= 0; y--) {
|
for(int y = world.getMaxHeight()-1; y >= 0; y--) {
|
||||||
if(super.getInterpolatedNoise(x, y, z) > 0) {
|
if(super.getInterpolatedNoise(x, y, z) > 0) {
|
||||||
|
@ -2,6 +2,7 @@ package com.dfsek.terra.generation;
|
|||||||
|
|
||||||
import com.dfsek.terra.math.NoiseFunction2;
|
import com.dfsek.terra.math.NoiseFunction2;
|
||||||
import com.dfsek.terra.math.NoiseFunction3;
|
import com.dfsek.terra.math.NoiseFunction3;
|
||||||
|
import com.dfsek.terra.util.DataUtil;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.data.BlockData;
|
import org.bukkit.block.data.BlockData;
|
||||||
import org.polydev.gaea.biome.Generator;
|
import org.polydev.gaea.biome.Generator;
|
||||||
|
@ -4,7 +4,7 @@ import com.dfsek.terra.TerraWorld;
|
|||||||
import com.dfsek.terra.biome.TerraBiomeGrid;
|
import com.dfsek.terra.biome.TerraBiomeGrid;
|
||||||
import com.dfsek.terra.biome.UserDefinedBiome;
|
import com.dfsek.terra.biome.UserDefinedBiome;
|
||||||
import com.dfsek.terra.config.base.ConfigUtil;
|
import com.dfsek.terra.config.base.ConfigUtil;
|
||||||
import com.dfsek.terra.generation.DataUtil;
|
import com.dfsek.terra.util.DataUtil;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Chunk;
|
import org.bukkit.Chunk;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@ -15,14 +15,12 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
import org.polydev.gaea.generation.GenerationPhase;
|
import org.polydev.gaea.generation.GenerationPhase;
|
||||||
import org.polydev.gaea.population.GaeaBlockPopulator;
|
import org.polydev.gaea.population.GaeaBlockPopulator;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
public class SnowPopulator extends GaeaBlockPopulator {
|
public class SnowPopulator extends GaeaBlockPopulator {
|
||||||
private static final Set<Material> blacklistSpawn = new HashSet<>();
|
private static final Set<Material> blacklistSpawn = new HashSet<>();
|
||||||
private static final BlockData snow = Material.SNOW.createBlockData();
|
|
||||||
static {
|
static {
|
||||||
for(Material m : Material.values()) {
|
for(Material m : Material.values()) {
|
||||||
String name = m.toString().toLowerCase();
|
String name = m.toString().toLowerCase();
|
||||||
@ -35,7 +33,8 @@ public class SnowPopulator extends GaeaBlockPopulator {
|
|||||||
|| name.contains("door")
|
|| name.contains("door")
|
||||||
|| name.contains("repeater")
|
|| name.contains("repeater")
|
||||||
|| name.equals("lily_pad")
|
|| name.equals("lily_pad")
|
||||||
|| name.equals("snow")) blacklistSpawn.add(m);
|
|| name.equals("snow")
|
||||||
|
|| name.equals("pane")) blacklistSpawn.add(m);
|
||||||
}
|
}
|
||||||
blacklistSpawn.add(Material.END_STONE);
|
blacklistSpawn.add(Material.END_STONE);
|
||||||
if(ConfigUtil.debug)
|
if(ConfigUtil.debug)
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package com.dfsek.terra.generation;
|
package com.dfsek.terra.util;
|
||||||
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.data.BlockData;
|
import org.bukkit.block.data.BlockData;
|
9
src/main/resources/lang/en_us.yml
Normal file
9
src/main/resources/lang/en_us.yml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
enable:
|
||||||
|
- "If you like Terra, please consider supporting the project on Patreon!"
|
||||||
|
- "You'll gain access to experimental features before they are released!"
|
||||||
|
- "Support the project here: https://www.patreon.com/dfsek"
|
||||||
|
disable:
|
||||||
|
- "Thank you for using Terra!"
|
||||||
|
command:
|
||||||
|
player-only: "This command is for players only!"
|
||||||
|
terra-world: "This command must be executed in a Terra world!"
|
Loading…
x
Reference in New Issue
Block a user