diff --git a/common/addons/config-biome/README.md b/common/addons/config-biome/README.md deleted file mode 100644 index 4070828ac..000000000 --- a/common/addons/config-biome/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# config-biome - -Registers the default configuration for Terra Biomes, `BIOME`. \ No newline at end of file diff --git a/common/addons/config-biome/build.gradle.kts b/common/addons/config-biome/build.gradle.kts deleted file mode 100644 index 7d82dc72f..000000000 --- a/common/addons/config-biome/build.gradle.kts +++ /dev/null @@ -1,2 +0,0 @@ -dependencies { -} diff --git a/common/addons/config-biome/src/main/java/com/dfsek/terra/addons/biome/BiomeAddon.java b/common/addons/config-biome/src/main/java/com/dfsek/terra/addons/biome/BiomeAddon.java deleted file mode 100644 index ff9ac1f2a..000000000 --- a/common/addons/config-biome/src/main/java/com/dfsek/terra/addons/biome/BiomeAddon.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.dfsek.terra.addons.biome; - -import com.dfsek.terra.addons.biome.holder.PaletteHolder; -import com.dfsek.terra.addons.biome.holder.PaletteHolderLoader; -import com.dfsek.terra.api.Platform; -import com.dfsek.terra.api.addon.TerraAddon; -import com.dfsek.terra.api.addon.annotations.Addon; -import com.dfsek.terra.api.addon.annotations.Author; -import com.dfsek.terra.api.addon.annotations.Version; -import com.dfsek.terra.api.event.events.config.pack.ConfigPackPreLoadEvent; -import com.dfsek.terra.api.event.functional.FunctionalEventHandler; -import com.dfsek.terra.api.inject.annotations.Inject; - - -@Addon("config-biome") -@Author("Terra") -@Version("1.0.0") -public class BiomeAddon extends TerraAddon { - @Inject - private Platform platform; - - @Override - public void initialize() { - platform.getEventManager() - .getHandler(FunctionalEventHandler.class) - .register(this, ConfigPackPreLoadEvent.class) - .then(event -> { - event.getPack().registerConfigType(new BiomeConfigType(event.getPack()), "BIOME", 5); - event.getPack().applyLoader(PaletteHolder.class, new PaletteHolderLoader()); - }) - .failThrough(); - } -} diff --git a/common/addons/config-biome/src/main/java/com/dfsek/terra/addons/biome/BiomeConfigType.java b/common/addons/config-biome/src/main/java/com/dfsek/terra/addons/biome/BiomeConfigType.java deleted file mode 100644 index 8dd3b65d2..000000000 --- a/common/addons/config-biome/src/main/java/com/dfsek/terra/addons/biome/BiomeConfigType.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.dfsek.terra.addons.biome; - -import com.dfsek.tectonic.exception.LoadException; -import com.dfsek.tectonic.loading.TypeLoader; - -import java.util.function.Supplier; - -import com.dfsek.terra.api.Platform; -import com.dfsek.terra.api.config.ConfigFactory; -import com.dfsek.terra.api.config.ConfigPack; -import com.dfsek.terra.api.config.ConfigType; -import com.dfsek.terra.api.registry.OpenRegistry; -import com.dfsek.terra.api.util.reflection.TypeKey; -import com.dfsek.terra.api.world.biome.TerraBiome; - - -public class BiomeConfigType implements ConfigType { - public static final TypeKey BIOME_TYPE_TOKEN = new TypeKey<>() { - }; - private final BiomeFactory factory; - - public BiomeConfigType(ConfigPack pack) { - this.factory = new BiomeFactory(pack); - } - - @Override - public Supplier> registrySupplier(ConfigPack pack) { - return () -> pack.getRegistryFactory().create(registry -> (TypeLoader) (t, c, loader) -> { - if(c.equals("SELF")) return null; - TerraBiome obj = registry.get((String) c); - if(obj == null) - throw new LoadException("No such " + t.getType().getTypeName() + " matching \"" + c + "\" was found in this registry."); - return obj; - }); - } - - @Override - public BiomeTemplate getTemplate(ConfigPack pack, Platform platform) { - return new BiomeTemplate(pack, platform); - } - - @Override - public ConfigFactory getFactory() { - return factory; - } - - @Override - public TypeKey getTypeKey() { - return BIOME_TYPE_TOKEN; - } -} diff --git a/common/addons/config-biome/src/main/java/com/dfsek/terra/addons/biome/BiomeFactory.java b/common/addons/config-biome/src/main/java/com/dfsek/terra/addons/biome/BiomeFactory.java deleted file mode 100644 index 8fb31ebb1..000000000 --- a/common/addons/config-biome/src/main/java/com/dfsek/terra/addons/biome/BiomeFactory.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.dfsek.terra.addons.biome; - -import com.dfsek.terra.api.Platform; -import com.dfsek.terra.api.config.ConfigFactory; -import com.dfsek.terra.api.config.ConfigPack; -import com.dfsek.terra.api.world.biome.TerraBiome; - - -public class BiomeFactory implements ConfigFactory { - private final ConfigPack pack; - - public BiomeFactory(ConfigPack pack) { - this.pack = pack; - } - - @Override - public TerraBiome build(BiomeTemplate template, Platform platform) { - UserDefinedGenerationSettings generator = new UserDefinedGenerationSettings(template.getNoiseEquation(), - template.getElevationEquation(), - template.getCarvingEquation(), template.getBiomeNoise(), - template.getElevationWeight(), - template.getBlendDistance(), template.getBlendStep(), - template.getBlendWeight()); - return new UserDefinedBiome(template.getVanilla(), generator, template); - } -} diff --git a/common/addons/config-biome/src/main/java/com/dfsek/terra/addons/biome/BiomeTemplate.java b/common/addons/config-biome/src/main/java/com/dfsek/terra/addons/biome/BiomeTemplate.java deleted file mode 100644 index 013b3cfc1..000000000 --- a/common/addons/config-biome/src/main/java/com/dfsek/terra/addons/biome/BiomeTemplate.java +++ /dev/null @@ -1,213 +0,0 @@ -package com.dfsek.terra.addons.biome; - -import com.dfsek.tectonic.annotations.Default; -import com.dfsek.tectonic.annotations.Final; -import com.dfsek.tectonic.annotations.Value; -import com.dfsek.tectonic.config.ValidatedConfigTemplate; -import com.dfsek.tectonic.exception.ValidationException; - -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import com.dfsek.terra.api.Platform; -import com.dfsek.terra.api.block.BlockType; -import com.dfsek.terra.api.config.AbstractableTemplate; -import com.dfsek.terra.api.config.ConfigPack; -import com.dfsek.terra.api.config.meta.Meta; -import com.dfsek.terra.api.noise.NoiseSampler; -import com.dfsek.terra.api.util.collection.ProbabilityCollection; -import com.dfsek.terra.api.world.biome.Biome; -import com.dfsek.terra.api.world.generator.Palette; - - -@SuppressWarnings({ "FieldMayBeFinal", "unused" }) -public class BiomeTemplate implements AbstractableTemplate, ValidatedConfigTemplate { - private final ConfigPack pack; - - @Value("id") - @Final - private @Meta String id; - - @Value("extends") - @Final - @Default - private List extended = Collections.emptyList(); - - @Value("variables") - @Default - private @Meta Map variables = new HashMap<>(); - - @Value("beta.carving.equation") - @Default - private @Meta NoiseSampler carvingEquation = NoiseSampler.zero(); - - @Value("vanilla") - private @Meta ProbabilityCollection vanilla; - - @Value("biome-noise") - @Default - private @Meta NoiseSampler biomeNoise = NoiseSampler.zero(); - - @Value("blend.distance") - @Default - private @Meta int blendDistance = 3; - - @Value("blend.weight") - @Default - private @Meta double blendWeight = 1; - - @Value("blend.step") - @Default - private @Meta int blendStep = 4; - - @Value("noise") - private @Meta NoiseSampler noiseEquation; - - @Value("ocean.level") - @Default - private @Meta int seaLevel = 62; - - @Value("elevation.equation") - @Default - private @Meta NoiseSampler elevationEquation = NoiseSampler.zero(); - - @Value("elevation.weight") - @Default - private @Meta double elevationWeight = 1; - - @Value("slabs.enable") - @Default - private @Meta boolean doSlabs = false; - - @Value("slabs.threshold") - @Default - private @Meta double slabThreshold = 0.0075D; - - @Value("slabs.palettes") - @Default - private @Meta Map<@Meta BlockType, @Meta Palette> slabPalettes; - - @Value("slabs.stair-palettes") - @Default - private @Meta Map<@Meta BlockType, @Meta Palette> stairPalettes; - - @Value("interpolate-elevation") - @Default - private @Meta boolean interpolateElevation = true; - - @Value("color") - @Final - @Default - private @Meta int color = 0; - - @Value("tags") - @Default - private @Meta Set<@Meta String> tags = new HashSet<>(); - - @Value("colors") - @Default - private @Meta Map colors = new HashMap<>(); - // Plain ol' map, so platforms can decide what to do with colors (if anything). - - public BiomeTemplate(ConfigPack pack, Platform platform) { - this.pack = pack; - } - - public boolean interpolateElevation() { - return interpolateElevation; - } - - public boolean doSlabs() { - return doSlabs; - } - - @Override - public boolean validate() throws ValidationException { - color |= 0xff000000; // Alpha adjustment - return true; - } - - public List getExtended() { - return extended; - } - - public Set getTags() { - return tags; - } - - public Map getColors() { - return colors; - } - - public double getBlendWeight() { - return blendWeight; - } - - public int getColor() { - return color; - } - - public int getBlendDistance() { - return blendDistance; - } - - public double getSlabThreshold() { - return slabThreshold; - } - - public Map getSlabPalettes() { - return slabPalettes; - } - - public Map getStairPalettes() { - return stairPalettes; - } - - public NoiseSampler getBiomeNoise() { - return biomeNoise; - } - - public NoiseSampler getElevationEquation() { - return elevationEquation; - } - - public NoiseSampler getCarvingEquation() { - return carvingEquation; - } - - public ConfigPack getPack() { - return pack; - } - - public int getSeaLevel() { - return seaLevel; - } - - public String getID() { - return id; - } - - public ProbabilityCollection getVanilla() { - return vanilla; - } - - public NoiseSampler getNoiseEquation() { - return noiseEquation; - } - - public double getElevationWeight() { - return elevationWeight; - } - - public int getBlendStep() { - return blendStep; - } - - public Map getVariables() { - return variables; - } -} diff --git a/common/addons/config-biome/src/main/java/com/dfsek/terra/addons/biome/PaletteSettingsImpl.java b/common/addons/config-biome/src/main/java/com/dfsek/terra/addons/biome/PaletteSettingsImpl.java deleted file mode 100644 index 5440ed440..000000000 --- a/common/addons/config-biome/src/main/java/com/dfsek/terra/addons/biome/PaletteSettingsImpl.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.dfsek.terra.addons.biome; - -import com.dfsek.terra.addons.biome.holder.PaletteHolder; -import com.dfsek.terra.api.world.biome.PaletteSettings; -import com.dfsek.terra.api.world.generator.Palette; - - -public class PaletteSettingsImpl implements PaletteSettings { - private final PaletteHolder palette; - - public PaletteSettingsImpl(PaletteHolder palette) { - this.palette = palette; - } - - @Override - public Palette getPalette(int y) { - return palette.getPalette(y); - } -} diff --git a/common/addons/config-biome/src/main/java/com/dfsek/terra/addons/biome/UserDefinedBiome.java b/common/addons/config-biome/src/main/java/com/dfsek/terra/addons/biome/UserDefinedBiome.java deleted file mode 100644 index d10b7c70f..000000000 --- a/common/addons/config-biome/src/main/java/com/dfsek/terra/addons/biome/UserDefinedBiome.java +++ /dev/null @@ -1,78 +0,0 @@ -package com.dfsek.terra.addons.biome; - -import java.util.Set; - -import com.dfsek.terra.api.properties.Context; -import com.dfsek.terra.api.util.collection.ProbabilityCollection; -import com.dfsek.terra.api.world.biome.Biome; -import com.dfsek.terra.api.world.biome.GenerationSettings; -import com.dfsek.terra.api.world.biome.TerraBiome; - - -/** - * Class representing a config-defined biome - */ -public class UserDefinedBiome implements TerraBiome { - private final UserDefinedGenerationSettings gen; - private final ProbabilityCollection vanilla; - private final String id; - private final BiomeTemplate config; - private final int color; - private final Set tags; - - private final Context context = new Context(); - - public UserDefinedBiome(ProbabilityCollection vanilla, UserDefinedGenerationSettings gen, BiomeTemplate config) { - this.vanilla = vanilla; - this.gen = gen; - this.id = config.getID(); - this.config = config; - this.color = config.getColor(); - this.tags = config.getTags(); - tags.add("BIOME:" + id); - } - - @Override - public String toString() { - return "{BIOME:" + getID() + "}"; - } - - /** - * Gets the Vanilla biomes to represent the custom biome. - * - * @return Collection of biomes to represent the custom biome. - */ - @Override - public ProbabilityCollection getVanillaBiomes() { - return vanilla; - } - - @Override - public GenerationSettings getGenerator() { - return gen; - } - - @Override - public int getColor() { - return color; - } - - @Override - public Set getTags() { - return tags; - } - - @Override - public String getID() { - return id; - } - - public BiomeTemplate getConfig() { - return config; - } - - @Override - public Context getContext() { - return context; - } -} diff --git a/common/addons/config-biome/src/main/java/com/dfsek/terra/addons/biome/UserDefinedGenerationSettings.java b/common/addons/config-biome/src/main/java/com/dfsek/terra/addons/biome/UserDefinedGenerationSettings.java deleted file mode 100644 index dbc5607b0..000000000 --- a/common/addons/config-biome/src/main/java/com/dfsek/terra/addons/biome/UserDefinedGenerationSettings.java +++ /dev/null @@ -1,71 +0,0 @@ -package com.dfsek.terra.addons.biome; - -import com.dfsek.terra.api.noise.NoiseSampler; -import com.dfsek.terra.api.world.biome.GenerationSettings; - - -public class UserDefinedGenerationSettings implements GenerationSettings { - - private final NoiseSampler noise; - private final NoiseSampler elevation; - private final NoiseSampler carving; - - private final NoiseSampler biomeNoise; - private final double elevationWeight; - private final int blendDistance; - private final int blendStep; - private final double blendWeight; - - public UserDefinedGenerationSettings(NoiseSampler noise, NoiseSampler elevation, NoiseSampler carving, NoiseSampler biomeNoise, - double elevationWeight, int blendDistance, int blendStep, double blendWeight) { - this.noise = noise; - this.elevation = elevation; - this.carving = carving; - - this.biomeNoise = biomeNoise; - this.elevationWeight = elevationWeight; - this.blendDistance = blendDistance; - this.blendStep = blendStep; - this.blendWeight = blendWeight; - } - - @Override - public NoiseSampler getBaseSampler() { - return noise; - } - - @Override - public NoiseSampler getElevationSampler() { - return elevation; - } - - @Override - public NoiseSampler getCarver() { - return carving; - } - - @Override - public int getBlendDistance() { - return blendDistance; - } - - @Override - public double getWeight() { - return blendWeight; - } - - @Override - public NoiseSampler getBiomeNoise() { - return biomeNoise; - } - - @Override - public double getElevationWeight() { - return elevationWeight; - } - - @Override - public int getBlendStep() { - return blendStep; - } -} diff --git a/common/addons/config-biome/src/main/java/com/dfsek/terra/addons/biome/command/biome/AsyncBiomeFinder.java b/common/addons/config-biome/src/main/java/com/dfsek/terra/addons/biome/command/biome/AsyncBiomeFinder.java deleted file mode 100644 index c6f7ed919..000000000 --- a/common/addons/config-biome/src/main/java/com/dfsek/terra/addons/biome/command/biome/AsyncBiomeFinder.java +++ /dev/null @@ -1,117 +0,0 @@ -package com.dfsek.terra.addons.biome.command.biome; - -import com.dfsek.terra.api.Platform; - -import org.jetbrains.annotations.NotNull; - -import java.util.function.Consumer; - -import com.dfsek.terra.api.util.vector.Vector3; -import com.dfsek.terra.api.world.World; -import com.dfsek.terra.api.world.biome.TerraBiome; -import com.dfsek.terra.api.world.biome.generation.BiomeProvider; - - -/** - * Runnable that locates a biome asynchronously - */ -public class AsyncBiomeFinder implements Runnable { - - protected final BiomeProvider provider; - protected final TerraBiome target; - protected final int startRadius; - protected final int maxRadius; - protected final int centerX; - protected final int centerZ; - protected final World world; - protected final Platform platform; - private final Consumer callback; - protected int searchSize = 1; - - public AsyncBiomeFinder(BiomeProvider provider, TerraBiome target, @NotNull Vector3 origin, World world, int startRadius, int maxRadius, - Consumer callback, Platform platform) { - this.provider = provider; - this.target = target; - this.platform = platform; - this.startRadius = startRadius; - this.maxRadius = maxRadius; - this.centerX = origin.getBlockX(); - this.centerZ = origin.getBlockZ(); - this.world = world; - this.callback = callback; - } - - public Vector3 finalizeVector(Vector3 orig) { - return orig.multiply(platform.getTerraConfig().getBiomeSearchResolution()); - } - - @Override - public void run() { - int x = centerX; - int z = centerZ; - - x /= searchSize; - z /= searchSize; - - int run = 1; - boolean toggle = true; - boolean found = false; - - main: - for(int i = startRadius; i < maxRadius; i++) { - for(int j = 0; j < run; j++) { - if(isValid(x, z, target)) { - found = true; - break main; - } - if(toggle) x += 1; - else x -= 1; - } - for(int j = 0; j < run; j++) { - if(isValid(x, z, target)) { - found = true; - break main; - } - if(toggle) z += 1; - else z -= 1; - } - run++; - toggle = !toggle; - } - Vector3 finalSpawn = found ? finalizeVector(new Vector3(x, 0, z)) : null; - callback.accept(finalSpawn); - } - - /** - * Helper method to get biome at location - * - * @param x X coordinate - * @param z Z coordinate - * - * @return TerraBiome at coordinates - */ - public boolean isValid(int x, int z, TerraBiome target) { - int res = platform.getTerraConfig().getBiomeSearchResolution(); - return getProvider().getBiome(x * res, z * res, world.getSeed()).equals(target); - } - - public TerraBiome getTarget() { - return target; - } - - public World getWorld() { - return world; - } - - public BiomeProvider getProvider() { - return provider; - } - - public int getSearchSize() { - return searchSize; - } - - public void setSearchSize(int searchSize) { - this.searchSize = searchSize; - } -} diff --git a/common/addons/config-biome/src/main/java/com/dfsek/terra/addons/biome/command/biome/BiomeCommand.java b/common/addons/config-biome/src/main/java/com/dfsek/terra/addons/biome/command/biome/BiomeCommand.java deleted file mode 100644 index 35497035e..000000000 --- a/common/addons/config-biome/src/main/java/com/dfsek/terra/addons/biome/command/biome/BiomeCommand.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.dfsek.terra.addons.biome.command.biome; - -import com.dfsek.terra.addons.biome.UserDefinedBiome; -import com.dfsek.terra.api.Platform; -import com.dfsek.terra.api.command.CommandTemplate; -import com.dfsek.terra.api.command.annotation.Command; -import com.dfsek.terra.api.command.annotation.Subcommand; -import com.dfsek.terra.api.command.annotation.type.PlayerCommand; -import com.dfsek.terra.api.command.annotation.type.WorldCommand; -import com.dfsek.terra.api.entity.CommandSender; -import com.dfsek.terra.api.entity.Player; -import com.dfsek.terra.api.inject.annotations.Inject; -import com.dfsek.terra.api.world.biome.generation.BiomeProvider; - - -@Command( - subcommands = { - @Subcommand(value = "info", aliases = "i", clazz = BiomeInfoCommand.class), - @Subcommand(value = "locate", aliases = "l", clazz = BiomeLocateCommand.class) - }, - usage = "/terra biome" -) -@WorldCommand -@PlayerCommand -public class BiomeCommand implements CommandTemplate { - @Inject - private Platform platform; - - @Override - public void execute(CommandSender sender) { - Player player = (Player) sender; - - BiomeProvider provider = player.world().getBiomeProvider(); - UserDefinedBiome biome = (UserDefinedBiome) provider.getBiome(player.position(), player.world().getSeed()); - sender.sendMessage("You are standing in " + biome.getID()); - } -} diff --git a/common/addons/config-biome/src/main/java/com/dfsek/terra/addons/biome/command/biome/BiomeInfoCommand.java b/common/addons/config-biome/src/main/java/com/dfsek/terra/addons/biome/command/biome/BiomeInfoCommand.java deleted file mode 100644 index 029c72aae..000000000 --- a/common/addons/config-biome/src/main/java/com/dfsek/terra/addons/biome/command/biome/BiomeInfoCommand.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.dfsek.terra.addons.biome.command.biome; - -import com.dfsek.terra.addons.biome.BiomeTemplate; -import com.dfsek.terra.addons.biome.UserDefinedBiome; -import com.dfsek.terra.addons.biome.command.biome.arg.BiomeArgumentParser; -import com.dfsek.terra.addons.biome.command.biome.tab.BiomeTabCompleter; -import com.dfsek.terra.api.command.CommandTemplate; -import com.dfsek.terra.api.command.annotation.Argument; -import com.dfsek.terra.api.command.annotation.Command; -import com.dfsek.terra.api.command.annotation.inject.ArgumentTarget; -import com.dfsek.terra.api.entity.CommandSender; -import com.dfsek.terra.api.world.biome.TerraBiome; - - -@Command(arguments = @Argument( - value = "biome", - tabCompleter = BiomeTabCompleter.class, - argumentParser = BiomeArgumentParser.class -)) -public class BiomeInfoCommand implements CommandTemplate { - @ArgumentTarget("biome") - private TerraBiome biome; - - @Override - public void execute(CommandSender sender) { - sender.sendMessage("Biome info for \"" + biome.getID() + "\"."); - sender.sendMessage("Vanilla biome: " + biome.getVanillaBiomes()); - - if(biome instanceof UserDefinedBiome) { - BiomeTemplate bio = ((UserDefinedBiome) biome).getConfig(); - - if(bio.getExtended().size() == 0) { - sender.sendMessage("No Parent Biomes"); - } else { - sender.sendMessage("------Parent Biomes-----"); - bio.getExtended().forEach(id -> sender.sendMessage(" - " + id)); - } - } - } -} diff --git a/common/addons/config-biome/src/main/java/com/dfsek/terra/addons/biome/command/biome/BiomeLocateCommand.java b/common/addons/config-biome/src/main/java/com/dfsek/terra/addons/biome/command/biome/BiomeLocateCommand.java deleted file mode 100644 index 4bdcdad0a..000000000 --- a/common/addons/config-biome/src/main/java/com/dfsek/terra/addons/biome/command/biome/BiomeLocateCommand.java +++ /dev/null @@ -1,77 +0,0 @@ -package com.dfsek.terra.addons.biome.command.biome; - -import java.util.Locale; - -import com.dfsek.terra.addons.biome.command.biome.arg.BiomeArgumentParser; -import com.dfsek.terra.addons.biome.command.biome.tab.BiomeTabCompleter; -import com.dfsek.terra.api.Platform; -import com.dfsek.terra.api.command.CommandTemplate; -import com.dfsek.terra.api.command.annotation.Argument; -import com.dfsek.terra.api.command.annotation.Command; -import com.dfsek.terra.api.command.annotation.Switch; -import com.dfsek.terra.api.command.annotation.inject.ArgumentTarget; -import com.dfsek.terra.api.command.annotation.inject.SwitchTarget; -import com.dfsek.terra.api.command.annotation.type.PlayerCommand; -import com.dfsek.terra.api.command.annotation.type.WorldCommand; -import com.dfsek.terra.api.command.arg.IntegerArgumentParser; -import com.dfsek.terra.api.entity.CommandSender; -import com.dfsek.terra.api.entity.Player; -import com.dfsek.terra.api.inject.annotations.Inject; -import com.dfsek.terra.api.util.vector.Vector3; -import com.dfsek.terra.api.world.biome.TerraBiome; - - -@PlayerCommand -@WorldCommand -@Command(arguments = { - @Argument( - value = "biome", - tabCompleter = BiomeTabCompleter.class, - argumentParser = BiomeArgumentParser.class - ), - @Argument( - value = "radius", - required = false, - defaultValue = "1000", - argumentParser = IntegerArgumentParser.class - ) -}, switches = @Switch( - value = "teleport", - aliases = { "t", "tp" } -)) -public class BiomeLocateCommand implements CommandTemplate { - - @ArgumentTarget("radius") - private Integer radius; - - @ArgumentTarget("biome") - private TerraBiome biome; - - @SwitchTarget("teleport") - private boolean teleport; - - @Inject - private Platform platform; - - @Override - public void execute(CommandSender sender) { - - Player player = (Player) sender; - - new Thread(new AsyncBiomeFinder(player.world().getBiomeProvider(), biome, - player.position().clone().multiply((1D / platform.getTerraConfig().getBiomeSearchResolution())), - player.world(), 0, radius, location -> { - if(location != null) { - sender.sendMessage( - String.format("The nearest %s is at [%d, ~, %d] (%.1f blocks away)", biome.getID().toLowerCase(Locale.ROOT), - location.getBlockX(), location.getBlockZ(), - location.add(new Vector3(0, player.position().getY(), 0)).distance(player.position()))); - if(teleport) { - platform.runPossiblyUnsafeTask( - () -> player.position(new Vector3(location.getX(), player.position().getY(), location.getZ()))); - } - } else sender.sendMessage("Unable to locate biome \"" + biome.getID() + "\""); - }, platform), "Biome Location Thread").start(); - - } -} diff --git a/common/addons/config-biome/src/main/java/com/dfsek/terra/addons/biome/command/biome/arg/BiomeArgumentParser.java b/common/addons/config-biome/src/main/java/com/dfsek/terra/addons/biome/command/biome/arg/BiomeArgumentParser.java deleted file mode 100644 index 9cd0cdbc9..000000000 --- a/common/addons/config-biome/src/main/java/com/dfsek/terra/addons/biome/command/biome/arg/BiomeArgumentParser.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.dfsek.terra.addons.biome.command.biome.arg; - -import com.dfsek.terra.api.Platform; -import com.dfsek.terra.api.command.arg.ArgumentParser; -import com.dfsek.terra.api.entity.CommandSender; -import com.dfsek.terra.api.entity.Player; -import com.dfsek.terra.api.inject.annotations.Inject; -import com.dfsek.terra.api.world.biome.TerraBiome; - - -public class BiomeArgumentParser implements ArgumentParser { - @Inject - private Platform platform; - - @Override - public TerraBiome parse(CommandSender sender, String arg) { - Player player = (Player) sender; - return player.world().getConfig().getRegistry(TerraBiome.class).get(arg); - } -} diff --git a/common/addons/config-biome/src/main/java/com/dfsek/terra/addons/biome/command/biome/tab/BiomeTabCompleter.java b/common/addons/config-biome/src/main/java/com/dfsek/terra/addons/biome/command/biome/tab/BiomeTabCompleter.java deleted file mode 100644 index 6dc1baac9..000000000 --- a/common/addons/config-biome/src/main/java/com/dfsek/terra/addons/biome/command/biome/tab/BiomeTabCompleter.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.dfsek.terra.addons.biome.command.biome.tab; - -import java.util.List; -import java.util.stream.Collectors; - -import com.dfsek.terra.api.Platform; -import com.dfsek.terra.api.command.tab.TabCompleter; -import com.dfsek.terra.api.entity.CommandSender; -import com.dfsek.terra.api.entity.Player; -import com.dfsek.terra.api.inject.annotations.Inject; -import com.dfsek.terra.api.world.biome.TerraBiome; - - -public class BiomeTabCompleter implements TabCompleter { - @Inject - private Platform platform; - - @Override - public List complete(CommandSender sender) { - Player player = (Player) sender; - return player.world().getConfig().getRegistry(TerraBiome.class).entries().stream().map(TerraBiome::getID).collect( - Collectors.toList()); - } -} diff --git a/common/addons/config-biome/src/main/java/com/dfsek/terra/addons/biome/holder/PaletteHolder.java b/common/addons/config-biome/src/main/java/com/dfsek/terra/addons/biome/holder/PaletteHolder.java deleted file mode 100644 index ca16479df..000000000 --- a/common/addons/config-biome/src/main/java/com/dfsek/terra/addons/biome/holder/PaletteHolder.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.dfsek.terra.addons.biome.holder; - -import com.dfsek.terra.api.world.generator.Palette; - - -public class PaletteHolder { - private final Palette[] palettes; - private final int offset; - - protected PaletteHolder(Palette[] palettes, int offset) { - this.palettes = palettes; - this.offset = offset; - } - - public Palette getPalette(int y) { - int index = y + offset; - return index >= 0 - ? index < palettes.length - ? palettes[index] - : palettes[palettes.length - 1] - : palettes[0]; - } -} diff --git a/common/addons/config-biome/src/main/java/com/dfsek/terra/addons/biome/holder/PaletteHolderBuilder.java b/common/addons/config-biome/src/main/java/com/dfsek/terra/addons/biome/holder/PaletteHolderBuilder.java deleted file mode 100644 index 7ed5a7825..000000000 --- a/common/addons/config-biome/src/main/java/com/dfsek/terra/addons/biome/holder/PaletteHolderBuilder.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.dfsek.terra.addons.biome.holder; - -import net.jafama.FastMath; - -import java.util.Map; -import java.util.TreeMap; - -import com.dfsek.terra.api.world.generator.Palette; - - -public class PaletteHolderBuilder { - private final TreeMap paletteMap = new TreeMap<>(); - - public PaletteHolderBuilder add(int y, Palette palette) { - paletteMap.put(y, palette); - return this; - } - - public PaletteHolder build() { - - int min = FastMath.min(paletteMap.keySet().stream().min(Integer::compareTo).orElse(0), 0); - int max = FastMath.max(paletteMap.keySet().stream().max(Integer::compareTo).orElse(255), 255); - - Palette[] palettes = new Palette[paletteMap.lastKey() + 1 - min]; - for(int y = min; y <= FastMath.max(paletteMap.lastKey(), max); y++) { - Palette d = null; - for(Map.Entry e : paletteMap.entrySet()) { - if(e.getKey() >= y) { - d = e.getValue(); - break; - } - } - if(d == null) throw new IllegalArgumentException("No palette for Y=" + y); - palettes[y - min] = d; - } - return new PaletteHolder(palettes, -min); - } -} diff --git a/common/addons/config-biome/src/main/java/com/dfsek/terra/addons/biome/holder/PaletteHolderLoader.java b/common/addons/config-biome/src/main/java/com/dfsek/terra/addons/biome/holder/PaletteHolderLoader.java deleted file mode 100644 index 3effd7037..000000000 --- a/common/addons/config-biome/src/main/java/com/dfsek/terra/addons/biome/holder/PaletteHolderLoader.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.dfsek.terra.addons.biome.holder; - -import com.dfsek.tectonic.exception.LoadException; -import com.dfsek.tectonic.loading.ConfigLoader; -import com.dfsek.tectonic.loading.TypeLoader; - -import java.lang.reflect.AnnotatedType; -import java.util.List; -import java.util.Map; - -import com.dfsek.terra.api.world.generator.Palette; - - -public class PaletteHolderLoader implements TypeLoader { - @SuppressWarnings("unchecked") - @Override - public PaletteHolder load(AnnotatedType type, Object o, ConfigLoader configLoader) throws LoadException { - List> palette = (List>) o; - PaletteHolderBuilder builder = new PaletteHolderBuilder(); - for(Map layer : palette) { - for(Map.Entry entry : layer.entrySet()) { - builder.add(entry.getValue(), configLoader.loadType(Palette.class, entry.getKey())); - } - } - return builder.build(); - } -}