mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-02-16 10:30:42 +00:00
Implement a whole bunch of stuff
This commit is contained in:
@@ -34,7 +34,6 @@ version = versionObj
|
||||
dependencies {
|
||||
implementation("org.apache.commons:commons-rng-core:1.3")
|
||||
implementation("net.jafama:jafama:2.3.2")
|
||||
implementation("co.aikar:taskchain-bukkit:3.7.2")
|
||||
|
||||
compileOnly("org.jetbrains:annotations:20.1.0")
|
||||
|
||||
@@ -103,7 +102,6 @@ tasks.named<ShadowJar>("shadowJar") {
|
||||
relocate("net.jafama", "com.dfsek.terra.lib.jafama")
|
||||
relocate("com.dfsek.tectonic", "com.dfsek.terra.lib.tectonic")
|
||||
relocate("net.jafama", "com.dfsek.terra.lib.jafama")
|
||||
relocate("co.aikar.taskchain", "com.dfsek.terra.lib.taskchain")
|
||||
minimize()
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.dfsek.terra;
|
||||
import com.dfsek.terra.api.gaea.profiler.DataType;
|
||||
import com.dfsek.terra.api.gaea.profiler.Measurement;
|
||||
import com.dfsek.terra.api.gaea.profiler.WorldProfiler;
|
||||
import org.bukkit.World;
|
||||
import com.dfsek.terra.api.generic.world.World;
|
||||
|
||||
public class TerraProfiler extends WorldProfiler {
|
||||
public TerraProfiler(World w) {
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
package com.dfsek.terra;
|
||||
|
||||
import com.dfsek.terra.api.gaea.biome.BiomeGrid;
|
||||
import com.dfsek.terra.api.generic.TerraPlugin;
|
||||
import com.dfsek.terra.api.generic.generator.TerraChunkGenerator;
|
||||
import com.dfsek.terra.api.generic.world.World;
|
||||
import com.dfsek.terra.biome.BiomeZone;
|
||||
import com.dfsek.terra.biome.grid.master.TerraBiomeGrid;
|
||||
import com.dfsek.terra.biome.grid.master.TerraRadialBiomeGrid;
|
||||
@@ -9,8 +12,6 @@ import com.dfsek.terra.config.base.ConfigPack;
|
||||
import com.dfsek.terra.config.base.ConfigPackTemplate;
|
||||
import com.dfsek.terra.config.builder.biomegrid.BiomeGridBuilder;
|
||||
import com.dfsek.terra.debug.Debug;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
|
||||
public class TerraWorld {
|
||||
private final TerraBiomeGrid grid;
|
||||
@@ -20,7 +21,7 @@ public class TerraWorld {
|
||||
private final TerraProfiler profiler;
|
||||
|
||||
|
||||
public TerraWorld(World w, ConfigPack c) {
|
||||
public TerraWorld(World w, ConfigPack c, TerraPlugin main) {
|
||||
safe = true;
|
||||
config = c;
|
||||
profiler = new TerraProfiler(w);
|
||||
@@ -39,10 +40,10 @@ public class TerraWorld {
|
||||
} catch(NullPointerException e) {
|
||||
safe = false;
|
||||
Debug.stack(e);
|
||||
Bukkit.getLogger().severe("No such BiomeGrid " + partName);
|
||||
Bukkit.getLogger().severe("Please check configuration files for errors. Configuration errors will have been reported during initialization.");
|
||||
Bukkit.getLogger().severe("ONLY report this to Terra if you are SURE your config is error-free.");
|
||||
Bukkit.getLogger().severe("Terrain will NOT generate properly at this point. Correct your config before using your server!");
|
||||
main.getLogger().severe("No such BiomeGrid " + partName);
|
||||
main.getLogger().severe("Please check configuration files for errors. Configuration errors will have been reported during initialization.");
|
||||
main.getLogger().severe("ONLY report this to Terra if you are SURE your config is error-free.");
|
||||
main.getLogger().severe("Terrain will NOT generate properly at this point. Correct your config before using your server!");
|
||||
}
|
||||
}
|
||||
zone = new BiomeZone(w, c, definedGrids);
|
||||
|
||||
68
src/main/java/com/dfsek/terra/api/GenericLoaders.java
Normal file
68
src/main/java/com/dfsek/terra/api/GenericLoaders.java
Normal file
@@ -0,0 +1,68 @@
|
||||
package com.dfsek.terra.api;
|
||||
|
||||
import com.dfsek.tectonic.loading.TypeRegistry;
|
||||
import com.dfsek.terra.api.gaea.math.ProbabilityCollection;
|
||||
import com.dfsek.terra.api.gaea.math.Range;
|
||||
import com.dfsek.terra.api.generic.TerraPlugin;
|
||||
import com.dfsek.terra.biome.grid.master.TerraBiomeGrid;
|
||||
import com.dfsek.terra.biome.palette.PaletteHolder;
|
||||
import com.dfsek.terra.biome.palette.PaletteLayer;
|
||||
import com.dfsek.terra.carving.CarverPalette;
|
||||
import com.dfsek.terra.config.loaders.ImageLoaderLoader;
|
||||
import com.dfsek.terra.config.loaders.MaterialSetLoader;
|
||||
import com.dfsek.terra.config.loaders.ProbabilityCollectionLoader;
|
||||
import com.dfsek.terra.config.loaders.RangeLoader;
|
||||
import com.dfsek.terra.config.loaders.config.FloraLayerLoader;
|
||||
import com.dfsek.terra.config.loaders.config.GridSpawnLoader;
|
||||
import com.dfsek.terra.config.loaders.config.NoiseBuilderLoader;
|
||||
import com.dfsek.terra.config.loaders.config.OreConfigLoader;
|
||||
import com.dfsek.terra.config.loaders.config.OreHolderLoader;
|
||||
import com.dfsek.terra.config.loaders.config.StructureFeatureLoader;
|
||||
import com.dfsek.terra.config.loaders.config.TreeLayerLoader;
|
||||
import com.dfsek.terra.config.loaders.palette.CarverPaletteLoader;
|
||||
import com.dfsek.terra.config.loaders.palette.PaletteHolderLoader;
|
||||
import com.dfsek.terra.config.loaders.palette.PaletteLayerLoader;
|
||||
import com.dfsek.terra.generation.config.NoiseBuilder;
|
||||
import com.dfsek.terra.generation.items.flora.FloraLayer;
|
||||
import com.dfsek.terra.generation.items.flora.TerraFlora;
|
||||
import com.dfsek.terra.generation.items.ores.Ore;
|
||||
import com.dfsek.terra.generation.items.ores.OreConfig;
|
||||
import com.dfsek.terra.generation.items.ores.OreHolder;
|
||||
import com.dfsek.terra.generation.items.tree.TreeLayer;
|
||||
import com.dfsek.terra.image.ImageLoader;
|
||||
import com.dfsek.terra.procgen.GridSpawn;
|
||||
import com.dfsek.terra.structure.features.Feature;
|
||||
import com.dfsek.terra.util.MaterialSet;
|
||||
import com.dfsek.terra.util.StructureTypeEnum;
|
||||
|
||||
public class GenericLoaders implements LoaderRegistrar {
|
||||
private final TerraPlugin main;
|
||||
|
||||
public GenericLoaders(TerraPlugin main) {
|
||||
this.main = main;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register(TypeRegistry registry) {
|
||||
registry.registerLoader(ProbabilityCollection.class, new ProbabilityCollectionLoader())
|
||||
.registerLoader(Range.class, new RangeLoader())
|
||||
.registerLoader(CarverPalette.class, new CarverPaletteLoader())
|
||||
.registerLoader(GridSpawn.class, new GridSpawnLoader())
|
||||
.registerLoader(PaletteHolder.class, new PaletteHolderLoader())
|
||||
.registerLoader(PaletteLayer.class, new PaletteLayerLoader())
|
||||
.registerLoader(FloraLayer.class, new FloraLayerLoader())
|
||||
.registerLoader(Ore.Type.class, (t, o, l) -> Ore.Type.valueOf((String) o))
|
||||
.registerLoader(OreConfig.class, new OreConfigLoader())
|
||||
.registerLoader(NoiseBuilder.class, new NoiseBuilderLoader())
|
||||
.registerLoader(TreeLayer.class, new TreeLayerLoader(main))
|
||||
.registerLoader(MaterialSet.class, new MaterialSetLoader())
|
||||
.registerLoader(OreHolder.class, new OreHolderLoader())
|
||||
.registerLoader(Feature.class, new StructureFeatureLoader())
|
||||
.registerLoader(ImageLoader.class, new ImageLoaderLoader())
|
||||
.registerLoader(TerraBiomeGrid.Type.class, (t, o, l) -> TerraBiomeGrid.Type.valueOf((String) o))
|
||||
.registerLoader(StructureTypeEnum.class, (t, o, l) -> StructureTypeEnum.valueOf((String) o))
|
||||
.registerLoader(ImageLoader.Channel.class, (t, o, l) -> ImageLoader.Channel.valueOf((String) o))
|
||||
.registerLoader(ImageLoader.Align.class, (t, o, l) -> ImageLoader.Align.valueOf((String) o))
|
||||
.registerLoader(TerraFlora.Search.class, (t, o, l) -> TerraFlora.Search.valueOf((String) o));
|
||||
}
|
||||
}
|
||||
7
src/main/java/com/dfsek/terra/api/LoaderRegistrar.java
Normal file
7
src/main/java/com/dfsek/terra/api/LoaderRegistrar.java
Normal file
@@ -0,0 +1,7 @@
|
||||
package com.dfsek.terra.api;
|
||||
|
||||
import com.dfsek.tectonic.loading.TypeRegistry;
|
||||
|
||||
public interface LoaderRegistrar {
|
||||
void register(TypeRegistry registry);
|
||||
}
|
||||
@@ -1,58 +1,27 @@
|
||||
package com.dfsek.terra;
|
||||
package com.dfsek.terra.api.bukkit;
|
||||
|
||||
import com.dfsek.tectonic.loading.TypeRegistry;
|
||||
import com.dfsek.terra.api.bukkit.BukkitWorldHandle;
|
||||
import com.dfsek.terra.TerraWorld;
|
||||
import com.dfsek.terra.api.bukkit.generator.BukkitChunkGeneratorWrapper;
|
||||
import com.dfsek.terra.api.gaea.GaeaPlugin;
|
||||
import com.dfsek.terra.api.gaea.generation.GaeaChunkGenerator;
|
||||
import com.dfsek.terra.api.gaea.lang.Language;
|
||||
import com.dfsek.terra.api.gaea.math.ProbabilityCollection;
|
||||
import com.dfsek.terra.api.gaea.math.Range;
|
||||
import com.dfsek.terra.api.generic.TerraPlugin;
|
||||
import com.dfsek.terra.api.generic.world.World;
|
||||
import com.dfsek.terra.api.generic.world.WorldHandle;
|
||||
import com.dfsek.terra.biome.grid.master.TerraBiomeGrid;
|
||||
import com.dfsek.terra.biome.palette.PaletteHolder;
|
||||
import com.dfsek.terra.biome.palette.PaletteLayer;
|
||||
import com.dfsek.terra.carving.CarverPalette;
|
||||
import com.dfsek.terra.command.TerraCommand;
|
||||
import com.dfsek.terra.command.structure.LocateCommand;
|
||||
import com.dfsek.terra.config.base.ConfigPack;
|
||||
import com.dfsek.terra.config.base.PluginConfig;
|
||||
import com.dfsek.terra.config.lang.LangUtil;
|
||||
import com.dfsek.terra.config.loaders.ImageLoaderLoader;
|
||||
import com.dfsek.terra.config.loaders.MaterialSetLoader;
|
||||
import com.dfsek.terra.config.loaders.ProbabilityCollectionLoader;
|
||||
import com.dfsek.terra.config.loaders.RangeLoader;
|
||||
import com.dfsek.terra.config.loaders.config.FloraLayerLoader;
|
||||
import com.dfsek.terra.config.loaders.config.GridSpawnLoader;
|
||||
import com.dfsek.terra.config.loaders.config.NoiseBuilderLoader;
|
||||
import com.dfsek.terra.config.loaders.config.OreConfigLoader;
|
||||
import com.dfsek.terra.config.loaders.config.OreHolderLoader;
|
||||
import com.dfsek.terra.config.loaders.config.StructureFeatureLoader;
|
||||
import com.dfsek.terra.config.loaders.config.TreeLayerLoader;
|
||||
import com.dfsek.terra.config.loaders.palette.CarverPaletteLoader;
|
||||
import com.dfsek.terra.config.loaders.palette.PaletteHolderLoader;
|
||||
import com.dfsek.terra.config.loaders.palette.PaletteLayerLoader;
|
||||
import com.dfsek.terra.debug.Debug;
|
||||
import com.dfsek.terra.generation.config.NoiseBuilder;
|
||||
import com.dfsek.terra.generation.items.flora.FloraLayer;
|
||||
import com.dfsek.terra.generation.items.flora.TerraFlora;
|
||||
import com.dfsek.terra.generation.items.ores.Ore;
|
||||
import com.dfsek.terra.generation.items.ores.OreConfig;
|
||||
import com.dfsek.terra.generation.items.ores.OreHolder;
|
||||
import com.dfsek.terra.generation.items.tree.TreeLayer;
|
||||
import com.dfsek.terra.image.ImageLoader;
|
||||
import com.dfsek.terra.generation.TerraChunkGenerator;
|
||||
import com.dfsek.terra.listeners.EventListener;
|
||||
import com.dfsek.terra.listeners.SpigotListener;
|
||||
import com.dfsek.terra.procgen.GridSpawn;
|
||||
import com.dfsek.terra.registry.ConfigRegistry;
|
||||
import com.dfsek.terra.structure.features.Feature;
|
||||
import com.dfsek.terra.util.MaterialSet;
|
||||
import com.dfsek.terra.util.PaperUtil;
|
||||
import com.dfsek.terra.util.StructureTypeEnum;
|
||||
import org.bstats.bukkit.Metrics;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.command.PluginCommand;
|
||||
@@ -66,7 +35,7 @@ import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
|
||||
public class Terra extends GaeaPlugin implements TerraPlugin {
|
||||
public class TerraBukkitPlugin extends GaeaPlugin implements TerraPlugin {
|
||||
private final Map<String, TerraChunkGenerator> generatorMap = new HashMap<>();
|
||||
private final Map<World, TerraWorld> worldMap = new HashMap<>();
|
||||
private final Map<String, ConfigPack> worlds = new HashMap<>();
|
||||
@@ -78,7 +47,7 @@ public class Terra extends GaeaPlugin implements TerraPlugin {
|
||||
Map<World, TerraWorld> newMap = new HashMap<>();
|
||||
worldMap.forEach((world, tw) -> {
|
||||
String packID = tw.getConfig().getTemplate().getID();
|
||||
newMap.put(world, new TerraWorld(world, registry.get(packID)));
|
||||
newMap.put(world, new TerraWorld(world, registry.get(packID), this));
|
||||
});
|
||||
worldMap.clear();
|
||||
worldMap.putAll(newMap);
|
||||
@@ -136,11 +105,11 @@ public class Terra extends GaeaPlugin implements TerraPlugin {
|
||||
|
||||
@Override
|
||||
public @Nullable ChunkGenerator getDefaultWorldGenerator(@NotNull String worldName, @Nullable String id) {
|
||||
return generatorMap.computeIfAbsent(worldName, name -> {
|
||||
return new BukkitChunkGeneratorWrapper(generatorMap.computeIfAbsent(worldName, name -> {
|
||||
if(!registry.contains(id)) throw new IllegalArgumentException("No such config pack \"" + id + "\"");
|
||||
worlds.put(worldName, registry.get(id));
|
||||
return new TerraChunkGenerator(registry.get(id), this);
|
||||
});
|
||||
}));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -148,43 +117,12 @@ public class Terra extends GaeaPlugin implements TerraPlugin {
|
||||
return config.isDebug();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends GaeaChunkGenerator> getGeneratorClass() {
|
||||
return TerraChunkGenerator.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Language getLanguage() {
|
||||
return LangUtil.getLanguage();
|
||||
}
|
||||
|
||||
public void registerAllLoaders(TypeRegistry registry) {
|
||||
registry.registerLoader(ProbabilityCollection.class, new ProbabilityCollectionLoader())
|
||||
.registerLoader(Range.class, new RangeLoader())
|
||||
.registerLoader(CarverPalette.class, new CarverPaletteLoader())
|
||||
.registerLoader(GridSpawn.class, new GridSpawnLoader())
|
||||
.registerLoader(PaletteHolder.class, new PaletteHolderLoader())
|
||||
.registerLoader(PaletteLayer.class, new PaletteLayerLoader())
|
||||
.registerLoader(Biome.class, (t, o, l) -> Biome.valueOf((String) o))
|
||||
.registerLoader(BlockData.class, (t, o, l) -> Bukkit.createBlockData((String) o))
|
||||
.registerLoader(Material.class, (t, o, l) -> Material.matchMaterial((String) o))
|
||||
.registerLoader(FloraLayer.class, new FloraLayerLoader())
|
||||
.registerLoader(Ore.Type.class, (t, o, l) -> Ore.Type.valueOf((String) o))
|
||||
.registerLoader(OreConfig.class, new OreConfigLoader())
|
||||
.registerLoader(NoiseBuilder.class, new NoiseBuilderLoader())
|
||||
.registerLoader(TreeLayer.class, new TreeLayerLoader(this))
|
||||
.registerLoader(MaterialSet.class, new MaterialSetLoader())
|
||||
.registerLoader(OreHolder.class, new OreHolderLoader())
|
||||
.registerLoader(Feature.class, new StructureFeatureLoader())
|
||||
.registerLoader(ImageLoader.class, new ImageLoaderLoader())
|
||||
.registerLoader(EntityType.class, (t, o, l) -> EntityType.valueOf((String) o))
|
||||
.registerLoader(TerraBiomeGrid.Type.class, (t, o, l) -> TerraBiomeGrid.Type.valueOf((String) o))
|
||||
.registerLoader(StructureTypeEnum.class, (t, o, l) -> StructureTypeEnum.valueOf((String) o))
|
||||
.registerLoader(ImageLoader.Channel.class, (t, o, l) -> ImageLoader.Channel.valueOf((String) o))
|
||||
.registerLoader(ImageLoader.Align.class, (t, o, l) -> ImageLoader.Align.valueOf((String) o))
|
||||
.registerLoader(TerraFlora.Search.class, (t, o, l) -> TerraFlora.Search.valueOf((String) o));
|
||||
}
|
||||
|
||||
public ConfigRegistry getRegistry() {
|
||||
return registry;
|
||||
}
|
||||
@@ -193,9 +131,9 @@ public class Terra extends GaeaPlugin implements TerraPlugin {
|
||||
if(!(w.getGenerator() instanceof TerraChunkGenerator)) throw new IllegalArgumentException("Not a Terra world!");
|
||||
if(!worlds.containsKey(w.getName())) {
|
||||
getLogger().warning("Unexpected world load detected: \"" + w.getName() + "\"");
|
||||
return new TerraWorld(w, ((TerraChunkGenerator) w.getGenerator()).getConfigPack());
|
||||
return new TerraWorld(w, ((TerraChunkGenerator) w.getGenerator()).getConfigPack(), this);
|
||||
}
|
||||
return worldMap.computeIfAbsent(w, world -> new TerraWorld(w, worlds.get(w.getName())));
|
||||
return worldMap.computeIfAbsent(w, world -> new TerraWorld(w, worlds.get(w.getName()), this));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -207,4 +145,12 @@ public class Terra extends GaeaPlugin implements TerraPlugin {
|
||||
public WorldHandle getHandle() {
|
||||
return handle;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register(TypeRegistry registry) {
|
||||
registry.registerLoader(Biome.class, (t, o, l) -> Biome.valueOf((String) o))
|
||||
.registerLoader(BlockData.class, (t, o, l) -> Bukkit.createBlockData((String) o))
|
||||
.registerLoader(Material.class, (t, o, l) -> Material.matchMaterial((String) o))
|
||||
.registerLoader(EntityType.class, (t, o, l) -> EntityType.valueOf((String) o));
|
||||
}
|
||||
}
|
||||
@@ -2,9 +2,11 @@ package com.dfsek.terra.api.bukkit.generator;
|
||||
|
||||
import com.dfsek.terra.api.bukkit.BukkitBiomeGrid;
|
||||
import com.dfsek.terra.api.bukkit.BukkitWorld;
|
||||
import com.dfsek.terra.api.bukkit.world.block.BukkitBlockData;
|
||||
import com.dfsek.terra.api.generic.generator.BlockPopulator;
|
||||
import com.dfsek.terra.api.generic.world.BiomeGrid;
|
||||
import com.dfsek.terra.api.generic.world.World;
|
||||
import com.dfsek.terra.api.generic.world.block.BlockData;
|
||||
import org.bukkit.generator.ChunkGenerator;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -50,12 +52,43 @@ public class BukkitChunkGenerator implements com.dfsek.terra.api.generic.generat
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChunkData generateChunkData(@NotNull World world, @NotNull Random random, int x, int z, @NotNull BiomeGrid biome, ChunkData data) {
|
||||
return new BukkitChunkGeneratorWrapper.BukkitChunkData(delegate.generateChunkData(((BukkitWorld) world).getHandle(), random, x, z, ((BukkitBiomeGrid) biome).getHandle()));
|
||||
public ChunkData generateChunkData(@NotNull World world, @NotNull Random random, int x, int z, @NotNull BiomeGrid biome) {
|
||||
return new BukkitChunkData(delegate.generateChunkData(((BukkitWorld) world).getHandle(), random, x, z, ((BukkitBiomeGrid) biome).getHandle()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BlockPopulator> getDefaultPopulators(World world) {
|
||||
return delegate.getDefaultPopulators(((BukkitWorld) world).getHandle()).stream().map(BukkitPopulator::new).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public static class BukkitChunkData implements ChunkData {
|
||||
|
||||
private final ChunkGenerator.ChunkData delegate;
|
||||
|
||||
public BukkitChunkData(ChunkGenerator.ChunkData delegate) {
|
||||
this.delegate = delegate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChunkGenerator.ChunkData getHandle() {
|
||||
return delegate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxHeight() {
|
||||
return delegate.getMaxHeight();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setBlock(int x, int y, int z, @NotNull BlockData blockData) {
|
||||
delegate.setBlock(x, y, z, ((BukkitBlockData) blockData).getHandle());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public @NotNull BlockData getBlockData(int x, int y, int z) {
|
||||
return new BukkitBlockData(delegate.getBlockData(x, y, z));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,8 +2,7 @@ package com.dfsek.terra.api.bukkit.generator;
|
||||
|
||||
import com.dfsek.terra.api.bukkit.BukkitBiomeGrid;
|
||||
import com.dfsek.terra.api.bukkit.BukkitWorld;
|
||||
import com.dfsek.terra.api.bukkit.world.block.BukkitBlockData;
|
||||
import com.dfsek.terra.api.generic.world.block.BlockData;
|
||||
import com.dfsek.terra.api.generic.generator.TerraChunkGenerator;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.generator.ChunkGenerator;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -11,48 +10,17 @@ import org.jetbrains.annotations.NotNull;
|
||||
import java.util.Random;
|
||||
|
||||
public class BukkitChunkGeneratorWrapper extends ChunkGenerator {
|
||||
private final com.dfsek.terra.api.generic.generator.ChunkGenerator delegate;
|
||||
private final TerraChunkGenerator delegate;
|
||||
|
||||
public BukkitChunkGeneratorWrapper(com.dfsek.terra.api.generic.generator.ChunkGenerator delegate) {
|
||||
public BukkitChunkGeneratorWrapper(TerraChunkGenerator delegate) {
|
||||
this.delegate = delegate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull ChunkData generateChunkData(@NotNull World world, @NotNull Random random, int x, int z, @NotNull BiomeGrid biome) {
|
||||
BukkitWorld bukkitWorld = new BukkitWorld(world);
|
||||
BukkitChunkData data = new BukkitChunkData(createChunkData(world));
|
||||
delegate.generateChunkData(bukkitWorld, random, x, z, new BukkitBiomeGrid(biome), data);
|
||||
BukkitChunkGenerator.BukkitChunkData data = new BukkitChunkGenerator.BukkitChunkData(createChunkData(world));
|
||||
delegate.generateChunkData(bukkitWorld, random, x, z, new BukkitBiomeGrid(biome), new BukkitChunkGenerator.BukkitChunkData(createChunkData(bukkitWorld.getHandle())));
|
||||
return data.getHandle();
|
||||
}
|
||||
|
||||
public static class BukkitChunkData implements com.dfsek.terra.api.generic.generator.ChunkGenerator.ChunkData {
|
||||
|
||||
private final ChunkGenerator.ChunkData delegate;
|
||||
|
||||
public BukkitChunkData(ChunkGenerator.ChunkData delegate) {
|
||||
this.delegate = delegate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChunkGenerator.ChunkData getHandle() {
|
||||
return delegate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxHeight() {
|
||||
return delegate.getMaxHeight();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setBlock(int x, int y, int z, @NotNull BlockData blockData) {
|
||||
delegate.setBlock(x, y, z, ((BukkitBlockData) blockData).getHandle());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public @NotNull BlockData getBlockData(int x, int y, int z) {
|
||||
return new BukkitBlockData(delegate.getBlockData(x, y, z));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.dfsek.terra.api.bukkit.world;
|
||||
|
||||
import com.dfsek.terra.api.generic.world.Biome;
|
||||
|
||||
public class BukkitBiome implements Biome {
|
||||
private final org.bukkit.block.Biome biome;
|
||||
|
||||
public BukkitBiome(org.bukkit.block.Biome biome) {
|
||||
this.biome = biome;
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.bukkit.block.Biome getHandle() {
|
||||
return biome;
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,9 @@
|
||||
package com.dfsek.terra.api.gaea;
|
||||
|
||||
import com.dfsek.terra.api.gaea.generation.GaeaChunkGenerator;
|
||||
import com.dfsek.terra.api.gaea.lang.Language;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public abstract class GaeaPlugin extends JavaPlugin {
|
||||
public abstract boolean isDebug();
|
||||
public abstract Class<? extends GaeaChunkGenerator> getGeneratorClass();
|
||||
public abstract Language getLanguage();
|
||||
}
|
||||
|
||||
@@ -2,8 +2,8 @@ package com.dfsek.terra.api.gaea.biome;
|
||||
|
||||
import com.dfsek.terra.api.gaea.generation.GenerationPhase;
|
||||
import com.dfsek.terra.api.gaea.math.FastNoiseLite;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import com.dfsek.terra.api.generic.world.World;
|
||||
import com.dfsek.terra.api.generic.world.vector.Location;
|
||||
|
||||
public abstract class BiomeGrid {
|
||||
private final FastNoiseLite noiseX;
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package com.dfsek.terra.api.gaea.command;
|
||||
|
||||
import com.dfsek.terra.api.gaea.generation.GaeaChunkGenerator;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.generator.ChunkGenerator;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
@@ -28,8 +28,7 @@ public abstract class WorldCommand extends PlayerCommand {
|
||||
*/
|
||||
@Override
|
||||
public final boolean execute(@NotNull Player sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
Class<? extends GaeaChunkGenerator> clazz = getMain().getGeneratorClass();
|
||||
if(clazz.isInstance(sender.getWorld().getGenerator())) {
|
||||
if(sender.getWorld().getGenerator() instanceof ChunkGenerator) { // TODO: implementation
|
||||
return execute(sender, command, label, args, sender.getWorld());
|
||||
} else {
|
||||
getMain().getLanguage().send("command.world", sender);
|
||||
|
||||
@@ -1,85 +0,0 @@
|
||||
package com.dfsek.terra.api.gaea.generation;
|
||||
|
||||
import com.dfsek.terra.api.gaea.biome.Biome;
|
||||
import com.dfsek.terra.api.gaea.math.FastNoiseLite;
|
||||
import com.dfsek.terra.api.gaea.profiler.ProfileFuture;
|
||||
import com.dfsek.terra.api.gaea.profiler.WorldProfiler;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.generator.ChunkGenerator;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
public abstract class GaeaChunkGenerator extends ChunkGenerator {
|
||||
private final ChunkInterpolator.InterpolationType interpolationType;
|
||||
private FastNoiseLite gen;
|
||||
private WorldProfiler profiler;
|
||||
|
||||
public GaeaChunkGenerator(ChunkInterpolator.InterpolationType type) {
|
||||
interpolationType = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull ChunkData generateChunkData(@NotNull World world, @NotNull Random random, int chunkX, int chunkZ, @NotNull BiomeGrid biome) {
|
||||
try(ProfileFuture ignore = measure("TotalChunkGenTime")) {
|
||||
if(gen == null) {
|
||||
gen = new FastNoiseLite((int) world.getSeed());
|
||||
gen.setNoiseType(FastNoiseLite.NoiseType.OpenSimplex2);
|
||||
gen.setFractalType(FastNoiseLite.FractalType.FBm);
|
||||
gen.setFractalOctaves(getNoiseOctaves(world));
|
||||
gen.setFrequency(getNoiseFrequency(world));
|
||||
}
|
||||
ChunkData chunk;
|
||||
ChunkInterpolator interp;
|
||||
try(ProfileFuture ignored = measure("ChunkBaseGenTime")) {
|
||||
interp = interpolationType.getInstance(world, chunkX, chunkZ, this.getBiomeGrid(world), gen);
|
||||
chunk = generateBase(world, random, chunkX, chunkZ, interp);
|
||||
}
|
||||
try(ProfileFuture ignored = measure("BiomeApplyTime")) {
|
||||
com.dfsek.terra.api.gaea.biome.BiomeGrid grid = getBiomeGrid(world);
|
||||
int xOrig = (chunkX << 4);
|
||||
int zOrig = (chunkZ << 4);
|
||||
for(byte x = 0; x < 4; x++) {
|
||||
for(byte z = 0; z < 4; z++) {
|
||||
int cx = xOrig + (x << 2);
|
||||
int cz = zOrig + (z << 2);
|
||||
Biome b = grid.getBiome(cx, cz, GenerationPhase.PALETTE_APPLY);
|
||||
biome.setBiome(x << 2, z << 2, b.getVanillaBiome());
|
||||
}
|
||||
}
|
||||
}
|
||||
for(GenerationPopulator g : getGenerationPopulators(world)) {
|
||||
g.populate(world, chunk, random, chunkX, chunkZ, interp);
|
||||
}
|
||||
return chunk;
|
||||
}
|
||||
}
|
||||
|
||||
public void attachProfiler(WorldProfiler p) {
|
||||
this.profiler = p;
|
||||
}
|
||||
|
||||
public WorldProfiler getProfiler() {
|
||||
return profiler;
|
||||
}
|
||||
|
||||
private ProfileFuture measure(String id) {
|
||||
if(profiler != null) return profiler.measure(id);
|
||||
return null;
|
||||
}
|
||||
|
||||
public abstract ChunkData generateBase(@NotNull World world, @NotNull Random random, int x, int z, ChunkInterpolator noise);
|
||||
|
||||
public abstract int getNoiseOctaves(World w);
|
||||
|
||||
public abstract double getNoiseFrequency(World w);
|
||||
|
||||
public abstract List<GenerationPopulator> getGenerationPopulators(World w);
|
||||
|
||||
public abstract com.dfsek.terra.api.gaea.biome.BiomeGrid getBiomeGrid(World w);
|
||||
|
||||
public FastNoiseLite getNoiseGenerator() {
|
||||
return gen;
|
||||
}
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
package com.dfsek.terra.api.gaea.generation;
|
||||
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.generator.ChunkGenerator;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public abstract class GenerationPopulator {
|
||||
public abstract void populate(World world, ChunkGenerator.ChunkData chunk, Random r, int chunkX, int chunkZ, ChunkInterpolator interp);
|
||||
}
|
||||
@@ -1,11 +1,11 @@
|
||||
package com.dfsek.terra.api.gaea.profiler;
|
||||
|
||||
import com.dfsek.terra.api.gaea.generation.GaeaChunkGenerator;
|
||||
import com.dfsek.terra.api.generic.generator.TerraChunkGenerator;
|
||||
import com.dfsek.terra.api.generic.world.World;
|
||||
import com.google.common.collect.BiMap;
|
||||
import com.google.common.collect.HashBiMap;
|
||||
import net.jafama.FastMath;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.World;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@@ -15,7 +15,7 @@ public class WorldProfiler {
|
||||
private boolean isProfiling;
|
||||
|
||||
public WorldProfiler(World w) {
|
||||
if(! (w.getGenerator() instanceof GaeaChunkGenerator))
|
||||
if(!(w.getGenerator() instanceof TerraChunkGenerator))
|
||||
throw new IllegalArgumentException("Attempted to instantiate profiler on non-Gaea managed world!");
|
||||
this.addMeasurement(new Measurement(2500000, DataType.PERIOD_MILLISECONDS), "TotalChunkGenTime")
|
||||
.addMeasurement(new Measurement(2500000, DataType.PERIOD_MILLISECONDS), "ChunkBaseGenTime")
|
||||
@@ -23,7 +23,7 @@ public class WorldProfiler {
|
||||
.addMeasurement(new Measurement(2000000, DataType.PERIOD_MILLISECONDS), "PopulationManagerTime");
|
||||
isProfiling = false;
|
||||
this.world = w;
|
||||
((GaeaChunkGenerator) w.getGenerator()).attachProfiler(this);
|
||||
((TerraChunkGenerator) w.getGenerator()).attachProfiler(this);
|
||||
}
|
||||
|
||||
public String getResultsFormatted() {
|
||||
|
||||
@@ -2,13 +2,12 @@ package com.dfsek.terra.api.gaea.tree;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
|
||||
public interface Tree {
|
||||
boolean plant(Location l, Random r, JavaPlugin main);
|
||||
boolean plant(Location l, Random r);
|
||||
|
||||
Set<Material> getSpawnable();
|
||||
}
|
||||
|
||||
@@ -89,10 +89,8 @@ public enum TreeType implements Tree {
|
||||
if(this.getVanillaTreeType() == null) {
|
||||
if(!spawnable.contains(l.subtract(0, 1, 0).getBlock().getType())) return false;
|
||||
FractalTree tree = getCustomTreeType().getTree(l, r);
|
||||
if(main.isEnabled()) co.aikar.taskchain.BukkitTaskChainFactory.create(main).newChain()
|
||||
.async(tree::grow)
|
||||
.sync(tree::plant)
|
||||
.execute();
|
||||
tree.grow();
|
||||
tree.plant();
|
||||
return true;
|
||||
}
|
||||
return l.getWorld().generateTree(l, this.getVanillaTreeType());
|
||||
|
||||
@@ -2,9 +2,9 @@ package com.dfsek.terra.api.gaea.world.carving;
|
||||
|
||||
import com.dfsek.terra.api.gaea.math.MathUtil;
|
||||
import com.dfsek.terra.api.gaea.util.FastRandom;
|
||||
import com.dfsek.terra.api.generic.world.World;
|
||||
import com.dfsek.terra.api.generic.world.vector.Vector3;
|
||||
import net.jafama.FastMath;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.Random;
|
||||
import java.util.function.BiConsumer;
|
||||
@@ -20,14 +20,14 @@ public abstract class Carver {
|
||||
this.maxY = maxY;
|
||||
}
|
||||
|
||||
public void carve(int chunkX, int chunkZ, World w, BiConsumer<Vector, CarvingType> consumer) {
|
||||
public void carve(int chunkX, int chunkZ, World w, BiConsumer<Vector3, CarvingType> consumer) {
|
||||
for(int x = chunkX - carvingRadius; x <= chunkX + carvingRadius; x++) {
|
||||
for(int z = chunkZ - carvingRadius; z <= chunkZ + carvingRadius; z++) {
|
||||
if(isChunkCarved(w, x, z, new FastRandom(MathUtil.hashToLong(this.getClass().getName() + "_" + x + "&" + z)))) {
|
||||
long seed = MathUtil.getCarverChunkSeed(x, z, w.getSeed());
|
||||
Random r = new FastRandom(seed);
|
||||
Worm carving = getWorm(seed, new Vector((x << 4) + r.nextInt(16), r.nextInt(maxY - minY + 1) + minY, (z << 4) + r.nextInt(16)));
|
||||
Vector origin = carving.getOrigin();
|
||||
Worm carving = getWorm(seed, new Vector3((x << 4) + r.nextInt(16), r.nextInt(maxY - minY + 1) + minY, (z << 4) + r.nextInt(16)));
|
||||
Vector3 origin = carving.getOrigin();
|
||||
for(int i = 0; i < carving.getLength(); i++) {
|
||||
carving.step();
|
||||
if(carving.getRunning().clone().setY(0).distanceSquared(origin.clone().setY(0)) > sixtyFourSq)
|
||||
@@ -49,7 +49,7 @@ public abstract class Carver {
|
||||
this.carvingRadius = carvingRadius;
|
||||
}
|
||||
|
||||
public abstract Worm getWorm(long seed, Vector l);
|
||||
public abstract Worm getWorm(long seed, Vector3 l);
|
||||
|
||||
public abstract boolean isChunkCarved(World w, int chunkX, int chunkZ, Random r);
|
||||
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
package com.dfsek.terra.api.gaea.world.carving;
|
||||
|
||||
import com.dfsek.terra.api.generic.world.vector.Vector3;
|
||||
import net.jafama.FastMath;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.Random;
|
||||
import java.util.function.BiConsumer;
|
||||
|
||||
public abstract class Worm {
|
||||
private final Random r;
|
||||
private final Vector origin;
|
||||
private final Vector running;
|
||||
private final Vector3 origin;
|
||||
private final Vector3 running;
|
||||
private final int length;
|
||||
private int topCut = 0;
|
||||
private int bottomCut = 0;
|
||||
private int[] radius = new int[] {0, 0, 0};
|
||||
|
||||
public Worm(int length, Random r, Vector origin) {
|
||||
public Worm(int length, Random r, Vector3 origin) {
|
||||
this.r = r;
|
||||
this.length = length;
|
||||
this.origin = origin;
|
||||
@@ -30,7 +30,7 @@ public abstract class Worm {
|
||||
this.topCut = topCut;
|
||||
}
|
||||
|
||||
public Vector getOrigin() {
|
||||
public Vector3 getOrigin() {
|
||||
return origin;
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ public abstract class Worm {
|
||||
return length;
|
||||
}
|
||||
|
||||
public Vector getRunning() {
|
||||
public Vector3 getRunning() {
|
||||
return running;
|
||||
}
|
||||
|
||||
@@ -61,12 +61,12 @@ public abstract class Worm {
|
||||
public abstract void step();
|
||||
|
||||
public static class WormPoint {
|
||||
private final Vector origin;
|
||||
private final Vector3 origin;
|
||||
private final int topCut;
|
||||
private final int bottomCut;
|
||||
private final int[] rad;
|
||||
|
||||
public WormPoint(Vector origin, int[] rad, int topCut, int bottomCut) {
|
||||
public WormPoint(Vector3 origin, int[] rad, int topCut, int bottomCut) {
|
||||
this.origin = origin;
|
||||
this.rad = rad;
|
||||
this.topCut = topCut;
|
||||
@@ -77,7 +77,7 @@ public abstract class Worm {
|
||||
return (FastMath.pow2(x) / FastMath.pow2(xr + 0.5D)) + (FastMath.pow2(y) / FastMath.pow2(yr + 0.5D)) + (FastMath.pow2(z) / FastMath.pow2(zr + 0.5D));
|
||||
}
|
||||
|
||||
public Vector getOrigin() {
|
||||
public Vector3 getOrigin() {
|
||||
return origin;
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ public abstract class Worm {
|
||||
return rad[index];
|
||||
}
|
||||
|
||||
public void carve(int chunkX, int chunkZ, BiConsumer<Vector, Carver.CarvingType> consumer) {
|
||||
public void carve(int chunkX, int chunkZ, BiConsumer<Vector3, Carver.CarvingType> consumer) {
|
||||
int xRad = getRadius(0);
|
||||
int yRad = getRadius(1);
|
||||
int zRad = getRadius(2);
|
||||
@@ -96,12 +96,12 @@ public abstract class Worm {
|
||||
for(int z = -zRad - 1; z <= zRad + 1; z++) {
|
||||
if(!(FastMath.floorDiv(origin.getBlockZ() + z, 16) == chunkZ)) continue;
|
||||
for(int y = -yRad - 1; y <= yRad + 1; y++) {
|
||||
Vector position = origin.clone().add(new Vector(x, y, z));
|
||||
Vector3 position = origin.clone().add(new Vector3(x, y, z));
|
||||
if(position.getY() < 0 || position.getY() > 255) continue;
|
||||
double eq = ellipseEquation(x, y, z, xRad, yRad, zRad);
|
||||
if(eq <= 1 &&
|
||||
y >= -yRad - 1 + bottomCut && y <= yRad + 1 - topCut) {
|
||||
consumer.accept(new Vector(position.getBlockX() - originX, position.getBlockY(), position.getBlockZ() - originZ), Carver.CarvingType.CENTER);
|
||||
consumer.accept(new Vector3(position.getBlockX() - originX, position.getBlockY(), position.getBlockZ() - originZ), Carver.CarvingType.CENTER);
|
||||
} else if(eq <= 1.5) {
|
||||
Carver.CarvingType type = Carver.CarvingType.WALL;
|
||||
if(y <= -yRad - 1 + bottomCut) {
|
||||
@@ -109,7 +109,7 @@ public abstract class Worm {
|
||||
} else if(y >= yRad + 1 - topCut) {
|
||||
type = Carver.CarvingType.TOP;
|
||||
}
|
||||
consumer.accept(new Vector(position.getBlockX() - originX, position.getBlockY(), position.getBlockZ() - originZ), type);
|
||||
consumer.accept(new Vector3(position.getBlockX() - originX, position.getBlockY(), position.getBlockZ() - originZ), type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,18 @@
|
||||
package com.dfsek.terra.api.generic;
|
||||
|
||||
import com.dfsek.terra.TerraWorld;
|
||||
import com.dfsek.terra.api.LoaderRegistrar;
|
||||
import com.dfsek.terra.api.generic.world.World;
|
||||
import com.dfsek.terra.api.generic.world.WorldHandle;
|
||||
|
||||
public interface TerraPlugin {
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public interface TerraPlugin extends LoaderRegistrar {
|
||||
WorldHandle getHandle();
|
||||
|
||||
boolean isEnabled();
|
||||
|
||||
TerraWorld getWorld(World world);
|
||||
|
||||
Logger getLogger();
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ public interface ChunkGenerator extends Handle {
|
||||
|
||||
boolean shouldGenerateStructures();
|
||||
|
||||
ChunkData generateChunkData(@NotNull World world, @NotNull Random random, int x, int z, @NotNull BiomeGrid biome, ChunkData data);
|
||||
ChunkData generateChunkData(@NotNull World world, @NotNull Random random, int x, int z, @NotNull BiomeGrid biome);
|
||||
|
||||
List<BlockPopulator> getDefaultPopulators(World world);
|
||||
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.dfsek.terra.api.generic.generator;
|
||||
|
||||
import com.dfsek.terra.api.gaea.profiler.WorldProfiler;
|
||||
import com.dfsek.terra.api.generic.world.BiomeGrid;
|
||||
import com.dfsek.terra.api.generic.world.World;
|
||||
import com.dfsek.terra.config.base.ConfigPack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public interface TerraChunkGenerator {
|
||||
void generateChunkData(@NotNull World world, @NotNull Random random, int x, int z, @NotNull BiomeGrid biome, ChunkGenerator.ChunkData data);
|
||||
|
||||
void attachProfiler(WorldProfiler profiler);
|
||||
|
||||
boolean isParallelCapable();
|
||||
|
||||
boolean shouldGenerateCaves();
|
||||
|
||||
boolean shouldGenerateDecorations();
|
||||
|
||||
boolean shouldGenerateMobs();
|
||||
|
||||
boolean shouldGenerateStructures();
|
||||
|
||||
ConfigPack getConfigPack();
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package com.dfsek.terra.api.generic.world;
|
||||
|
||||
import com.dfsek.terra.api.generic.Handle;
|
||||
|
||||
public interface Biome extends Handle {
|
||||
}
|
||||
@@ -24,4 +24,16 @@ public class Location implements Cloneable {
|
||||
throw new Error(e);
|
||||
}
|
||||
}
|
||||
|
||||
public int getBlockX() {
|
||||
return vector.getBlockX();
|
||||
}
|
||||
|
||||
public int getBlockY() {
|
||||
return vector.getBlockY();
|
||||
}
|
||||
|
||||
public int getBlockZ() {
|
||||
return vector.getBlockZ();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,8 +2,17 @@ package com.dfsek.terra.api.generic.world.vector;
|
||||
|
||||
import com.dfsek.terra.api.generic.world.World;
|
||||
import net.jafama.FastMath;
|
||||
import org.bukkit.util.NumberConversions;
|
||||
import org.bukkit.util.Vector;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class Vector3 implements Cloneable {
|
||||
|
||||
/**
|
||||
* Threshold for fuzzy equals().
|
||||
*/
|
||||
private static final double epsilon = 0.000001;
|
||||
|
||||
private double x;
|
||||
private double y;
|
||||
private double z;
|
||||
@@ -80,12 +89,17 @@ public class Vector3 implements Cloneable {
|
||||
return this;
|
||||
}
|
||||
|
||||
public double lengthSq() {
|
||||
return x * x + y * y + z * z;
|
||||
/**
|
||||
* Get the threshold used for equals().
|
||||
*
|
||||
* @return The epsilon.
|
||||
*/
|
||||
public static double getEpsilon() {
|
||||
return epsilon;
|
||||
}
|
||||
|
||||
public double length() {
|
||||
return FastMath.sqrt(lengthSq());
|
||||
public double lengthSquared() {
|
||||
return x * x + y * y + z * z;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -97,6 +111,188 @@ public class Vector3 implements Cloneable {
|
||||
}
|
||||
}
|
||||
|
||||
public double length() {
|
||||
return FastMath.sqrt(lengthSquared());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns if a vector is normalized
|
||||
*
|
||||
* @return whether the vector is normalised
|
||||
*/
|
||||
public boolean isNormalized() {
|
||||
return Math.abs(this.lengthSquared() - 1) < getEpsilon();
|
||||
}
|
||||
|
||||
/**
|
||||
* Rotates the vector around the x axis.
|
||||
* <p>
|
||||
* This piece of math is based on the standard rotation matrix for vectors
|
||||
* in three dimensional space. This matrix can be found here:
|
||||
* <a href="https://en.wikipedia.org/wiki/Rotation_matrix#Basic_rotations">Rotation
|
||||
* Matrix</a>.
|
||||
*
|
||||
* @param angle the angle to rotate the vector about. This angle is passed
|
||||
* in radians
|
||||
* @return the same vector
|
||||
*/
|
||||
@NotNull
|
||||
public Vector3 rotateAroundX(double angle) {
|
||||
double angleCos = Math.cos(angle);
|
||||
double angleSin = Math.sin(angle);
|
||||
|
||||
double y = angleCos * getY() - angleSin * getZ();
|
||||
double z = angleSin * getY() + angleCos * getZ();
|
||||
return setY(y).setZ(z);
|
||||
}
|
||||
|
||||
/**
|
||||
* Rotates the vector around the y axis.
|
||||
* <p>
|
||||
* This piece of math is based on the standard rotation matrix for vectors
|
||||
* in three dimensional space. This matrix can be found here:
|
||||
* <a href="https://en.wikipedia.org/wiki/Rotation_matrix#Basic_rotations">Rotation
|
||||
* Matrix</a>.
|
||||
*
|
||||
* @param angle the angle to rotate the vector about. This angle is passed
|
||||
* in radians
|
||||
* @return the same vector
|
||||
*/
|
||||
@NotNull
|
||||
public Vector3 rotateAroundY(double angle) {
|
||||
double angleCos = Math.cos(angle);
|
||||
double angleSin = Math.sin(angle);
|
||||
|
||||
double x = angleCos * getX() + angleSin * getZ();
|
||||
double z = -angleSin * getX() + angleCos * getZ();
|
||||
return setX(x).setZ(z);
|
||||
}
|
||||
|
||||
/**
|
||||
* Rotates the vector around the z axis
|
||||
* <p>
|
||||
* This piece of math is based on the standard rotation matrix for vectors
|
||||
* in three dimensional space. This matrix can be found here:
|
||||
* <a href="https://en.wikipedia.org/wiki/Rotation_matrix#Basic_rotations">Rotation
|
||||
* Matrix</a>.
|
||||
*
|
||||
* @param angle the angle to rotate the vector about. This angle is passed
|
||||
* in radians
|
||||
* @return the same vector
|
||||
*/
|
||||
@NotNull
|
||||
public Vector3 rotateAroundZ(double angle) {
|
||||
double angleCos = Math.cos(angle);
|
||||
double angleSin = Math.sin(angle);
|
||||
|
||||
double x = angleCos * getX() - angleSin * getY();
|
||||
double y = angleSin * getX() + angleCos * getY();
|
||||
return setX(x).setY(y);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the distance between this vector and another. The value of this
|
||||
* method is not cached and uses a costly square-root function, so do not
|
||||
* repeatedly call this method to get the vector's magnitude. NaN will be
|
||||
* returned if the inner result of the sqrt() function overflows, which
|
||||
* will be caused if the distance is too long.
|
||||
*
|
||||
* @param o The other vector
|
||||
* @return the distance
|
||||
*/
|
||||
public double distance(@NotNull Vector3 o) {
|
||||
return FastMath.sqrt(NumberConversions.square(x - o.x) + NumberConversions.square(y - o.y) + NumberConversions.square(z - o.z));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the squared distance between this vector and another.
|
||||
*
|
||||
* @param o The other vector
|
||||
* @return the distance
|
||||
*/
|
||||
public double distanceSquared(@NotNull Vector3 o) {
|
||||
return NumberConversions.square(x - o.x) + NumberConversions.square(y - o.y) + NumberConversions.square(z - o.z);
|
||||
}
|
||||
|
||||
/**
|
||||
* Rotates the vector around a given arbitrary axis in 3 dimensional space.
|
||||
*
|
||||
* <p>
|
||||
* Rotation will follow the general Right-Hand-Rule, which means rotation
|
||||
* will be counterclockwise when the axis is pointing towards the observer.
|
||||
* <p>
|
||||
* This method will always make sure the provided axis is a unit vector, to
|
||||
* not modify the length of the vector when rotating. If you are experienced
|
||||
* with the scaling of a non-unit axis vector, you can use
|
||||
* {@link Vector#rotateAroundNonUnitAxis(Vector, double)}.
|
||||
*
|
||||
* @param axis the axis to rotate the vector around. If the passed vector is
|
||||
* not of length 1, it gets copied and normalized before using it for the
|
||||
* rotation. Please use {@link Vector#normalize()} on the instance before
|
||||
* passing it to this method
|
||||
* @param angle the angle to rotate the vector around the axis
|
||||
* @return the same vector
|
||||
* @throws IllegalArgumentException if the provided axis vector instance is
|
||||
* null
|
||||
*/
|
||||
@NotNull
|
||||
public Vector3 rotateAroundAxis(@NotNull Vector3 axis, double angle) throws IllegalArgumentException {
|
||||
return rotateAroundNonUnitAxis(axis.isNormalized() ? axis : axis.clone().normalize(), angle);
|
||||
}
|
||||
|
||||
/**
|
||||
* Rotates the vector around a given arbitrary axis in 3 dimensional space.
|
||||
*
|
||||
* <p>
|
||||
* Rotation will follow the general Right-Hand-Rule, which means rotation
|
||||
* will be counterclockwise when the axis is pointing towards the observer.
|
||||
* <p>
|
||||
* Note that the vector length will change accordingly to the axis vector
|
||||
* length. If the provided axis is not a unit vector, the rotated vector
|
||||
* will not have its previous length. The scaled length of the resulting
|
||||
* vector will be related to the axis vector. If you are not perfectly sure
|
||||
* about the scaling of the vector, use
|
||||
* {@link Vector#rotateAroundAxis(Vector, double)}
|
||||
*
|
||||
* @param axis the axis to rotate the vector around.
|
||||
* @param angle the angle to rotate the vector around the axis
|
||||
* @return the same vector
|
||||
* @throws IllegalArgumentException if the provided axis vector instance is
|
||||
* null
|
||||
*/
|
||||
@NotNull
|
||||
public Vector3 rotateAroundNonUnitAxis(@NotNull Vector3 axis, double angle) throws IllegalArgumentException {
|
||||
double x = getX(), y = getY(), z = getZ();
|
||||
double x2 = axis.getX(), y2 = axis.getY(), z2 = axis.getZ();
|
||||
|
||||
double cosTheta = Math.cos(angle);
|
||||
double sinTheta = Math.sin(angle);
|
||||
double dotProduct = this.dot(axis);
|
||||
|
||||
double xPrime = x2 * dotProduct * (1d - cosTheta)
|
||||
+ x * cosTheta
|
||||
+ (-z2 * y + y2 * z) * sinTheta;
|
||||
double yPrime = y2 * dotProduct * (1d - cosTheta)
|
||||
+ y * cosTheta
|
||||
+ (z2 * x - x2 * z) * sinTheta;
|
||||
double zPrime = z2 * dotProduct * (1d - cosTheta)
|
||||
+ z * cosTheta
|
||||
+ (-y2 * x + x2 * y) * sinTheta;
|
||||
|
||||
return setX(xPrime).setY(yPrime).setZ(zPrime);
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the dot product of this vector with another. The dot product
|
||||
* is defined as x1*x2+y1*y2+z1*z2. The returned value is a scalar.
|
||||
*
|
||||
* @param other The other vector
|
||||
* @return dot product
|
||||
*/
|
||||
public double dot(@NotNull Vector3 other) {
|
||||
return x * other.x + y * other.y + z * other.z;
|
||||
}
|
||||
|
||||
public Location toLocation(World world) {
|
||||
return new Location(world, this.clone());
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.dfsek.terra.async;
|
||||
|
||||
import com.dfsek.terra.Terra;
|
||||
import com.dfsek.terra.api.bukkit.TerraBukkitPlugin;
|
||||
import com.dfsek.terra.api.gaea.biome.Biome;
|
||||
import com.dfsek.terra.api.gaea.generation.GenerationPhase;
|
||||
import com.dfsek.terra.biome.grid.master.TerraBiomeGrid;
|
||||
@@ -15,7 +15,7 @@ import java.util.function.Consumer;
|
||||
*/
|
||||
public class AsyncBiomeFinder extends AsyncFeatureFinder<Biome> {
|
||||
|
||||
public AsyncBiomeFinder(TerraBiomeGrid grid, Biome target, @NotNull Location origin, int startRadius, int maxRadius, Consumer<Vector> callback, Terra main) {
|
||||
public AsyncBiomeFinder(TerraBiomeGrid grid, Biome target, @NotNull Location origin, int startRadius, int maxRadius, Consumer<Vector> callback, TerraBukkitPlugin main) {
|
||||
super(grid, target, origin, startRadius, maxRadius, callback, main);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.dfsek.terra.async;
|
||||
|
||||
import com.dfsek.terra.Terra;
|
||||
import com.dfsek.terra.api.bukkit.TerraBukkitPlugin;
|
||||
import com.dfsek.terra.biome.grid.master.TerraBiomeGrid;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
@@ -20,9 +20,9 @@ public abstract class AsyncFeatureFinder<T> implements Runnable {
|
||||
protected final World world;
|
||||
private final Consumer<Vector> callback;
|
||||
protected int searchSize = 1;
|
||||
protected final Terra main;
|
||||
protected final TerraBukkitPlugin main;
|
||||
|
||||
public AsyncFeatureFinder(TerraBiomeGrid grid, T target, @NotNull Location origin, int startRadius, int maxRadius, Consumer<Vector> callback, Terra main) {
|
||||
public AsyncFeatureFinder(TerraBiomeGrid grid, T target, @NotNull Location origin, int startRadius, int maxRadius, Consumer<Vector> callback, TerraBukkitPlugin main) {
|
||||
this.grid = grid;
|
||||
this.target = target;
|
||||
this.main = main;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.dfsek.terra.async;
|
||||
|
||||
import com.dfsek.terra.Terra;
|
||||
import com.dfsek.terra.api.bukkit.TerraBukkitPlugin;
|
||||
import com.dfsek.terra.api.gaea.util.FastRandom;
|
||||
import com.dfsek.terra.biome.UserDefinedBiome;
|
||||
import com.dfsek.terra.biome.grid.master.TerraBiomeGrid;
|
||||
@@ -20,7 +20,7 @@ import java.util.function.Consumer;
|
||||
* Runnable to locate structures asynchronously
|
||||
*/
|
||||
public class AsyncStructureFinder extends AsyncFeatureFinder<TerraStructure> {
|
||||
public AsyncStructureFinder(TerraBiomeGrid grid, TerraStructure target, @NotNull Location origin, int startRadius, int maxRadius, Consumer<Vector> callback, Terra main) {
|
||||
public AsyncStructureFinder(TerraBiomeGrid grid, TerraStructure target, @NotNull Location origin, int startRadius, int maxRadius, Consumer<Vector> callback, TerraBukkitPlugin main) {
|
||||
super(grid, target, origin, startRadius, maxRadius, callback, main);
|
||||
setSearchSize(target.getSpawn().getWidth() + 2 * target.getSpawn().getSeparation());
|
||||
}
|
||||
|
||||
@@ -3,10 +3,10 @@ package com.dfsek.terra.biome;
|
||||
import com.dfsek.terra.api.gaea.biome.BiomeGrid;
|
||||
import com.dfsek.terra.api.gaea.biome.NormalizationUtil;
|
||||
import com.dfsek.terra.api.gaea.math.FastNoiseLite;
|
||||
import com.dfsek.terra.api.generic.world.World;
|
||||
import com.dfsek.terra.config.base.ConfigPack;
|
||||
import com.dfsek.terra.config.base.ConfigPackTemplate;
|
||||
import com.dfsek.terra.image.ImageLoader;
|
||||
import org.bukkit.World;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
@@ -3,8 +3,8 @@ package com.dfsek.terra.biome.grid;
|
||||
import com.dfsek.terra.api.gaea.biome.Biome;
|
||||
import com.dfsek.terra.api.gaea.biome.BiomeGrid;
|
||||
import com.dfsek.terra.api.gaea.generation.GenerationPhase;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import com.dfsek.terra.api.generic.world.World;
|
||||
import com.dfsek.terra.api.generic.world.vector.Location;
|
||||
|
||||
/**
|
||||
* BiomeGrid implementation that holds a single biome.
|
||||
|
||||
@@ -4,11 +4,11 @@ import com.dfsek.terra.api.gaea.biome.Biome;
|
||||
import com.dfsek.terra.api.gaea.biome.BiomeGrid;
|
||||
import com.dfsek.terra.api.gaea.biome.NormalizationUtil;
|
||||
import com.dfsek.terra.api.gaea.generation.GenerationPhase;
|
||||
import com.dfsek.terra.api.generic.world.World;
|
||||
import com.dfsek.terra.api.generic.world.vector.Location;
|
||||
import com.dfsek.terra.config.base.ConfigPack;
|
||||
import com.dfsek.terra.config.base.ConfigPackTemplate;
|
||||
import com.dfsek.terra.image.ImageLoader;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
|
||||
public class UserDefinedGrid extends BiomeGrid {
|
||||
private final ImageLoader imageLoader;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.dfsek.terra.biome.grid.master;
|
||||
|
||||
import com.dfsek.terra.api.gaea.biome.BiomeGrid;
|
||||
import com.dfsek.terra.api.generic.world.World;
|
||||
import com.dfsek.terra.biome.grid.UserDefinedGrid;
|
||||
import org.bukkit.World;
|
||||
|
||||
public abstract class TerraBiomeGrid extends BiomeGrid {
|
||||
public TerraBiomeGrid(World w, double freq1, double freq2, int sizeX, int sizeZ) {
|
||||
|
||||
@@ -3,6 +3,8 @@ package com.dfsek.terra.biome.grid.master;
|
||||
import com.dfsek.terra.api.gaea.biome.Biome;
|
||||
import com.dfsek.terra.api.gaea.biome.BiomeGrid;
|
||||
import com.dfsek.terra.api.gaea.generation.GenerationPhase;
|
||||
import com.dfsek.terra.api.generic.world.World;
|
||||
import com.dfsek.terra.api.generic.world.vector.Location;
|
||||
import com.dfsek.terra.api.generic.world.vector.Vector2;
|
||||
import com.dfsek.terra.biome.BiomeZone;
|
||||
import com.dfsek.terra.biome.UserDefinedBiome;
|
||||
@@ -12,8 +14,6 @@ import com.dfsek.terra.biome.postprocessing.ErosionNoise;
|
||||
import com.dfsek.terra.config.base.ConfigPack;
|
||||
import com.dfsek.terra.config.base.ConfigPackTemplate;
|
||||
import net.jafama.FastMath;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
|
||||
public class TerraRadialBiomeGrid extends TerraBiomeGrid {
|
||||
private static final int failNum = 0;
|
||||
|
||||
@@ -2,6 +2,8 @@ package com.dfsek.terra.biome.grid.master;
|
||||
|
||||
import com.dfsek.terra.api.gaea.biome.Biome;
|
||||
import com.dfsek.terra.api.gaea.generation.GenerationPhase;
|
||||
import com.dfsek.terra.api.generic.world.World;
|
||||
import com.dfsek.terra.api.generic.world.vector.Location;
|
||||
import com.dfsek.terra.api.generic.world.vector.Vector2;
|
||||
import com.dfsek.terra.biome.BiomeZone;
|
||||
import com.dfsek.terra.biome.UserDefinedBiome;
|
||||
@@ -10,8 +12,6 @@ import com.dfsek.terra.biome.postprocessing.CoordinatePerturb;
|
||||
import com.dfsek.terra.biome.postprocessing.ErosionNoise;
|
||||
import com.dfsek.terra.config.base.ConfigPack;
|
||||
import com.dfsek.terra.config.base.ConfigPackTemplate;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
|
||||
public class TerraStandardBiomeGrid extends TerraBiomeGrid {
|
||||
private static final int failNum = 0;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.dfsek.terra.biome.palette;
|
||||
|
||||
import com.dfsek.terra.api.gaea.world.palette.Palette;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import com.dfsek.terra.api.generic.world.block.BlockData;
|
||||
|
||||
public class PaletteHolder {
|
||||
private final Palette<BlockData>[] palettes;
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
package com.dfsek.terra.biome.palette;
|
||||
|
||||
import com.dfsek.terra.api.gaea.world.palette.Palette;
|
||||
import com.dfsek.terra.util.PaletteUtil;
|
||||
import com.dfsek.terra.api.generic.world.block.BlockData;
|
||||
import net.jafama.FastMath;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
@@ -20,13 +19,14 @@ public class PaletteHolderBuilder {
|
||||
public PaletteHolder build() {
|
||||
Palette<BlockData>[] palettes = new Palette[paletteMap.lastKey() + 1];
|
||||
for(int y = 0; y <= FastMath.max(paletteMap.lastKey(), 255); y++) {
|
||||
Palette<BlockData> d = PaletteUtil.BLANK_PALETTE;
|
||||
Palette<BlockData> d = null;
|
||||
for(Map.Entry<Integer, Palette<BlockData>> e : paletteMap.entrySet()) {
|
||||
if(e.getKey() >= y) {
|
||||
d = e.getValue();
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(d == null) throw new IllegalArgumentException("No palette for Y=" + y);
|
||||
palettes[y] = d;
|
||||
}
|
||||
return new PaletteHolder(palettes);
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
package com.dfsek.terra.carving;
|
||||
|
||||
import com.dfsek.terra.Terra;
|
||||
import com.dfsek.terra.api.bukkit.TerraBukkitPlugin;
|
||||
import com.dfsek.terra.api.gaea.biome.Biome;
|
||||
import com.dfsek.terra.api.gaea.generation.GenerationPhase;
|
||||
import com.dfsek.terra.api.gaea.math.MathUtil;
|
||||
import com.dfsek.terra.api.gaea.util.FastRandom;
|
||||
import com.dfsek.terra.api.gaea.util.GlueList;
|
||||
import com.dfsek.terra.api.gaea.world.carving.Worm;
|
||||
import com.dfsek.terra.api.generic.world.World;
|
||||
import com.dfsek.terra.api.generic.world.vector.Vector3;
|
||||
import com.dfsek.terra.biome.UserDefinedBiome;
|
||||
import com.dfsek.terra.biome.grid.master.TerraBiomeGrid;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@@ -21,9 +21,9 @@ public class CarverCache {
|
||||
|
||||
private final World w;
|
||||
private final Map<Long, List<Worm.WormPoint>> carvers = new HashMap<>();
|
||||
private final Terra main;
|
||||
private final TerraBukkitPlugin main;
|
||||
|
||||
public CarverCache(World w, Terra main) {
|
||||
public CarverCache(World w, TerraBukkitPlugin main) {
|
||||
this.w = w;
|
||||
this.main = main;
|
||||
}
|
||||
@@ -36,7 +36,7 @@ public class CarverCache {
|
||||
long seed = MathUtil.getCarverChunkSeed(chunkX, chunkZ, w.getSeed());
|
||||
carver.getSeedVar().setValue(seed);
|
||||
Random r = new FastRandom(seed);
|
||||
Worm carving = carver.getWorm(seed, new Vector((chunkX << 4) + r.nextInt(16), carver.getConfig().getHeight().get(r), (chunkZ << 4) + r.nextInt(16)));
|
||||
Worm carving = carver.getWorm(seed, new Vector3((chunkX << 4) + r.nextInt(16), carver.getConfig().getHeight().get(r), (chunkZ << 4) + r.nextInt(16)));
|
||||
List<Worm.WormPoint> points = new GlueList<>();
|
||||
for(int i = 0; i < carving.getLength(); i++) {
|
||||
carving.step();
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
package com.dfsek.terra.carving;
|
||||
|
||||
import com.dfsek.terra.Terra;
|
||||
import com.dfsek.terra.api.bukkit.TerraBukkitPlugin;
|
||||
import com.dfsek.terra.api.gaea.generation.GenerationPhase;
|
||||
import com.dfsek.terra.api.gaea.math.Range;
|
||||
import com.dfsek.terra.api.gaea.util.FastRandom;
|
||||
import com.dfsek.terra.api.gaea.world.carving.Carver;
|
||||
import com.dfsek.terra.api.gaea.world.carving.Worm;
|
||||
import com.dfsek.terra.api.generic.world.World;
|
||||
import com.dfsek.terra.api.generic.world.vector.Vector3;
|
||||
import com.dfsek.terra.biome.UserDefinedBiome;
|
||||
import com.dfsek.terra.config.templates.BiomeTemplate;
|
||||
import com.dfsek.terra.config.templates.CarverTemplate;
|
||||
import com.dfsek.terra.math.RandomFunction;
|
||||
import net.jafama.FastMath;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.util.Vector;
|
||||
import parsii.eval.Expression;
|
||||
import parsii.eval.Parser;
|
||||
import parsii.eval.Scope;
|
||||
@@ -43,9 +43,9 @@ public class UserDefinedCarver extends Carver {
|
||||
private double step = 2;
|
||||
private Range recalc = new Range(8, 10);
|
||||
private double recalcMagnitude = 3;
|
||||
private final Terra main;
|
||||
private final TerraBukkitPlugin main;
|
||||
|
||||
public UserDefinedCarver(Range height, Range length, double[] start, double[] mutate, List<String> radii, Scope parent, long hash, int topCut, int bottomCut, CarverTemplate config, Terra main) throws ParseException {
|
||||
public UserDefinedCarver(Range height, Range length, double[] start, double[] mutate, List<String> radii, Scope parent, long hash, int topCut, int bottomCut, CarverTemplate config, TerraBukkitPlugin main) throws ParseException {
|
||||
super(height.getMin(), height.getMax());
|
||||
this.length = length;
|
||||
this.start = start;
|
||||
@@ -74,7 +74,7 @@ public class UserDefinedCarver extends Carver {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Worm getWorm(long l, Vector vector) {
|
||||
public Worm getWorm(long l, Vector3 vector) {
|
||||
Random r = new FastRandom(l + hash);
|
||||
return new UserDefinedWorm(length.get(r) / 2, r, vector, topCut, bottomCut);
|
||||
}
|
||||
@@ -100,13 +100,13 @@ public class UserDefinedCarver extends Carver {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void carve(int chunkX, int chunkZ, World w, BiConsumer<Vector, CarvingType> consumer) {
|
||||
public void carve(int chunkX, int chunkZ, World w, BiConsumer<Vector3, CarvingType> consumer) {
|
||||
CarverCache cache = cacheMap.computeIfAbsent(w, world -> new CarverCache(world, main));
|
||||
int carvingRadius = getCarvingRadius();
|
||||
for(int x = chunkX - carvingRadius; x <= chunkX + carvingRadius; x++) {
|
||||
for(int z = chunkZ - carvingRadius; z <= chunkZ + carvingRadius; z++) {
|
||||
cache.getPoints(x, z, this).forEach(point -> {
|
||||
Vector origin = point.getOrigin();
|
||||
Vector3 origin = point.getOrigin();
|
||||
if(FastMath.floorDiv(origin.getBlockX(), 16) != chunkX && FastMath.floorDiv(origin.getBlockZ(), 16) != chunkZ) // We only want to carve this chunk.
|
||||
return;
|
||||
point.carve(chunkX, chunkZ, consumer);
|
||||
@@ -133,16 +133,16 @@ public class UserDefinedCarver extends Carver {
|
||||
}
|
||||
|
||||
private class UserDefinedWorm extends Worm {
|
||||
private final Vector direction;
|
||||
private final Vector3 direction;
|
||||
private int steps;
|
||||
private int nextDirection = 0;
|
||||
private double[] currentRotation = new double[3];
|
||||
|
||||
public UserDefinedWorm(int length, Random r, Vector origin, int topCut, int bottomCut) {
|
||||
public UserDefinedWorm(int length, Random r, Vector3 origin, int topCut, int bottomCut) {
|
||||
super(length, r, origin);
|
||||
super.setTopCut(topCut);
|
||||
super.setBottomCut(bottomCut);
|
||||
direction = new Vector((r.nextDouble() - 0.5D) * start[0], (r.nextDouble() - 0.5D) * start[1], (r.nextDouble() - 0.5D) * start[2]).normalize().multiply(step);
|
||||
direction = new Vector3((r.nextDouble() - 0.5D) * start[0], (r.nextDouble() - 0.5D) * start[1], (r.nextDouble() - 0.5D) * start[2]).normalize().multiply(step);
|
||||
position.setValue(0);
|
||||
lengthVar.setValue(length);
|
||||
setRadius(new int[] {(int) (xRad.evaluate()), (int) (yRad.evaluate()), (int) (zRad.evaluate())});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.dfsek.terra.command;
|
||||
|
||||
import com.dfsek.terra.Terra;
|
||||
import com.dfsek.terra.api.bukkit.TerraBukkitPlugin;
|
||||
import com.dfsek.terra.api.gaea.command.Command;
|
||||
import com.dfsek.terra.config.base.ConfigPackTemplate;
|
||||
import com.dfsek.terra.config.lang.LangUtil;
|
||||
@@ -29,7 +29,7 @@ public class PacksCommand extends Command {
|
||||
@Override
|
||||
public boolean execute(@NotNull CommandSender commandSender, org.bukkit.command.@NotNull Command command, @NotNull String s, @NotNull String[] strings) {
|
||||
|
||||
ConfigRegistry registry = ((Terra) getMain()).getRegistry();
|
||||
ConfigRegistry registry = ((TerraBukkitPlugin) getMain()).getRegistry();
|
||||
|
||||
if(registry.entries().size() == 0) {
|
||||
LangUtil.send("command.packs.none", commandSender);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.dfsek.terra.command;
|
||||
|
||||
import com.dfsek.terra.Terra;
|
||||
import com.dfsek.terra.api.bukkit.TerraBukkitPlugin;
|
||||
import com.dfsek.terra.api.gaea.command.Command;
|
||||
import com.dfsek.terra.api.gaea.command.DebugCommand;
|
||||
import com.dfsek.terra.config.lang.LangUtil;
|
||||
@@ -27,13 +27,13 @@ public class ReloadCommand extends Command implements DebugCommand {
|
||||
|
||||
@Override
|
||||
public boolean execute(@NotNull CommandSender sender, org.bukkit.command.@NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
((Terra) getMain()).getTerraConfig().load(getMain());
|
||||
LangUtil.load(((Terra) getMain()).getTerraConfig().getLanguage(), getMain()); // Load language.
|
||||
if(!((Terra) getMain()).getRegistry().loadAll((Terra) getMain())) {
|
||||
((TerraBukkitPlugin) getMain()).getTerraConfig().load(getMain());
|
||||
LangUtil.load(((TerraBukkitPlugin) getMain()).getTerraConfig().getLanguage(), getMain()); // Load language.
|
||||
if(!((TerraBukkitPlugin) getMain()).getRegistry().loadAll((TerraBukkitPlugin) getMain())) {
|
||||
LangUtil.send("command.reload-error", sender);
|
||||
return true;
|
||||
}
|
||||
((Terra) getMain()).reload();
|
||||
((TerraBukkitPlugin) getMain()).reload();
|
||||
LangUtil.send("command.reload", sender);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.dfsek.terra.command.biome;
|
||||
|
||||
import com.dfsek.terra.Terra;
|
||||
import com.dfsek.terra.api.bukkit.TerraBukkitPlugin;
|
||||
import com.dfsek.terra.api.gaea.command.WorldCommand;
|
||||
import com.dfsek.terra.api.gaea.generation.GenerationPhase;
|
||||
import com.dfsek.terra.biome.UserDefinedBiome;
|
||||
@@ -23,7 +23,7 @@ public class BiomeCommand extends WorldCommand {
|
||||
|
||||
@Override
|
||||
public boolean execute(@NotNull Player sender, @NotNull Command command, @NotNull String label, @NotNull String[] args, World w) {
|
||||
TerraBiomeGrid grid = ((Terra) getMain()).getWorld(sender.getWorld()).getGrid();
|
||||
TerraBiomeGrid grid = ((TerraBukkitPlugin) getMain()).getWorld(sender.getWorld()).getGrid();
|
||||
UserDefinedBiome biome = (UserDefinedBiome) grid.getBiome(sender.getLocation(), GenerationPhase.POPULATE);
|
||||
LangUtil.send("command.biome.in", sender, biome.getID());
|
||||
return true;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.dfsek.terra.command.biome;
|
||||
|
||||
import com.dfsek.terra.Terra;
|
||||
import com.dfsek.terra.api.bukkit.TerraBukkitPlugin;
|
||||
import com.dfsek.terra.api.gaea.command.WorldCommand;
|
||||
import com.dfsek.terra.biome.UserDefinedBiome;
|
||||
import com.dfsek.terra.carving.UserDefinedCarver;
|
||||
@@ -27,7 +27,7 @@ public class BiomeInfoCommand extends WorldCommand {
|
||||
@Override
|
||||
public boolean execute(@NotNull Player sender, @NotNull Command command, @NotNull String label, @NotNull String[] args, World world) {
|
||||
String id = args[0];
|
||||
ConfigPack cfg = ((Terra) getMain()).getWorld(world).getConfig();
|
||||
ConfigPack cfg = ((TerraBukkitPlugin) getMain()).getWorld(world).getConfig();
|
||||
UserDefinedBiome b;
|
||||
try {
|
||||
b = cfg.getBiome(id);
|
||||
@@ -86,7 +86,7 @@ public class BiomeInfoCommand extends WorldCommand {
|
||||
public List<String> getTabCompletions(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) {
|
||||
if(!(sender instanceof Player) || !(((Player) sender).getWorld().getGenerator() instanceof TerraChunkGenerator))
|
||||
return Collections.emptyList();
|
||||
List<String> ids = ((Terra) getMain()).getWorld(((Player) sender).getWorld()).getConfig().getBiomeIDs();
|
||||
List<String> ids = ((TerraBukkitPlugin) getMain()).getWorld(((Player) sender).getWorld()).getConfig().getBiomeIDs();
|
||||
if(args.length == 1)
|
||||
return ids.stream().filter(string -> string.toUpperCase().startsWith(args[0].toUpperCase())).collect(Collectors.toList());
|
||||
return Collections.emptyList();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.dfsek.terra.command.biome;
|
||||
|
||||
import com.dfsek.terra.Terra;
|
||||
import com.dfsek.terra.api.bukkit.TerraBukkitPlugin;
|
||||
import com.dfsek.terra.api.gaea.command.WorldCommand;
|
||||
import com.dfsek.terra.async.AsyncBiomeFinder;
|
||||
import com.dfsek.terra.biome.UserDefinedBiome;
|
||||
@@ -45,12 +45,12 @@ public class BiomeLocateCommand extends WorldCommand {
|
||||
}
|
||||
UserDefinedBiome b;
|
||||
try {
|
||||
b = ((Terra) getMain()).getWorld(world).getConfig().getBiome(id);
|
||||
b = ((TerraBukkitPlugin) getMain()).getWorld(world).getConfig().getBiome(id);
|
||||
} catch(IllegalArgumentException | NullPointerException e) {
|
||||
LangUtil.send("command.biome.invalid", sender, id);
|
||||
return true;
|
||||
}
|
||||
Bukkit.getScheduler().runTaskAsynchronously(getMain(), new AsyncBiomeFinder(((Terra) getMain()).getWorld(world).getGrid(), b, sender.getLocation().clone().multiply((1D / ((Terra) getMain()).getTerraConfig().getBiomeSearchResolution())), 0, maxRadius, location -> {
|
||||
Bukkit.getScheduler().runTaskAsynchronously(getMain(), new AsyncBiomeFinder(((TerraBukkitPlugin) getMain()).getWorld(world).getGrid(), b, sender.getLocation().clone().multiply((1D / ((TerraBukkitPlugin) getMain()).getTerraConfig().getBiomeSearchResolution())), 0, maxRadius, location -> {
|
||||
if(location != null) {
|
||||
ComponentBuilder cm = new ComponentBuilder(String.format("The nearest %s is at ", id.toLowerCase()))
|
||||
.append(String.format("[%d, ~, %d]", location.getBlockX(), location.getBlockZ()), ComponentBuilder.FormatRetention.NONE)
|
||||
@@ -61,7 +61,7 @@ public class BiomeLocateCommand extends WorldCommand {
|
||||
sender.spigot().sendMessage(cm.create());
|
||||
// LangUtil.send("command.biome.biome-found", sender, String.valueOf(location.getBlockX()), String.valueOf(location.getBlockZ()));
|
||||
} else LangUtil.send("command.biome.unable-to-locate", sender);
|
||||
}, (Terra) getMain()));
|
||||
}, (TerraBukkitPlugin) getMain()));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ public class BiomeLocateCommand extends WorldCommand {
|
||||
public List<String> getTabCompletions(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) {
|
||||
if(!(sender instanceof Player) || !(((Player) sender).getWorld().getGenerator() instanceof TerraChunkGenerator))
|
||||
return Collections.emptyList();
|
||||
List<String> ids = ((Terra) getMain()).getWorld(((Player) sender).getWorld()).getConfig().getBiomeIDs();
|
||||
List<String> ids = ((TerraBukkitPlugin) getMain()).getWorld(((Player) sender).getWorld()).getConfig().getBiomeIDs();
|
||||
if(args.length == 1)
|
||||
return ids.stream().filter(string -> string.toUpperCase().startsWith(args[0].toUpperCase())).collect(Collectors.toList());
|
||||
return Collections.emptyList();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.dfsek.terra.command.image;
|
||||
|
||||
import com.dfsek.terra.Terra;
|
||||
import com.dfsek.terra.api.bukkit.TerraBukkitPlugin;
|
||||
import com.dfsek.terra.api.gaea.command.WorldCommand;
|
||||
import com.dfsek.terra.config.lang.LangUtil;
|
||||
import com.dfsek.terra.image.WorldImageGenerator;
|
||||
@@ -22,7 +22,7 @@ public class RenderCommand extends WorldCommand {
|
||||
@Override
|
||||
public boolean execute(@NotNull Player sender, @NotNull Command command, @NotNull String label, @NotNull String[] args, World world) {
|
||||
try {
|
||||
WorldImageGenerator g = new WorldImageGenerator(world, Integer.parseInt(args[0]), Integer.parseInt(args[1]), (Terra) getMain());
|
||||
WorldImageGenerator g = new WorldImageGenerator(world, Integer.parseInt(args[0]), Integer.parseInt(args[1]), (TerraBukkitPlugin) getMain());
|
||||
g.drawWorld(sender.getLocation().getBlockX(), sender.getLocation().getBlockZ());
|
||||
File file = new File(getMain().getDataFolder() + File.separator + "export" + File.separator + "map" + File.separator + "map_" + System.currentTimeMillis() + ".png");
|
||||
//noinspection ResultOfMethodCallIgnored
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.dfsek.terra.command.image.gui;
|
||||
|
||||
import com.dfsek.terra.Terra;
|
||||
import com.dfsek.terra.api.bukkit.TerraBukkitPlugin;
|
||||
import com.dfsek.terra.api.gaea.command.WorldCommand;
|
||||
import com.dfsek.terra.config.lang.LangUtil;
|
||||
import com.dfsek.terra.image.ImageLoader;
|
||||
@@ -24,9 +24,9 @@ public class RawGUICommand extends WorldCommand {
|
||||
LangUtil.send("command.image.gui.debug", sender);
|
||||
return true;
|
||||
}
|
||||
ImageLoader loader = ((Terra) getMain()).getWorld(world).getConfig().getTemplate().getImageLoader();
|
||||
if(loader != null) loader.debug(false, sender.getWorld(), (Terra) getMain());
|
||||
else ImageLoader.debugWorld(false, world, (Terra) getMain());
|
||||
ImageLoader loader = ((TerraBukkitPlugin) getMain()).getWorld(world).getConfig().getTemplate().getImageLoader();
|
||||
if(loader != null) loader.debug(false, sender.getWorld(), (TerraBukkitPlugin) getMain());
|
||||
else ImageLoader.debugWorld(false, world, (TerraBukkitPlugin) getMain());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.dfsek.terra.command.image.gui;
|
||||
|
||||
import com.dfsek.terra.Terra;
|
||||
import com.dfsek.terra.api.bukkit.TerraBukkitPlugin;
|
||||
import com.dfsek.terra.api.gaea.command.WorldCommand;
|
||||
import com.dfsek.terra.config.lang.LangUtil;
|
||||
import com.dfsek.terra.image.ImageLoader;
|
||||
@@ -24,9 +24,9 @@ public class StepGUICommand extends WorldCommand {
|
||||
LangUtil.send("command.image.gui.debug", sender);
|
||||
return true;
|
||||
}
|
||||
ImageLoader loader = ((Terra) getMain()).getWorld(world).getConfig().getTemplate().getImageLoader();
|
||||
if(loader != null) loader.debug(true, sender.getWorld(), (Terra) getMain());
|
||||
else ImageLoader.debugWorld(true, world, (Terra) getMain());
|
||||
ImageLoader loader = ((TerraBukkitPlugin) getMain()).getWorld(world).getConfig().getTemplate().getImageLoader();
|
||||
if(loader != null) loader.debug(true, sender.getWorld(), (TerraBukkitPlugin) getMain());
|
||||
else ImageLoader.debugWorld(true, world, (TerraBukkitPlugin) getMain());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.dfsek.terra.command.profile;
|
||||
|
||||
import com.dfsek.terra.Terra;
|
||||
import com.dfsek.terra.api.bukkit.TerraBukkitPlugin;
|
||||
import com.dfsek.terra.api.gaea.command.WorldCommand;
|
||||
import com.dfsek.terra.api.gaea.profiler.WorldProfiler;
|
||||
import org.bukkit.World;
|
||||
@@ -19,7 +19,7 @@ public class QueryCommand extends WorldCommand {
|
||||
|
||||
@Override
|
||||
public boolean execute(@NotNull Player sender, @NotNull Command command, @NotNull String label, @NotNull String[] args, World world) {
|
||||
WorldProfiler profile = ((Terra) getMain()).getWorld(world).getProfiler();
|
||||
WorldProfiler profile = ((TerraBukkitPlugin) getMain()).getWorld(world).getProfiler();
|
||||
sender.sendMessage(profile.getResultsFormatted());
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.dfsek.terra.command.profile;
|
||||
|
||||
import com.dfsek.terra.Terra;
|
||||
import com.dfsek.terra.api.bukkit.TerraBukkitPlugin;
|
||||
import com.dfsek.terra.api.gaea.command.WorldCommand;
|
||||
import com.dfsek.terra.api.gaea.profiler.WorldProfiler;
|
||||
import com.dfsek.terra.config.lang.LangUtil;
|
||||
@@ -20,7 +20,7 @@ public class ResetCommand extends WorldCommand {
|
||||
|
||||
@Override
|
||||
public boolean execute(@NotNull Player sender, @NotNull Command command, @NotNull String label, @NotNull String[] args, World world) {
|
||||
WorldProfiler profile = ((Terra) getMain()).getWorld(world).getProfiler();
|
||||
WorldProfiler profile = ((TerraBukkitPlugin) getMain()).getWorld(world).getProfiler();
|
||||
profile.reset();
|
||||
LangUtil.send("command.profile.reset", sender);
|
||||
return true;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.dfsek.terra.command.profile;
|
||||
|
||||
import com.dfsek.terra.Terra;
|
||||
import com.dfsek.terra.api.bukkit.TerraBukkitPlugin;
|
||||
import com.dfsek.terra.api.gaea.command.WorldCommand;
|
||||
import com.dfsek.terra.api.gaea.profiler.WorldProfiler;
|
||||
import com.dfsek.terra.config.lang.LangUtil;
|
||||
@@ -20,7 +20,7 @@ public class StartCommand extends WorldCommand {
|
||||
|
||||
@Override
|
||||
public boolean execute(@NotNull Player sender, @NotNull Command command, @NotNull String label, @NotNull String[] args, World world) {
|
||||
WorldProfiler profile = ((Terra) getMain()).getWorld(world).getProfiler();
|
||||
WorldProfiler profile = ((TerraBukkitPlugin) getMain()).getWorld(world).getProfiler();
|
||||
profile.setProfiling(true);
|
||||
LangUtil.send("command.profile.start", sender);
|
||||
return true;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.dfsek.terra.command.profile;
|
||||
|
||||
import com.dfsek.terra.Terra;
|
||||
import com.dfsek.terra.api.bukkit.TerraBukkitPlugin;
|
||||
import com.dfsek.terra.api.gaea.command.WorldCommand;
|
||||
import com.dfsek.terra.api.gaea.profiler.WorldProfiler;
|
||||
import com.dfsek.terra.config.lang.LangUtil;
|
||||
@@ -20,7 +20,7 @@ public class StopCommand extends WorldCommand {
|
||||
|
||||
@Override
|
||||
public boolean execute(@NotNull Player sender, @NotNull Command command, @NotNull String label, @NotNull String[] args, World world) {
|
||||
WorldProfiler profile = ((Terra) getMain()).getWorld(world).getProfiler();
|
||||
WorldProfiler profile = ((TerraBukkitPlugin) getMain()).getWorld(world).getProfiler();
|
||||
profile.setProfiling(false);
|
||||
LangUtil.send("command.profile.stop", sender);
|
||||
return true;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.dfsek.terra.command.structure;
|
||||
|
||||
import com.dfsek.terra.Terra;
|
||||
import com.dfsek.terra.api.bukkit.TerraBukkitPlugin;
|
||||
import com.dfsek.terra.api.gaea.command.WorldCommand;
|
||||
import com.dfsek.terra.async.AsyncStructureFinder;
|
||||
import com.dfsek.terra.config.lang.LangUtil;
|
||||
@@ -46,12 +46,12 @@ public class LocateCommand extends WorldCommand {
|
||||
}
|
||||
TerraStructure s;
|
||||
try {
|
||||
s = Objects.requireNonNull(((Terra) getMain()).getWorld(world).getConfig().getStructure(id));
|
||||
s = Objects.requireNonNull(((TerraBukkitPlugin) getMain()).getWorld(world).getConfig().getStructure(id));
|
||||
} catch(IllegalArgumentException | NullPointerException e) {
|
||||
LangUtil.send("command.structure.invalid", sender, id);
|
||||
return true;
|
||||
}
|
||||
Bukkit.getScheduler().runTaskAsynchronously(getMain(), new AsyncStructureFinder(((Terra) getMain()).getWorld(world).getGrid(), s, sender.getLocation(), 0, maxRadius, (location) -> {
|
||||
Bukkit.getScheduler().runTaskAsynchronously(getMain(), new AsyncStructureFinder(((TerraBukkitPlugin) getMain()).getWorld(world).getGrid(), s, sender.getLocation(), 0, maxRadius, (location) -> {
|
||||
if(sender.isOnline()) {
|
||||
if(location != null) {
|
||||
ComponentBuilder cm = new ComponentBuilder(String.format("The nearest %s is at ", id.toLowerCase()))
|
||||
@@ -64,7 +64,7 @@ public class LocateCommand extends WorldCommand {
|
||||
} else
|
||||
sender.sendMessage("Unable to locate structure. ");
|
||||
}
|
||||
}, (Terra) getMain()));
|
||||
}, (TerraBukkitPlugin) getMain()));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ public class LocateCommand extends WorldCommand {
|
||||
public List<String> getTabCompletions(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) {
|
||||
if(!(sender instanceof Player) || !(((Player) sender).getWorld().getGenerator() instanceof TerraChunkGenerator))
|
||||
return Collections.emptyList();
|
||||
List<String> ids = ((Terra) getMain()).getWorld(((Player) sender).getWorld()).getConfig().getStructureIDs();
|
||||
List<String> ids = ((TerraBukkitPlugin) getMain()).getWorld(((Player) sender).getWorld()).getConfig().getStructureIDs();
|
||||
if(args.length == 1)
|
||||
return ids.stream().filter(string -> string.toUpperCase().startsWith(args[0].toUpperCase())).collect(Collectors.toList());
|
||||
return Collections.emptyList();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.dfsek.terra.command.structure;
|
||||
|
||||
import com.dfsek.terra.Terra;
|
||||
import com.dfsek.terra.api.bukkit.TerraBukkitPlugin;
|
||||
import com.dfsek.terra.api.gaea.command.DebugCommand;
|
||||
import com.dfsek.terra.api.gaea.command.WorldCommand;
|
||||
import com.dfsek.terra.structure.StructureSpawnRequirement;
|
||||
@@ -25,9 +25,9 @@ public class SpawnCommand extends WorldCommand implements DebugCommand {
|
||||
int x = p.getBlockX();
|
||||
int y = p.getBlockY();
|
||||
int z = p.getBlockZ();
|
||||
boolean air = StructureSpawnRequirement.AIR.getInstance(world, (Terra) getMain()).matches(x, y, z);
|
||||
boolean ground = StructureSpawnRequirement.LAND.getInstance(world, (Terra) getMain()).matches(x, y, z);
|
||||
boolean sea = StructureSpawnRequirement.OCEAN.getInstance(world, (Terra) getMain()).matches(x, y, z);
|
||||
boolean air = StructureSpawnRequirement.AIR.getInstance(world, (TerraBukkitPlugin) getMain()).matches(x, y, z);
|
||||
boolean ground = StructureSpawnRequirement.LAND.getInstance(world, (TerraBukkitPlugin) getMain()).matches(x, y, z);
|
||||
boolean sea = StructureSpawnRequirement.OCEAN.getInstance(world, (TerraBukkitPlugin) getMain()).matches(x, y, z);
|
||||
|
||||
sender.sendMessage("AIR: " + air + "\nLAND: " + ground + "\nOCEAN: " + sea);
|
||||
return true;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.dfsek.terra.command.structure.load;
|
||||
|
||||
import com.dfsek.terra.Terra;
|
||||
import com.dfsek.terra.api.bukkit.TerraBukkitPlugin;
|
||||
import com.dfsek.terra.api.gaea.command.DebugCommand;
|
||||
import com.dfsek.terra.config.lang.LangUtil;
|
||||
import com.dfsek.terra.structure.Rotation;
|
||||
@@ -36,8 +36,8 @@ public class LoadFullCommand extends LoadCommand implements DebugCommand {
|
||||
return true;
|
||||
}
|
||||
Structure struc = Structure.load(new File(getMain().getDataFolder() + File.separator + "export" + File.separator + "structures", args[0] + ".tstructure"));
|
||||
if(chunk) struc.paste(sender.getLocation(), sender.getLocation().getChunk(), r, (Terra) getMain());
|
||||
else struc.paste(sender.getLocation(), r, (Terra) getMain());
|
||||
if(chunk) struc.paste(sender.getLocation(), sender.getLocation().getChunk(), r, (TerraBukkitPlugin) getMain());
|
||||
else struc.paste(sender.getLocation(), r, (TerraBukkitPlugin) getMain());
|
||||
//sender.sendMessage(String.valueOf(struc.checkSpawns(sender.getLocation(), r)));
|
||||
} catch(IOException e) {
|
||||
e.printStackTrace();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.dfsek.terra.command.structure.load;
|
||||
|
||||
import com.dfsek.terra.Terra;
|
||||
import com.dfsek.terra.api.bukkit.TerraBukkitPlugin;
|
||||
import com.dfsek.terra.api.gaea.command.DebugCommand;
|
||||
import com.dfsek.terra.api.generic.world.WorldHandle;
|
||||
import com.dfsek.terra.config.lang.LangUtil;
|
||||
@@ -38,7 +38,7 @@ public class LoadRawCommand extends LoadCommand implements DebugCommand {
|
||||
@Override
|
||||
public boolean execute(@NotNull Player sender, @NotNull Command command, @NotNull String s, @NotNull String[] args) {
|
||||
try {
|
||||
WorldHandle handle = ((Terra) getMain()).getHandle();
|
||||
WorldHandle handle = ((TerraBukkitPlugin) getMain()).getHandle();
|
||||
Structure struc = Structure.load(new File(getMain().getDataFolder() + File.separator + "export" + File.separator + "structures", args[0] + ".tstructure"));
|
||||
StructureInfo info = struc.getStructureInfo();
|
||||
int centerX = info.getCenterX();
|
||||
|
||||
@@ -4,12 +4,12 @@ import com.dfsek.tectonic.abstraction.AbstractConfigLoader;
|
||||
import com.dfsek.tectonic.exception.ConfigException;
|
||||
import com.dfsek.tectonic.exception.LoadException;
|
||||
import com.dfsek.tectonic.loading.ConfigLoader;
|
||||
import com.dfsek.terra.Terra;
|
||||
import com.dfsek.terra.api.gaea.biome.Biome;
|
||||
import com.dfsek.terra.api.gaea.structures.loot.LootTable;
|
||||
import com.dfsek.terra.api.gaea.tree.Tree;
|
||||
import com.dfsek.terra.api.gaea.world.Flora;
|
||||
import com.dfsek.terra.api.gaea.world.palette.Palette;
|
||||
import com.dfsek.terra.api.generic.TerraPlugin;
|
||||
import com.dfsek.terra.biome.UserDefinedBiome;
|
||||
import com.dfsek.terra.biome.grid.master.TerraBiomeGrid;
|
||||
import com.dfsek.terra.carving.UserDefinedCarver;
|
||||
@@ -102,11 +102,11 @@ public class ConfigPack {
|
||||
.registerLoader(TerraStructure.class, structureRegistry);
|
||||
}
|
||||
|
||||
public ConfigPack(File folder, Terra main) throws ConfigException {
|
||||
public ConfigPack(File folder, TerraPlugin main) throws ConfigException {
|
||||
long l = System.nanoTime();
|
||||
|
||||
main.registerAllLoaders(selfLoader);
|
||||
main.registerAllLoaders(abstractConfigLoader);
|
||||
main.register(selfLoader);
|
||||
main.register(abstractConfigLoader);
|
||||
|
||||
File pack = new File(folder, "pack.yml");
|
||||
|
||||
@@ -119,11 +119,11 @@ public class ConfigPack {
|
||||
load(new FolderLoader(folder.toPath()), l, main);
|
||||
}
|
||||
|
||||
public ConfigPack(ZipFile file, Terra main) throws ConfigException {
|
||||
public ConfigPack(ZipFile file, TerraPlugin main) throws ConfigException {
|
||||
long l = System.nanoTime();
|
||||
|
||||
main.registerAllLoaders(selfLoader);
|
||||
main.registerAllLoaders(abstractConfigLoader);
|
||||
main.register(selfLoader);
|
||||
main.register(abstractConfigLoader);
|
||||
|
||||
InputStream stream = null;
|
||||
|
||||
@@ -143,7 +143,7 @@ public class ConfigPack {
|
||||
load(new ZIPLoader(file), l, main);
|
||||
}
|
||||
|
||||
private void load(Loader loader, long start, Terra main) throws ConfigException {
|
||||
private void load(Loader loader, long start, TerraPlugin main) throws ConfigException {
|
||||
for(Map.Entry<String, Double> var : template.getVariables().entrySet()) {
|
||||
varScope.create(var.getKey()).setValue(var.getValue());
|
||||
}
|
||||
@@ -179,7 +179,7 @@ public class ConfigPack {
|
||||
LangUtil.log("config-pack.loaded", Level.INFO, template.getID(), String.valueOf((System.nanoTime() - start) / 1000000D), template.getAuthor(), template.getVersion());
|
||||
}
|
||||
|
||||
private <C extends AbstractableTemplate, O> void buildAll(TerraFactory<C, O> factory, TerraRegistry<O> registry, List<C> configTemplates, Terra main) throws LoadException {
|
||||
private <C extends AbstractableTemplate, O> void buildAll(TerraFactory<C, O> factory, TerraRegistry<O> registry, List<C> configTemplates, TerraPlugin main) throws LoadException {
|
||||
for(C template : configTemplates) registry.add(template.getID(), factory.build(template, main));
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ import com.dfsek.tectonic.annotations.Value;
|
||||
import com.dfsek.tectonic.config.ConfigTemplate;
|
||||
import com.dfsek.tectonic.exception.ConfigException;
|
||||
import com.dfsek.tectonic.loading.ConfigLoader;
|
||||
import com.dfsek.terra.Terra;
|
||||
import com.dfsek.terra.api.bukkit.TerraBukkitPlugin;
|
||||
import com.dfsek.terra.api.gaea.GaeaPlugin;
|
||||
import com.dfsek.terra.api.gaea.util.JarUtil;
|
||||
import com.dfsek.terra.debug.Debug;
|
||||
@@ -51,7 +51,7 @@ public class PluginConfig implements ConfigTemplate {
|
||||
ConfigLoader loader = new ConfigLoader();
|
||||
loader.load(this, file);
|
||||
if(dumpDefaultConfig) { // Don't dump default config if already loaded.
|
||||
try(JarFile jar = new JarFile(new File(Terra.class.getProtectionDomain().getCodeSource().getLocation().toURI()))) {
|
||||
try(JarFile jar = new JarFile(new File(TerraBukkitPlugin.class.getProtectionDomain().getCodeSource().getLocation().toURI()))) {
|
||||
JarUtil.copyResourcesToDirectory(jar, "packs", new File(main.getDataFolder(), "packs").toString());
|
||||
} catch(IOException | URISyntaxException e) {
|
||||
Debug.error("Failed to dump default config files!");
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.dfsek.terra.config.builder.biomegrid;
|
||||
|
||||
import com.dfsek.terra.api.gaea.biome.BiomeGrid;
|
||||
import com.dfsek.terra.api.generic.world.World;
|
||||
import com.dfsek.terra.config.base.ConfigPack;
|
||||
import org.bukkit.World;
|
||||
|
||||
public interface BiomeGridBuilder {
|
||||
BiomeGrid build(World world, ConfigPack config);
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package com.dfsek.terra.config.builder.biomegrid;
|
||||
|
||||
import com.dfsek.terra.api.gaea.biome.Biome;
|
||||
import com.dfsek.terra.api.generic.world.World;
|
||||
import com.dfsek.terra.biome.grid.SingleBiomeGrid;
|
||||
import com.dfsek.terra.config.base.ConfigPack;
|
||||
import org.bukkit.World;
|
||||
|
||||
public class SingleGridBuilder implements BiomeGridBuilder {
|
||||
private final Biome biome;
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package com.dfsek.terra.config.builder.biomegrid;
|
||||
|
||||
import com.dfsek.terra.api.gaea.biome.Biome;
|
||||
import com.dfsek.terra.api.generic.world.World;
|
||||
import com.dfsek.terra.biome.grid.UserDefinedGrid;
|
||||
import com.dfsek.terra.config.base.ConfigPack;
|
||||
import org.bukkit.World;
|
||||
|
||||
public class UserDefinedGridBuilder implements BiomeGridBuilder {
|
||||
private double xFreq;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.dfsek.terra.config.factories;
|
||||
|
||||
import com.dfsek.terra.Terra;
|
||||
import com.dfsek.terra.api.gaea.math.ProbabilityCollection;
|
||||
import com.dfsek.terra.api.generic.TerraPlugin;
|
||||
import com.dfsek.terra.biome.UserDefinedBiome;
|
||||
import com.dfsek.terra.config.base.ConfigPack;
|
||||
import com.dfsek.terra.config.builder.GeneratorBuilder;
|
||||
@@ -16,7 +16,7 @@ public class BiomeFactory implements TerraFactory<BiomeTemplate, UserDefinedBiom
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserDefinedBiome build(BiomeTemplate template, Terra main) {
|
||||
public UserDefinedBiome build(BiomeTemplate template, TerraPlugin main) {
|
||||
UserDefinedDecorator decorator = new UserDefinedDecorator(new ProbabilityCollection<>(), new ProbabilityCollection<>(), 0, 0);
|
||||
GeneratorBuilder generatorBuilder = new GeneratorBuilder();
|
||||
generatorBuilder.setElevationEquation(template.getElevationEquation());
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.dfsek.terra.config.factories;
|
||||
|
||||
import com.dfsek.terra.Terra;
|
||||
import com.dfsek.terra.api.gaea.biome.Biome;
|
||||
import com.dfsek.terra.api.generic.TerraPlugin;
|
||||
import com.dfsek.terra.biome.UserDefinedBiome;
|
||||
import com.dfsek.terra.config.builder.biomegrid.BiomeGridBuilder;
|
||||
import com.dfsek.terra.config.builder.biomegrid.UserDefinedGridBuilder;
|
||||
@@ -12,7 +12,7 @@ import java.util.List;
|
||||
public class BiomeGridFactory implements TerraFactory<BiomeGridTemplate, BiomeGridBuilder> {
|
||||
|
||||
@Override
|
||||
public UserDefinedGridBuilder build(BiomeGridTemplate config, Terra main) {
|
||||
public UserDefinedGridBuilder build(BiomeGridTemplate config, TerraPlugin main) {
|
||||
|
||||
UserDefinedGridBuilder holder = new UserDefinedGridBuilder();
|
||||
holder.setXFreq(config.getXFreq());
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.dfsek.terra.config.factories;
|
||||
|
||||
import com.dfsek.tectonic.exception.LoadException;
|
||||
import com.dfsek.terra.Terra;
|
||||
import com.dfsek.terra.api.gaea.math.MathUtil;
|
||||
import com.dfsek.terra.api.generic.TerraPlugin;
|
||||
import com.dfsek.terra.carving.UserDefinedCarver;
|
||||
import com.dfsek.terra.config.base.ConfigPack;
|
||||
import com.dfsek.terra.config.templates.CarverTemplate;
|
||||
@@ -19,7 +19,7 @@ public class CarverFactory implements TerraFactory<CarverTemplate, UserDefinedCa
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserDefinedCarver build(CarverTemplate config, Terra main) throws LoadException {
|
||||
public UserDefinedCarver build(CarverTemplate config, TerraPlugin main) throws LoadException {
|
||||
double[] start = new double[] {config.getStartX(), config.getStartY(), config.getStartZ()};
|
||||
double[] mutate = new double[] {config.getMutateX(), config.getMutateY(), config.getMutateZ()};
|
||||
List<String> radius = Arrays.asList(config.getRadMX(), config.getRadMY(), config.getRadMZ());
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package com.dfsek.terra.config.factories;
|
||||
|
||||
import com.dfsek.terra.Terra;
|
||||
import com.dfsek.terra.api.gaea.util.FastRandom;
|
||||
import com.dfsek.terra.api.gaea.world.Flora;
|
||||
import com.dfsek.terra.api.gaea.world.palette.Palette;
|
||||
import com.dfsek.terra.api.gaea.world.palette.RandomPalette;
|
||||
import com.dfsek.terra.api.generic.TerraPlugin;
|
||||
import com.dfsek.terra.biome.palette.PaletteLayer;
|
||||
import com.dfsek.terra.config.templates.FloraTemplate;
|
||||
import com.dfsek.terra.generation.items.flora.TerraFlora;
|
||||
@@ -12,7 +12,7 @@ import org.bukkit.block.data.BlockData;
|
||||
|
||||
public class FloraFactory implements TerraFactory<FloraTemplate, Flora> {
|
||||
@Override
|
||||
public TerraFlora build(FloraTemplate config, Terra main) {
|
||||
public TerraFlora build(FloraTemplate config, TerraPlugin main) {
|
||||
Palette<BlockData> palette = new RandomPalette<>(new FastRandom(2403));
|
||||
for(PaletteLayer layer : config.getFloraPalette()) {
|
||||
palette.add(layer.getLayer(), layer.getSize());
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.dfsek.terra.config.factories;
|
||||
|
||||
import com.dfsek.terra.Terra;
|
||||
import com.dfsek.terra.api.generic.TerraPlugin;
|
||||
import com.dfsek.terra.config.templates.OreTemplate;
|
||||
import com.dfsek.terra.generation.items.ores.DeformedSphereOre;
|
||||
import com.dfsek.terra.generation.items.ores.Ore;
|
||||
@@ -9,7 +9,7 @@ import org.bukkit.block.data.BlockData;
|
||||
|
||||
public class OreFactory implements TerraFactory<OreTemplate, Ore> {
|
||||
@Override
|
||||
public Ore build(OreTemplate config, Terra main) {
|
||||
public Ore build(OreTemplate config, TerraPlugin main) {
|
||||
BlockData m = config.getMaterial();
|
||||
switch(config.getType()) {
|
||||
case SPHERE:
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
package com.dfsek.terra.config.factories;
|
||||
|
||||
import com.dfsek.terra.Terra;
|
||||
import com.dfsek.terra.api.gaea.math.FastNoiseLite;
|
||||
import com.dfsek.terra.api.gaea.util.FastRandom;
|
||||
import com.dfsek.terra.api.gaea.world.palette.Palette;
|
||||
import com.dfsek.terra.api.gaea.world.palette.RandomPalette;
|
||||
import com.dfsek.terra.api.gaea.world.palette.SimplexPalette;
|
||||
import com.dfsek.terra.api.generic.TerraPlugin;
|
||||
import com.dfsek.terra.biome.palette.PaletteLayer;
|
||||
import com.dfsek.terra.config.templates.PaletteTemplate;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
|
||||
public class PaletteFactory implements TerraFactory<PaletteTemplate, Palette<BlockData>> {
|
||||
@Override
|
||||
public Palette<BlockData> build(PaletteTemplate config, Terra main) {
|
||||
public Palette<BlockData> build(PaletteTemplate config, TerraPlugin main) {
|
||||
Palette<BlockData> palette;
|
||||
if(config.isSimplex()) {
|
||||
FastNoiseLite noise = new FastNoiseLite((int) config.getSeed());
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
package com.dfsek.terra.config.factories;
|
||||
|
||||
import com.dfsek.tectonic.exception.LoadException;
|
||||
import com.dfsek.terra.Terra;
|
||||
import com.dfsek.terra.api.generic.TerraPlugin;
|
||||
import com.dfsek.terra.config.templates.StructureTemplate;
|
||||
import com.dfsek.terra.generation.items.TerraStructure;
|
||||
|
||||
public class StructureFactory implements TerraFactory<StructureTemplate, TerraStructure> {
|
||||
@Override
|
||||
public TerraStructure build(StructureTemplate config, Terra main) throws LoadException {
|
||||
public TerraStructure build(StructureTemplate config, TerraPlugin main) throws LoadException {
|
||||
return new TerraStructure(config.getStructures(), config.getBound(), config.getY(), config.getSpawn(), config.getLoot(), config);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,8 +2,8 @@ package com.dfsek.terra.config.factories;
|
||||
|
||||
import com.dfsek.tectonic.config.ConfigTemplate;
|
||||
import com.dfsek.tectonic.exception.LoadException;
|
||||
import com.dfsek.terra.Terra;
|
||||
import com.dfsek.terra.api.generic.TerraPlugin;
|
||||
|
||||
public interface TerraFactory<C extends ConfigTemplate, O> {
|
||||
O build(C config, Terra main) throws LoadException;
|
||||
O build(C config, TerraPlugin main) throws LoadException;
|
||||
}
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
package com.dfsek.terra.config.factories;
|
||||
|
||||
import com.dfsek.tectonic.exception.LoadException;
|
||||
import com.dfsek.terra.Terra;
|
||||
import com.dfsek.terra.api.gaea.tree.Tree;
|
||||
import com.dfsek.terra.api.generic.TerraPlugin;
|
||||
import com.dfsek.terra.config.templates.TreeTemplate;
|
||||
import com.dfsek.terra.generation.items.tree.TerraTree;
|
||||
|
||||
public class TreeFactory implements TerraFactory<TreeTemplate, Tree> {
|
||||
@Override
|
||||
public Tree build(TreeTemplate config, Terra main) throws LoadException {
|
||||
public Tree build(TreeTemplate config, TerraPlugin main) throws LoadException {
|
||||
return new TerraTree(config.getSpawnable(), config.getyOffset(), config.getStructures());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.dfsek.terra.config.lang;
|
||||
|
||||
import com.dfsek.terra.Terra;
|
||||
import com.dfsek.terra.api.bukkit.TerraBukkitPlugin;
|
||||
import com.dfsek.terra.api.gaea.lang.Language;
|
||||
import com.dfsek.terra.debug.Debug;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@@ -23,7 +23,7 @@ public final class LangUtil {
|
||||
public static void load(String langID, JavaPlugin main) {
|
||||
logger = main.getLogger();
|
||||
File file = new File(main.getDataFolder(), "lang");
|
||||
try(JarFile jar = new JarFile(new File(Terra.class.getProtectionDomain().getCodeSource().getLocation().toURI()))) {
|
||||
try(JarFile jar = new JarFile(new File(TerraBukkitPlugin.class.getProtectionDomain().getCodeSource().getLocation().toURI()))) {
|
||||
copyResourcesToDirectory(jar, "lang", file.toString());
|
||||
} catch(IOException | URISyntaxException e) {
|
||||
Debug.error("Failed to dump language files!");
|
||||
|
||||
@@ -3,11 +3,11 @@ package com.dfsek.terra.config.loaders.config;
|
||||
import com.dfsek.tectonic.exception.LoadException;
|
||||
import com.dfsek.tectonic.loading.ConfigLoader;
|
||||
import com.dfsek.tectonic.loading.TypeLoader;
|
||||
import com.dfsek.terra.api.gaea.GaeaPlugin;
|
||||
import com.dfsek.terra.api.gaea.math.FastNoiseLite;
|
||||
import com.dfsek.terra.api.gaea.math.ProbabilityCollection;
|
||||
import com.dfsek.terra.api.gaea.math.Range;
|
||||
import com.dfsek.terra.api.gaea.tree.Tree;
|
||||
import com.dfsek.terra.api.generic.TerraPlugin;
|
||||
import com.dfsek.terra.config.loaders.Types;
|
||||
import com.dfsek.terra.generation.items.tree.TreeLayer;
|
||||
|
||||
@@ -16,9 +16,9 @@ import java.util.Map;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public class TreeLayerLoader implements TypeLoader<TreeLayer> {
|
||||
private final GaeaPlugin main;
|
||||
private final TerraPlugin main;
|
||||
|
||||
public TreeLayerLoader(GaeaPlugin main) {
|
||||
public TreeLayerLoader(TerraPlugin main) {
|
||||
this.main = main;
|
||||
}
|
||||
|
||||
@@ -33,9 +33,9 @@ public class TreeLayerLoader implements TypeLoader<TreeLayer> {
|
||||
if(map.containsKey("simplex-frequency")) {
|
||||
FastNoiseLite noiseLite = new FastNoiseLite();
|
||||
noiseLite.setFrequency((Double) map.get("simplex-frequency"));
|
||||
return new TreeLayer(density, range, items, noiseLite, main);
|
||||
return new TreeLayer(density, range, items, noiseLite);
|
||||
}
|
||||
|
||||
return new TreeLayer(density, range, items, null, main);
|
||||
return new TreeLayer(density, range, items, null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,8 +7,10 @@ import com.dfsek.tectonic.config.ValidatedConfigTemplate;
|
||||
import com.dfsek.tectonic.exception.ValidationException;
|
||||
import com.dfsek.terra.api.gaea.util.GlueList;
|
||||
import com.dfsek.terra.api.gaea.world.palette.Palette;
|
||||
import com.dfsek.terra.api.generic.world.Biome;
|
||||
import com.dfsek.terra.api.generic.world.block.BlockData;
|
||||
import com.dfsek.terra.api.generic.world.block.MaterialData;
|
||||
import com.dfsek.terra.biome.palette.PaletteHolder;
|
||||
import com.dfsek.terra.biome.palette.SinglePalette;
|
||||
import com.dfsek.terra.carving.UserDefinedCarver;
|
||||
import com.dfsek.terra.config.base.ConfigPack;
|
||||
import com.dfsek.terra.generation.items.TerraStructure;
|
||||
@@ -16,9 +18,6 @@ import com.dfsek.terra.generation.items.flora.FloraLayer;
|
||||
import com.dfsek.terra.generation.items.ores.OreHolder;
|
||||
import com.dfsek.terra.generation.items.tree.TreeLayer;
|
||||
import com.dfsek.terra.math.BlankFunction;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import parsii.eval.Parser;
|
||||
import parsii.eval.Scope;
|
||||
import parsii.tokenizer.ParseException;
|
||||
@@ -74,7 +73,7 @@ public class BiomeTemplate extends AbstractableTemplate implements ValidatedConf
|
||||
@Value("ocean.palette")
|
||||
@Abstractable
|
||||
@Default
|
||||
private Palette<BlockData> oceanPalette = new SinglePalette<>(Material.WATER.createBlockData());
|
||||
private Palette<BlockData> oceanPalette = null;
|
||||
|
||||
@Value("elevation.equation")
|
||||
@Default
|
||||
@@ -104,12 +103,12 @@ public class BiomeTemplate extends AbstractableTemplate implements ValidatedConf
|
||||
@Value("slabs.palettes")
|
||||
@Abstractable
|
||||
@Default
|
||||
private Map<Material, Palette<BlockData>> slabPalettes;
|
||||
private Map<MaterialData, Palette<BlockData>> slabPalettes;
|
||||
|
||||
@Value("slabs.stair-palettes")
|
||||
@Abstractable
|
||||
@Default
|
||||
private Map<Material, Palette<BlockData>> stairPalettes;
|
||||
private Map<MaterialData, Palette<BlockData>> stairPalettes;
|
||||
|
||||
@Value("slant.threshold")
|
||||
@Abstractable
|
||||
@@ -145,11 +144,11 @@ public class BiomeTemplate extends AbstractableTemplate implements ValidatedConf
|
||||
return doSlabs;
|
||||
}
|
||||
|
||||
public Map<Material, Palette<BlockData>> getSlabPalettes() {
|
||||
public Map<MaterialData, Palette<BlockData>> getSlabPalettes() {
|
||||
return slabPalettes;
|
||||
}
|
||||
|
||||
public Map<Material, Palette<BlockData>> getStairPalettes() {
|
||||
public Map<MaterialData, Palette<BlockData>> getStairPalettes() {
|
||||
return stairPalettes;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.dfsek.terra.debug.gui;
|
||||
|
||||
import com.dfsek.terra.Terra;
|
||||
import com.dfsek.terra.api.bukkit.TerraBukkitPlugin;
|
||||
import com.dfsek.terra.api.gaea.generation.GenerationPhase;
|
||||
import com.dfsek.terra.biome.UserDefinedBiome;
|
||||
import com.dfsek.terra.image.ImageLoader;
|
||||
@@ -19,9 +19,9 @@ public class DebugFrame extends JFrame implements ActionListener {
|
||||
private final int x;
|
||||
private final int z;
|
||||
private final BufferedImage img;
|
||||
private final Terra main;
|
||||
private final TerraBukkitPlugin main;
|
||||
|
||||
public DebugFrame(BufferedImage image, String s, Terra main) {
|
||||
public DebugFrame(BufferedImage image, String s, TerraBukkitPlugin main) {
|
||||
super(s);
|
||||
this.x = image.getWidth();
|
||||
this.z = image.getHeight();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.dfsek.terra.debug.gui;
|
||||
|
||||
import com.dfsek.terra.Terra;
|
||||
import com.dfsek.terra.api.bukkit.TerraBukkitPlugin;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
@@ -9,9 +9,9 @@ import java.awt.image.BufferedImage;
|
||||
public class DebugGUI extends Thread {
|
||||
|
||||
private final BufferedImage img;
|
||||
private final Terra main;
|
||||
private final TerraBukkitPlugin main;
|
||||
|
||||
public DebugGUI(BufferedImage img, Terra main) {
|
||||
public DebugGUI(BufferedImage img, TerraBukkitPlugin main) {
|
||||
this.img = img;
|
||||
this.main = main;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.dfsek.terra.generation;
|
||||
|
||||
import com.dfsek.terra.Terra;
|
||||
import com.dfsek.terra.TerraWorld;
|
||||
import com.dfsek.terra.api.bukkit.TerraBukkitPlugin;
|
||||
import com.dfsek.terra.api.gaea.biome.Biome;
|
||||
import com.dfsek.terra.api.gaea.generation.GenerationPhase;
|
||||
import com.dfsek.terra.api.gaea.math.ChunkInterpolator3;
|
||||
@@ -9,7 +9,6 @@ import com.dfsek.terra.api.gaea.population.PopulationManager;
|
||||
import com.dfsek.terra.api.gaea.profiler.ProfileFuture;
|
||||
import com.dfsek.terra.api.gaea.profiler.WorldProfiler;
|
||||
import com.dfsek.terra.api.gaea.world.palette.Palette;
|
||||
import com.dfsek.terra.api.generic.generator.BlockPopulator;
|
||||
import com.dfsek.terra.api.generic.generator.ChunkGenerator;
|
||||
import com.dfsek.terra.api.generic.world.BiomeGrid;
|
||||
import com.dfsek.terra.api.generic.world.Chunk;
|
||||
@@ -27,21 +26,19 @@ import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class ChunkGeneratorImpl implements ChunkGenerator {
|
||||
public class TerraChunkGenerator implements com.dfsek.terra.api.generic.generator.TerraChunkGenerator {
|
||||
private static final Map<World, PopulationManager> popMap = new HashMap<>();
|
||||
private final PopulationManager popMan;
|
||||
private final ConfigPack configPack;
|
||||
private final Terra main;
|
||||
private final TerraBukkitPlugin main;
|
||||
private boolean needsLoad = true;
|
||||
|
||||
public ChunkGeneratorImpl(ConfigPack c, Terra main) {
|
||||
public TerraChunkGenerator(ConfigPack c, TerraBukkitPlugin main) {
|
||||
popMan = new PopulationManager(main);
|
||||
this.configPack = c;
|
||||
this.main = main;
|
||||
@@ -62,7 +59,7 @@ public class ChunkGeneratorImpl implements ChunkGenerator {
|
||||
}
|
||||
|
||||
public static synchronized void fixChunk(Chunk c) {
|
||||
if(!(c.getWorld().getGenerator() instanceof ChunkGeneratorImpl)) throw new IllegalArgumentException();
|
||||
if(!(c.getWorld().getGenerator() instanceof TerraChunkGenerator)) throw new IllegalArgumentException();
|
||||
popMap.get(c.getWorld()).checkNeighbors(c.getX(), c.getZ(), c.getWorld());
|
||||
}
|
||||
|
||||
@@ -92,7 +89,13 @@ public class ChunkGeneratorImpl implements ChunkGenerator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChunkData generateChunkData(@NotNull World world, @NotNull Random random, int chunkX, int chunkZ, @NotNull BiomeGrid biome, ChunkData chunk) {
|
||||
public ConfigPack getConfigPack() {
|
||||
return configPack;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void generateChunkData(@NotNull World world, @NotNull Random random, int chunkX, int chunkZ, @NotNull BiomeGrid biome, ChunkGenerator.ChunkData chunk) {
|
||||
TerraWorld tw = main.getWorld(world);
|
||||
com.dfsek.terra.api.gaea.biome.BiomeGrid grid = tw.getGrid();
|
||||
try(ProfileFuture ignore = tw.getProfiler().measure("TotalChunkGenTime")) {
|
||||
@@ -101,7 +104,7 @@ public class ChunkGeneratorImpl implements ChunkGenerator {
|
||||
interp = new ChunkInterpolator3(world, chunkX, chunkZ, tw.getGrid());
|
||||
if(needsLoad) load(world); // Load population data for world.
|
||||
|
||||
if(!tw.isSafe()) return chunk;
|
||||
if(!tw.isSafe()) return;
|
||||
int xOrig = (chunkX << 4);
|
||||
int zOrig = (chunkZ << 4);
|
||||
|
||||
@@ -166,12 +169,6 @@ public class ChunkGeneratorImpl implements ChunkGenerator {
|
||||
}
|
||||
}
|
||||
}
|
||||
return chunk;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BlockPopulator> getDefaultPopulators(World world) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
public void attachProfiler(WorldProfiler p) {
|
||||
@@ -1,15 +1,14 @@
|
||||
package com.dfsek.terra.generation.config;
|
||||
|
||||
import com.dfsek.terra.api.gaea.biome.Generator;
|
||||
import com.dfsek.terra.api.gaea.math.FastNoiseLite;
|
||||
import com.dfsek.terra.api.gaea.math.Interpolator;
|
||||
import com.dfsek.terra.api.gaea.world.palette.Palette;
|
||||
import com.dfsek.terra.api.generic.world.World;
|
||||
import com.dfsek.terra.api.generic.world.block.BlockData;
|
||||
import com.dfsek.terra.biome.palette.PaletteHolder;
|
||||
import com.dfsek.terra.math.NoiseFunction2;
|
||||
import com.dfsek.terra.math.NoiseFunction3;
|
||||
import com.dfsek.terra.math.RandomFunction;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import parsii.eval.Expression;
|
||||
import parsii.eval.Parser;
|
||||
import parsii.eval.Scope;
|
||||
@@ -91,15 +90,7 @@ public class WorldGenerator extends Generator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized double getNoise(FastNoiseLite fastNoiseLite, World world, int x, int z) {
|
||||
xVar.setValue(x);
|
||||
yVar.setValue(0);
|
||||
zVar.setValue(z);
|
||||
return noiseExp.evaluate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized double getNoise(FastNoiseLite fastNoiseLite, World world, int x, int y, int z) {
|
||||
public synchronized double getNoise(World world, int x, int y, int z) {
|
||||
xVar.setValue(x);
|
||||
yVar.setValue(y);
|
||||
zVar.setValue(z);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.dfsek.terra.generation.items.flora;
|
||||
|
||||
import com.dfsek.terra.Terra;
|
||||
import com.dfsek.terra.api.bukkit.TerraBukkitPlugin;
|
||||
import com.dfsek.terra.api.gaea.math.Range;
|
||||
import com.dfsek.terra.api.gaea.util.FastRandom;
|
||||
import com.dfsek.terra.api.gaea.util.GlueList;
|
||||
@@ -41,9 +41,9 @@ public class TerraFlora implements Flora {
|
||||
|
||||
private final int irrigableOffset;
|
||||
|
||||
private final Terra main;
|
||||
private final TerraBukkitPlugin main;
|
||||
|
||||
public TerraFlora(Palette<BlockData> floraPalette, boolean physics, boolean ceiling, MaterialSet irrigable, MaterialSet spawnable, MaterialSet replaceable, MaterialSet testRotation, int maxPlacements, Search search, boolean spawnBlacklist, int irrigableOffset, Terra main) {
|
||||
public TerraFlora(Palette<BlockData> floraPalette, boolean physics, boolean ceiling, MaterialSet irrigable, MaterialSet spawnable, MaterialSet replaceable, MaterialSet testRotation, int maxPlacements, Search search, boolean spawnBlacklist, int irrigableOffset, TerraBukkitPlugin main) {
|
||||
this.floraPalette = floraPalette;
|
||||
this.physics = physics;
|
||||
this.testRotation = testRotation;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.dfsek.terra.generation.items.ores;
|
||||
|
||||
import com.dfsek.terra.Terra;
|
||||
import com.dfsek.terra.api.bukkit.TerraBukkitPlugin;
|
||||
import com.dfsek.terra.api.gaea.math.FastNoiseLite;
|
||||
import com.dfsek.terra.api.gaea.math.Range;
|
||||
import com.dfsek.terra.api.generic.world.WorldHandle;
|
||||
@@ -17,7 +17,7 @@ public class DeformedSphereOre extends Ore {
|
||||
private final double deformFrequency;
|
||||
private final Range size;
|
||||
|
||||
public DeformedSphereOre(BlockData material, MaterialSet replaceable, boolean applyGravity, double deform, double deformFrequency, Range size, Terra main) {
|
||||
public DeformedSphereOre(BlockData material, MaterialSet replaceable, boolean applyGravity, double deform, double deformFrequency, Range size, TerraBukkitPlugin main) {
|
||||
super(material, replaceable, applyGravity, main);
|
||||
this.deform = deform;
|
||||
this.deformFrequency = deformFrequency;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.dfsek.terra.generation.items.ores;
|
||||
|
||||
import com.dfsek.terra.Terra;
|
||||
import com.dfsek.terra.api.bukkit.TerraBukkitPlugin;
|
||||
import com.dfsek.terra.util.MaterialSet;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
@@ -13,9 +13,9 @@ public abstract class Ore {
|
||||
private final BlockData material;
|
||||
private final MaterialSet replaceable;
|
||||
private final boolean applyGravity;
|
||||
protected Terra main;
|
||||
protected TerraBukkitPlugin main;
|
||||
|
||||
public Ore(BlockData material, MaterialSet replaceable, boolean applyGravity, Terra main) {
|
||||
public Ore(BlockData material, MaterialSet replaceable, boolean applyGravity, TerraBukkitPlugin main) {
|
||||
|
||||
this.material = material;
|
||||
this.replaceable = replaceable;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.dfsek.terra.generation.items.ores;
|
||||
|
||||
import com.dfsek.terra.Terra;
|
||||
import com.dfsek.terra.api.bukkit.TerraBukkitPlugin;
|
||||
import com.dfsek.terra.api.gaea.math.Range;
|
||||
import com.dfsek.terra.api.generic.world.WorldHandle;
|
||||
import com.dfsek.terra.util.MaterialSet;
|
||||
@@ -16,7 +16,7 @@ import java.util.Random;
|
||||
public class VanillaOre extends Ore {
|
||||
private final Range sizeRange;
|
||||
|
||||
public VanillaOre(BlockData material, MaterialSet replaceable, boolean applyGravity, Range size, Terra main) {
|
||||
public VanillaOre(BlockData material, MaterialSet replaceable, boolean applyGravity, Range size, TerraBukkitPlugin main) {
|
||||
super(material, replaceable, applyGravity, main);
|
||||
this.sizeRange = size;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.dfsek.terra.generation.items.tree;
|
||||
|
||||
import com.dfsek.terra.Terra;
|
||||
import com.dfsek.terra.api.bukkit.TerraBukkitPlugin;
|
||||
import com.dfsek.terra.api.gaea.math.ProbabilityCollection;
|
||||
import com.dfsek.terra.api.gaea.tree.Tree;
|
||||
import com.dfsek.terra.api.generic.world.vector.Vector2;
|
||||
@@ -32,8 +32,8 @@ public class TerraTree implements Tree {
|
||||
if(!spawnable.contains(location.getBlock().getType())) return false;
|
||||
Structure struc = structure.get(random);
|
||||
Rotation rotation = Rotation.fromDegrees(random.nextInt(4) * 90);
|
||||
if(!struc.checkSpawns(mut, rotation, (Terra) main)) return false;
|
||||
struc.paste(mut, rotation, (Terra) main);
|
||||
if(!struc.checkSpawns(mut, rotation, (TerraBukkitPlugin) main)) return false;
|
||||
struc.paste(mut, rotation, (TerraBukkitPlugin) main);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ public class TerraTree implements Tree {
|
||||
return spawnable;
|
||||
}
|
||||
|
||||
public boolean plantBlockCheck(Location location, Random random, Terra main) {
|
||||
public boolean plantBlockCheck(Location location, Random random, TerraBukkitPlugin main) {
|
||||
Location mut = location.clone().subtract(0, yOffset, 0);
|
||||
if(!spawnable.contains(location.getBlock().getType())) return false;
|
||||
Structure struc = structure.get(random);
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.dfsek.terra.generation.items.tree;
|
||||
|
||||
import com.dfsek.terra.api.gaea.GaeaPlugin;
|
||||
import com.dfsek.terra.api.gaea.math.FastNoiseLite;
|
||||
import com.dfsek.terra.api.gaea.math.ProbabilityCollection;
|
||||
import com.dfsek.terra.api.gaea.math.Range;
|
||||
@@ -15,11 +14,9 @@ import org.bukkit.block.BlockFace;
|
||||
import java.util.Random;
|
||||
|
||||
public class TreeLayer extends PlaceableLayer<Tree> {
|
||||
private final GaeaPlugin main;
|
||||
|
||||
public TreeLayer(double density, Range level, ProbabilityCollection<Tree> layer, FastNoiseLite noise, GaeaPlugin main) {
|
||||
public TreeLayer(double density, Range level, ProbabilityCollection<Tree> layer, FastNoiseLite noise) {
|
||||
super(density, level, layer, noise);
|
||||
this.main = main;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -30,8 +27,8 @@ public class TreeLayer extends PlaceableLayer<Tree> {
|
||||
current = current.getRelative(BlockFace.DOWN);
|
||||
if(item.getSpawnable().contains(current.getType())) {
|
||||
if(item instanceof TreeType && current.getRelative(BlockFace.UP).isEmpty())
|
||||
item.plant(current.getLocation().add(0, 1, 0), random, main);
|
||||
else if(!(item instanceof TreeType)) item.plant(current.getLocation(), random, main);
|
||||
item.plant(current.getLocation().add(0, 1, 0), random);
|
||||
else if(!(item instanceof TreeType)) item.plant(current.getLocation(), random);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
package com.dfsek.terra.image;
|
||||
|
||||
import com.dfsek.terra.Terra;
|
||||
import com.dfsek.terra.api.bukkit.TerraBukkitPlugin;
|
||||
import com.dfsek.terra.api.gaea.biome.NormalizationUtil;
|
||||
import com.dfsek.terra.api.generic.world.World;
|
||||
import com.dfsek.terra.biome.BiomeZone;
|
||||
import com.dfsek.terra.biome.grid.master.TerraBiomeGrid;
|
||||
import com.dfsek.terra.debug.gui.DebugGUI;
|
||||
import net.jafama.FastMath;
|
||||
import org.bukkit.World;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import java.awt.*;
|
||||
@@ -24,7 +24,7 @@ public class ImageLoader {
|
||||
this.align = align;
|
||||
}
|
||||
|
||||
public static void debugWorld(boolean genStep, World w, Terra main) {
|
||||
public static void debugWorld(boolean genStep, World w, TerraBukkitPlugin main) {
|
||||
if(!main.isDebug()) return;
|
||||
BufferedImage newImg = new WorldImageGenerator(w, 1024, 1024, main).drawWorld(0, 0).getDraw();
|
||||
if(genStep) newImg = redrawStepped(newImg, w, Align.CENTER, main);
|
||||
@@ -32,7 +32,7 @@ public class ImageLoader {
|
||||
debugGUI.start();
|
||||
}
|
||||
|
||||
private static BufferedImage redrawStepped(BufferedImage original, World w, Align align, Terra main) {
|
||||
private static BufferedImage redrawStepped(BufferedImage original, World w, Align align, TerraBukkitPlugin main) {
|
||||
BufferedImage newImg = copyImage(original);
|
||||
TerraBiomeGrid tb = main.getWorld(w).getGrid();
|
||||
BiomeZone z = main.getWorld(w).getZone();
|
||||
@@ -59,7 +59,7 @@ public class ImageLoader {
|
||||
return b;
|
||||
}
|
||||
|
||||
public void debug(boolean genStep, World w, Terra main) {
|
||||
public void debug(boolean genStep, World w, TerraBukkitPlugin main) {
|
||||
if(!main.isDebug()) return;
|
||||
BufferedImage newImg = copyImage(image);
|
||||
if(genStep) {
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package com.dfsek.terra.image;
|
||||
|
||||
import com.dfsek.terra.Terra;
|
||||
import com.dfsek.terra.TerraWorld;
|
||||
import com.dfsek.terra.api.bukkit.TerraBukkitPlugin;
|
||||
import com.dfsek.terra.api.gaea.biome.NormalizationUtil;
|
||||
import com.dfsek.terra.api.generic.world.World;
|
||||
import com.dfsek.terra.biome.grid.master.TerraBiomeGrid;
|
||||
import org.bukkit.World;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import java.awt.*;
|
||||
@@ -15,9 +15,9 @@ import java.io.IOException;
|
||||
public class WorldImageGenerator {
|
||||
private final World w;
|
||||
private final BufferedImage draw;
|
||||
private final Terra main;
|
||||
private final TerraBukkitPlugin main;
|
||||
|
||||
public WorldImageGenerator(World w, int width, int height, Terra main) {
|
||||
public WorldImageGenerator(World w, int width, int height, TerraBukkitPlugin main) {
|
||||
draw = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
|
||||
this.w = w;
|
||||
this.main = main;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.dfsek.terra.listeners;
|
||||
|
||||
import com.dfsek.terra.Terra;
|
||||
import com.dfsek.terra.TerraWorld;
|
||||
import com.dfsek.terra.api.bukkit.TerraBukkitPlugin;
|
||||
import com.dfsek.terra.api.gaea.tree.Tree;
|
||||
import com.dfsek.terra.api.gaea.tree.TreeType;
|
||||
import com.dfsek.terra.api.gaea.util.FastRandom;
|
||||
@@ -20,9 +20,9 @@ import org.bukkit.event.world.StructureGrowEvent;
|
||||
* Listener for events on all implementations.
|
||||
*/
|
||||
public class EventListener implements Listener {
|
||||
private final Terra main;
|
||||
private final TerraBukkitPlugin main;
|
||||
|
||||
public EventListener(Terra main) {
|
||||
public EventListener(TerraBukkitPlugin main) {
|
||||
this.main = main;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.dfsek.terra.listeners;
|
||||
|
||||
import com.dfsek.terra.Terra;
|
||||
import com.dfsek.terra.TerraWorld;
|
||||
import com.dfsek.terra.api.bukkit.TerraBukkitPlugin;
|
||||
import com.dfsek.terra.async.AsyncStructureFinder;
|
||||
import com.dfsek.terra.debug.Debug;
|
||||
import com.dfsek.terra.generation.items.TerraStructure;
|
||||
@@ -24,9 +24,9 @@ import org.bukkit.event.entity.VillagerCareerChangeEvent;
|
||||
* StructureLocateEvent).
|
||||
*/
|
||||
public class SpigotListener implements Listener {
|
||||
private final Terra main;
|
||||
private final TerraBukkitPlugin main;
|
||||
|
||||
public SpigotListener(Terra main) {
|
||||
public SpigotListener(TerraBukkitPlugin main) {
|
||||
this.main = main;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.dfsek.terra.population;
|
||||
|
||||
import com.dfsek.terra.Terra;
|
||||
import com.dfsek.terra.TerraWorld;
|
||||
import com.dfsek.terra.api.bukkit.TerraBukkitPlugin;
|
||||
import com.dfsek.terra.api.gaea.profiler.ProfileFuture;
|
||||
import com.dfsek.terra.api.generic.world.WorldHandle;
|
||||
import com.dfsek.terra.carving.UserDefinedCarver;
|
||||
@@ -24,11 +24,11 @@ import java.util.Random;
|
||||
import java.util.Set;
|
||||
|
||||
public class CavePopulator extends BlockPopulator {
|
||||
private final Terra main;
|
||||
private final TerraBukkitPlugin main;
|
||||
private static final Map<Material, BlockData> shiftStorage = new HashMap<>(); // Persist BlockData created for shifts, to avoid re-calculating each time.
|
||||
private static final BlockData AIR = Material.AIR.createBlockData();
|
||||
|
||||
public CavePopulator(Terra main) {
|
||||
public CavePopulator(TerraBukkitPlugin main) {
|
||||
this.main = main;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.dfsek.terra.population;
|
||||
|
||||
import com.dfsek.terra.Terra;
|
||||
import com.dfsek.terra.TerraWorld;
|
||||
import com.dfsek.terra.api.bukkit.TerraBukkitPlugin;
|
||||
import com.dfsek.terra.api.gaea.generation.GenerationPhase;
|
||||
import com.dfsek.terra.api.gaea.population.GaeaBlockPopulator;
|
||||
import com.dfsek.terra.api.gaea.profiler.ProfileFuture;
|
||||
@@ -22,9 +22,9 @@ import java.util.Random;
|
||||
* Populates Flora and Trees
|
||||
*/
|
||||
public class FloraPopulator extends GaeaBlockPopulator {
|
||||
private final Terra main;
|
||||
private final TerraBukkitPlugin main;
|
||||
|
||||
public FloraPopulator(Terra main) {
|
||||
public FloraPopulator(TerraBukkitPlugin main) {
|
||||
this.main = main;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.dfsek.terra.population;
|
||||
|
||||
import com.dfsek.terra.Terra;
|
||||
import com.dfsek.terra.TerraWorld;
|
||||
import com.dfsek.terra.api.bukkit.TerraBukkitPlugin;
|
||||
import com.dfsek.terra.api.gaea.biome.Biome;
|
||||
import com.dfsek.terra.api.gaea.generation.GenerationPhase;
|
||||
import com.dfsek.terra.api.gaea.math.MathUtil;
|
||||
@@ -18,9 +18,9 @@ import org.jetbrains.annotations.NotNull;
|
||||
import java.util.Random;
|
||||
|
||||
public class OrePopulator extends GaeaBlockPopulator {
|
||||
private final Terra main;
|
||||
private final TerraBukkitPlugin main;
|
||||
|
||||
public OrePopulator(Terra main) {
|
||||
public OrePopulator(TerraBukkitPlugin main) {
|
||||
this.main = main;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.dfsek.terra.population;
|
||||
|
||||
import com.dfsek.terra.Terra;
|
||||
import com.dfsek.terra.TerraWorld;
|
||||
import com.dfsek.terra.api.bukkit.TerraBukkitPlugin;
|
||||
import com.dfsek.terra.api.gaea.profiler.ProfileFuture;
|
||||
import com.dfsek.terra.api.gaea.structures.loot.LootTable;
|
||||
import com.dfsek.terra.api.gaea.util.FastRandom;
|
||||
@@ -28,9 +28,9 @@ import org.jetbrains.annotations.NotNull;
|
||||
import java.util.Random;
|
||||
|
||||
public class StructurePopulator extends BlockPopulator {
|
||||
private final Terra main;
|
||||
private final TerraBukkitPlugin main;
|
||||
|
||||
public StructurePopulator(Terra main) {
|
||||
public StructurePopulator(TerraBukkitPlugin main) {
|
||||
this.main = main;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.dfsek.terra.population;
|
||||
|
||||
import com.dfsek.terra.Terra;
|
||||
import com.dfsek.terra.TerraWorld;
|
||||
import com.dfsek.terra.api.bukkit.TerraBukkitPlugin;
|
||||
import com.dfsek.terra.api.gaea.generation.GenerationPhase;
|
||||
import com.dfsek.terra.api.gaea.population.GaeaBlockPopulator;
|
||||
import com.dfsek.terra.api.gaea.profiler.ProfileFuture;
|
||||
@@ -18,9 +18,9 @@ import java.util.Random;
|
||||
|
||||
|
||||
public class TreePopulator extends GaeaBlockPopulator {
|
||||
private final Terra main;
|
||||
private final TerraBukkitPlugin main;
|
||||
|
||||
public TreePopulator(Terra main) {
|
||||
public TreePopulator(TerraBukkitPlugin main) {
|
||||
this.main = main;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.dfsek.terra.registry;
|
||||
|
||||
import com.dfsek.tectonic.exception.ConfigException;
|
||||
import com.dfsek.terra.Terra;
|
||||
import com.dfsek.terra.api.bukkit.TerraBukkitPlugin;
|
||||
import com.dfsek.terra.config.base.ConfigPack;
|
||||
import com.dfsek.terra.debug.Debug;
|
||||
|
||||
@@ -13,12 +13,12 @@ import java.util.zip.ZipFile;
|
||||
* Class to hold config packs
|
||||
*/
|
||||
public class ConfigRegistry extends TerraRegistry<ConfigPack> {
|
||||
public void load(File folder, Terra main) throws ConfigException {
|
||||
public void load(File folder, TerraBukkitPlugin main) throws ConfigException {
|
||||
ConfigPack pack = new ConfigPack(folder, main);
|
||||
add(pack.getTemplate().getID(), pack);
|
||||
}
|
||||
|
||||
public boolean loadAll(Terra main) {
|
||||
public boolean loadAll(TerraBukkitPlugin main) {
|
||||
boolean valid = true;
|
||||
File packsFolder = new File(main.getDataFolder(), "packs");
|
||||
for(File dir : packsFolder.listFiles(File::isDirectory)) {
|
||||
@@ -41,7 +41,7 @@ public class ConfigRegistry extends TerraRegistry<ConfigPack> {
|
||||
return valid;
|
||||
}
|
||||
|
||||
public void load(ZipFile file, Terra main) throws ConfigException {
|
||||
public void load(ZipFile file, TerraBukkitPlugin main) throws ConfigException {
|
||||
ConfigPack pack = new ConfigPack(file, main);
|
||||
add(pack.getTemplate().getID(), pack);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.dfsek.terra.structure;
|
||||
|
||||
import com.dfsek.terra.Terra;
|
||||
import com.dfsek.terra.api.bukkit.TerraBukkitPlugin;
|
||||
import com.dfsek.terra.api.gaea.math.Range;
|
||||
import com.dfsek.terra.api.generic.world.WorldHandle;
|
||||
import com.dfsek.terra.api.generic.world.vector.Vector2;
|
||||
@@ -163,7 +163,7 @@ public class Structure implements Serializable {
|
||||
* @param origin Origin location
|
||||
* @param r Rotation
|
||||
*/
|
||||
public void paste(@NotNull Location origin, Rotation r, Terra main) {
|
||||
public void paste(@NotNull Location origin, Rotation r, TerraBukkitPlugin main) {
|
||||
Range xRange = getRange(Rotation.Axis.X, r);
|
||||
Range zRange = getRange(Rotation.Axis.Z, r);
|
||||
this.executeForBlocksInRange(xRange, getRange(Rotation.Axis.Y, r), zRange, block -> pasteBlock(block, origin, r, main.getHandle()), r);
|
||||
@@ -286,7 +286,7 @@ public class Structure implements Serializable {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean checkSpawns(Location origin, Rotation r, Terra main) {
|
||||
public boolean checkSpawns(Location origin, Rotation r, TerraBukkitPlugin main) {
|
||||
for(StructureContainedBlock b : spawns) {
|
||||
Vector2 rot = getRotatedCoords(new Vector2(b.getX() - structureInfo.getCenterX(), b.getZ() - structureInfo.getCenterZ()), r);
|
||||
if(!b.getRequirement().getInstance(origin.getWorld(), main).matches((int) rot.getX() + origin.getBlockX(), origin.getBlockY() + b.getY(), (int) rot.getZ() + origin.getBlockZ()))
|
||||
@@ -310,7 +310,7 @@ public class Structure implements Serializable {
|
||||
* @param chunk Chunk to confine pasting to
|
||||
* @param r Rotation
|
||||
*/
|
||||
public void paste(Location origin, Chunk chunk, Rotation r, Terra main) {
|
||||
public void paste(Location origin, Chunk chunk, Rotation r, TerraBukkitPlugin main) {
|
||||
int xOr = (chunk.getX() << 4);
|
||||
int zOr = (chunk.getZ() << 4);
|
||||
Range intersectX = new Range(xOr, xOr + 16).sub(origin.getBlockX() - structureInfo.getCenterX());
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.dfsek.terra.structure;
|
||||
|
||||
import com.dfsek.terra.Terra;
|
||||
import com.dfsek.terra.api.bukkit.TerraBukkitPlugin;
|
||||
import com.dfsek.terra.structure.spawn.AirSpawn;
|
||||
import com.dfsek.terra.structure.spawn.BlankSpawn;
|
||||
import com.dfsek.terra.structure.spawn.LandSpawn;
|
||||
@@ -13,26 +13,26 @@ import java.io.Serializable;
|
||||
public enum StructureSpawnRequirement implements Serializable {
|
||||
AIR {
|
||||
@Override
|
||||
public Requirement getInstance(World world, Terra main) {
|
||||
public Requirement getInstance(World world, TerraBukkitPlugin main) {
|
||||
return new AirSpawn(world, main);
|
||||
}
|
||||
}, OCEAN {
|
||||
@Override
|
||||
public Requirement getInstance(World world, Terra main) {
|
||||
public Requirement getInstance(World world, TerraBukkitPlugin main) {
|
||||
return new OceanSpawn(world, main);
|
||||
}
|
||||
}, LAND {
|
||||
@Override
|
||||
public Requirement getInstance(World world, Terra main) {
|
||||
public Requirement getInstance(World world, TerraBukkitPlugin main) {
|
||||
return new LandSpawn(world, main);
|
||||
}
|
||||
}, BLANK {
|
||||
@Override
|
||||
public Requirement getInstance(World world, Terra main) {
|
||||
public Requirement getInstance(World world, TerraBukkitPlugin main) {
|
||||
return new BlankSpawn();
|
||||
}
|
||||
};
|
||||
private static final long serialVersionUID = -175639605885943679L;
|
||||
|
||||
public abstract Requirement getInstance(World world, Terra main);
|
||||
public abstract Requirement getInstance(World world, TerraBukkitPlugin main);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.dfsek.terra.structure.spawn;
|
||||
|
||||
import com.dfsek.terra.Terra;
|
||||
import com.dfsek.terra.TerraWorld;
|
||||
import com.dfsek.terra.api.bukkit.TerraBukkitPlugin;
|
||||
import com.dfsek.terra.api.gaea.generation.GenerationPhase;
|
||||
import com.dfsek.terra.biome.UserDefinedBiome;
|
||||
import com.dfsek.terra.config.templates.BiomeTemplate;
|
||||
@@ -9,7 +9,7 @@ import com.dfsek.terra.generation.config.WorldGenerator;
|
||||
import org.bukkit.World;
|
||||
|
||||
public class AirSpawn extends Requirement {
|
||||
public AirSpawn(World world, Terra main) {
|
||||
public AirSpawn(World world, TerraBukkitPlugin main) {
|
||||
super(world, main);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
package com.dfsek.terra.structure.spawn;
|
||||
|
||||
import com.dfsek.terra.Terra;
|
||||
import com.dfsek.terra.TerraWorld;
|
||||
import com.dfsek.terra.api.bukkit.TerraBukkitPlugin;
|
||||
import com.dfsek.terra.api.gaea.generation.GenerationPhase;
|
||||
import com.dfsek.terra.biome.UserDefinedBiome;
|
||||
import com.dfsek.terra.generation.config.WorldGenerator;
|
||||
import org.bukkit.World;
|
||||
|
||||
public class LandSpawn extends Requirement {
|
||||
public LandSpawn(World world, Terra main) {
|
||||
public LandSpawn(World world, TerraBukkitPlugin main) {
|
||||
super(world, main);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.dfsek.terra.structure.spawn;
|
||||
|
||||
import com.dfsek.terra.Terra;
|
||||
import com.dfsek.terra.TerraWorld;
|
||||
import com.dfsek.terra.api.bukkit.TerraBukkitPlugin;
|
||||
import com.dfsek.terra.api.gaea.generation.GenerationPhase;
|
||||
import com.dfsek.terra.biome.UserDefinedBiome;
|
||||
import com.dfsek.terra.config.templates.BiomeTemplate;
|
||||
@@ -9,7 +9,7 @@ import com.dfsek.terra.generation.config.WorldGenerator;
|
||||
import org.bukkit.World;
|
||||
|
||||
public class OceanSpawn extends Requirement {
|
||||
public OceanSpawn(World world, Terra main) {
|
||||
public OceanSpawn(World world, TerraBukkitPlugin main) {
|
||||
super(world, main);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.dfsek.terra.structure.spawn;
|
||||
|
||||
import com.dfsek.terra.Terra;
|
||||
import com.dfsek.terra.api.bukkit.TerraBukkitPlugin;
|
||||
import com.dfsek.terra.api.gaea.math.FastNoiseLite;
|
||||
import org.bukkit.World;
|
||||
|
||||
@@ -8,9 +8,9 @@ import java.util.Objects;
|
||||
|
||||
public abstract class Requirement {
|
||||
protected final World world;
|
||||
protected final Terra main;
|
||||
protected final TerraBukkitPlugin main;
|
||||
|
||||
public Requirement(World world, Terra main) {
|
||||
public Requirement(World world, TerraBukkitPlugin main) {
|
||||
this.world = world;
|
||||
this.main = main;
|
||||
}
|
||||
|
||||
@@ -1,20 +1,13 @@
|
||||
package com.dfsek.terra.util;
|
||||
|
||||
import com.dfsek.terra.api.gaea.util.FastRandom;
|
||||
import com.dfsek.terra.api.gaea.world.palette.Palette;
|
||||
import com.dfsek.terra.api.gaea.world.palette.RandomPalette;
|
||||
import com.dfsek.terra.api.generic.world.block.BlockData;
|
||||
import com.dfsek.terra.biome.palette.PaletteHolder;
|
||||
import com.dfsek.terra.config.templates.BiomeTemplate;
|
||||
import com.dfsek.terra.generation.Sampler;
|
||||
import com.dfsek.terra.math.MathUtil;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
|
||||
public final class PaletteUtil {
|
||||
public static final BlockData WATER = Material.WATER.createBlockData();
|
||||
public static final BlockData AIR = Material.AIR.createBlockData();
|
||||
public static final Palette<BlockData> BLANK_PALETTE = new RandomPalette<BlockData>(new FastRandom(2403)).add(AIR, 1);
|
||||
|
||||
public static Palette<BlockData> getPalette(int x, int y, int z, BiomeTemplate c, Sampler sampler) {
|
||||
PaletteHolder slant = c.getSlantPalette();
|
||||
if(slant != null && MathUtil.derivative(sampler, x, y, z) > c.getSlantThreshold()) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
name: "Terra"
|
||||
main: "com.dfsek.terra.Terra"
|
||||
main: "com.dfsek.terra.api.bukkit.Terra"
|
||||
version: "@VERSION@"
|
||||
load: "STARTUP"
|
||||
api-version: "1.16"
|
||||
|
||||
Reference in New Issue
Block a user