mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-02-16 10:30:42 +00:00
rename main parameters/fields to platform
This commit is contained in:
4
.github/ISSUE_TEMPLATE/BUG_REPORT.md
vendored
4
.github/ISSUE_TEMPLATE/BUG_REPORT.md
vendored
@@ -21,8 +21,8 @@ assignees: ""
|
||||
- You must be on the LATEST version of Terra to receive any support. There is no support for older versions of Terra.
|
||||
- Make sure that this is not a *specific* compatibility issue with another terrain generation mod.
|
||||
Do not request *specific* compatibility with mods or plugins (e.g. "Compatibility with TechCraft v7").
|
||||
That should be implemented in an addon, **not** in the main project.
|
||||
*General* compatibility (e.g. "Ability to pull Vanilla/Modded features from parent biomes") will be considered in the main project.
|
||||
That should be implemented in an addon, **not** in the platform project.
|
||||
*General* compatibility (e.g. "Ability to pull Vanilla/Modded features from parent biomes") will be considered in the platform project.
|
||||
- Make sure that there are no already existing issues open with your problem. If you open a duplicate, it will be closed as such.
|
||||
- Make sure that it is actually Terra causing the issue, and not another mod/plugin.
|
||||
You can do this by testing to see if you can recreate the issue without Terra installed.
|
||||
|
||||
@@ -114,9 +114,9 @@ please [include as many details as possible](#how-do-i-submit-a-good-bug-report)
|
||||
- Make sure that this is not a *specific* compatibility issue with another
|
||||
terrain generation mod. Do not request *specific* compatibility with mods or
|
||||
plugins (e.g. "Compatibility with TechCraft v7"). That should be implemented
|
||||
in an addon, **not** in the main project.
|
||||
in an addon, **not** in the platform project.
|
||||
*General* compatibility (e.g. "Ability to pull Vanilla/Modded features from
|
||||
parent biomes") will be considered in the main project.
|
||||
parent biomes") will be considered in the platform project.
|
||||
- Search for
|
||||
any [already existing issues](https://github.com/PolyhedralDev/Terra/issues?q=is%3Aissue+)
|
||||
open with your problem. If you open a duplicate, it will be closed as such.
|
||||
@@ -200,7 +200,7 @@ please [include as many details as possible](#how-do-i-submit-a-good-enhancement
|
||||
|
||||
Enhancement suggestions are tracked
|
||||
as [GitHub issues](https://guides.github.com/features/issues/). Create an issue
|
||||
on our main repository and provide the following information:
|
||||
on our platform repository and provide the following information:
|
||||
|
||||
- **Use a clear and descriptive title** for the issue to identify the
|
||||
suggestion.
|
||||
@@ -243,7 +243,7 @@ accepted.
|
||||
|
||||
Pull Requests are tracked
|
||||
as [GitHub Pull Requests](https://guides.github.com/activities/forking/#making-a-pull-request)
|
||||
. Create a pr on our main repository and provide the following information:
|
||||
. Create a pr on our platform repository and provide the following information:
|
||||
|
||||
- **Use a clear and descriptive title** to identify the pull request.
|
||||
- **State what this pull request adds/fixes**.
|
||||
@@ -347,7 +347,7 @@ TODO
|
||||
#### General Compatibility
|
||||
|
||||
General compatibility (example: injection of Vanilla structures/features/carvers
|
||||
into packs) is acceptable in the main project.
|
||||
into packs) is acceptable in the platform project.
|
||||
|
||||
- General compatibility features should be *disabled by default*. Having things
|
||||
auto-injected causes unpredictable behaviour that is annoying to diagnose.
|
||||
@@ -365,7 +365,7 @@ into packs) is acceptable in the main project.
|
||||
|
||||
#### Specific Compatibility
|
||||
|
||||
Specific compatibility should *not* be put in the main project. (Example: Adding
|
||||
Specific compatibility should *not* be put in the platform project. (Example: Adding
|
||||
the ability to generate TechCraft v7's doo-dads with a TerraScript function)
|
||||
|
||||
Having specific compatibilities leads to tons of extra dependencies to keep
|
||||
|
||||
@@ -26,18 +26,18 @@ public class ImageBiomeProviderAddon extends TerraAddon {
|
||||
};
|
||||
|
||||
@Inject
|
||||
private Platform main;
|
||||
private Platform platform;
|
||||
|
||||
@Override
|
||||
public void initialize() {
|
||||
main.getEventManager()
|
||||
.getHandler(FunctionalEventHandler.class)
|
||||
.register(this, ConfigPackPreLoadEvent.class)
|
||||
.then(event -> {
|
||||
CheckedRegistry<Supplier<ObjectTemplate<BiomeProvider>>> providerRegistry = event.getPack().getOrCreateRegistry(
|
||||
PROVIDER_REGISTRY_KEY);
|
||||
providerRegistry.register("IMAGE", () -> new ImageProviderTemplate(event.getPack().getRegistry(TerraBiome.class)));
|
||||
})
|
||||
.failThrough();
|
||||
platform.getEventManager()
|
||||
.getHandler(FunctionalEventHandler.class)
|
||||
.register(this, ConfigPackPreLoadEvent.class)
|
||||
.then(event -> {
|
||||
CheckedRegistry<Supplier<ObjectTemplate<BiomeProvider>>> providerRegistry = event.getPack().getOrCreateRegistry(
|
||||
PROVIDER_REGISTRY_KEY);
|
||||
providerRegistry.register("IMAGE", () -> new ImageProviderTemplate(event.getPack().getRegistry(TerraBiome.class)));
|
||||
})
|
||||
.failThrough();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,24 +40,24 @@ public class BiomePipelineAddon extends TerraAddon {
|
||||
public static final TypeKey<Supplier<ObjectTemplate<BiomeProvider>>> PROVIDER_REGISTRY_KEY = new TypeKey<>() {
|
||||
};
|
||||
@Inject
|
||||
private Platform main;
|
||||
private Platform platform;
|
||||
|
||||
@Override
|
||||
public void initialize() {
|
||||
main.getEventManager()
|
||||
.getHandler(FunctionalEventHandler.class)
|
||||
.register(this, ConfigPackPreLoadEvent.class)
|
||||
.then(event -> {
|
||||
platform.getEventManager()
|
||||
.getHandler(FunctionalEventHandler.class)
|
||||
.register(this, ConfigPackPreLoadEvent.class)
|
||||
.then(event -> {
|
||||
CheckedRegistry<Supplier<ObjectTemplate<BiomeProvider>>> providerRegistry = event.getPack().getOrCreateRegistry(
|
||||
PROVIDER_REGISTRY_KEY);
|
||||
providerRegistry.register("PIPELINE", () -> new BiomePipelineTemplate(main));
|
||||
providerRegistry.register("PIPELINE", () -> new BiomePipelineTemplate(platform));
|
||||
})
|
||||
.then(event -> {
|
||||
.then(event -> {
|
||||
CheckedRegistry<Supplier<ObjectTemplate<BiomeSource>>> sourceRegistry = event.getPack().getOrCreateRegistry(
|
||||
SOURCE_REGISTRY_KEY);
|
||||
sourceRegistry.register("NOISE", NoiseSourceTemplate::new);
|
||||
})
|
||||
.then(event -> {
|
||||
.then(event -> {
|
||||
CheckedRegistry<Supplier<ObjectTemplate<Stage>>> stageRegistry = event.getPack().getOrCreateRegistry(STAGE_REGISTRY_KEY);
|
||||
stageRegistry.register("FRACTAL_EXPAND", ExpanderStageTemplate::new);
|
||||
stageRegistry.register("SMOOTH", SmoothMutatorTemplate::new);
|
||||
@@ -66,6 +66,6 @@ public class BiomePipelineAddon extends TerraAddon {
|
||||
stageRegistry.register("BORDER", BorderMutatorTemplate::new);
|
||||
stageRegistry.register("BORDER_LIST", BorderListMutatorTemplate::new);
|
||||
})
|
||||
.failThrough();
|
||||
.failThrough();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,12 +20,12 @@ public class BiomePipelineProvider implements BiomeProvider {
|
||||
private final NoiseSampler mutator;
|
||||
private final double noiseAmp;
|
||||
|
||||
public BiomePipelineProvider(BiomePipeline pipeline, Platform main, int resolution, NoiseSampler mutator, double noiseAmp) {
|
||||
public BiomePipelineProvider(BiomePipeline pipeline, Platform platform, int resolution, NoiseSampler mutator, double noiseAmp) {
|
||||
this.resolution = resolution;
|
||||
this.mutator = mutator;
|
||||
this.noiseAmp = noiseAmp;
|
||||
holderCache = CacheBuilder.newBuilder()
|
||||
.maximumSize(main == null ? 32 : main.getTerraConfig().getProviderCache())
|
||||
.maximumSize(platform == null ? 32 : platform.getTerraConfig().getProviderCache())
|
||||
.build(
|
||||
new CacheLoader<>() {
|
||||
@Override
|
||||
|
||||
@@ -16,7 +16,7 @@ import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
||||
|
||||
@SuppressWarnings({ "FieldMayBeFinal", "unused" })
|
||||
public class BiomePipelineTemplate extends BiomeProviderTemplate {
|
||||
private final Platform main;
|
||||
private final Platform platform;
|
||||
@Value("pipeline.initial-size")
|
||||
@Default
|
||||
private @Meta int initialSize = 2;
|
||||
@@ -27,8 +27,8 @@ public class BiomePipelineTemplate extends BiomeProviderTemplate {
|
||||
@Value("pipeline.source")
|
||||
private @Meta BiomeSource source;
|
||||
|
||||
public BiomePipelineTemplate(Platform main) {
|
||||
this.main = main;
|
||||
public BiomePipelineTemplate(Platform platform) {
|
||||
this.platform = platform;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -36,6 +36,6 @@ public class BiomePipelineTemplate extends BiomeProviderTemplate {
|
||||
BiomePipeline.BiomePipelineBuilder biomePipelineBuilder = new BiomePipeline.BiomePipelineBuilder(initialSize);
|
||||
stages.forEach(biomePipelineBuilder::addStage);
|
||||
BiomePipeline pipeline = biomePipelineBuilder.build(source);
|
||||
return new BiomePipelineProvider(pipeline, main, resolution, blend, blendAmp);
|
||||
return new BiomePipelineProvider(pipeline, platform, resolution, blend, blendAmp);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,18 +25,18 @@ public class SingleBiomeProviderAddon extends TerraAddon {
|
||||
};
|
||||
|
||||
@Inject
|
||||
private Platform main;
|
||||
private Platform platform;
|
||||
|
||||
@Override
|
||||
public void initialize() {
|
||||
main.getEventManager()
|
||||
.getHandler(FunctionalEventHandler.class)
|
||||
.register(this, ConfigPackPreLoadEvent.class)
|
||||
.then(event -> {
|
||||
platform.getEventManager()
|
||||
.getHandler(FunctionalEventHandler.class)
|
||||
.register(this, ConfigPackPreLoadEvent.class)
|
||||
.then(event -> {
|
||||
CheckedRegistry<Supplier<ObjectTemplate<BiomeProvider>>> providerRegistry = event.getPack().getOrCreateRegistry(
|
||||
PROVIDER_REGISTRY_KEY);
|
||||
providerRegistry.register("SINGLE", SingleBiomeProviderTemplate::new);
|
||||
})
|
||||
.failThrough();
|
||||
.failThrough();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,30 +23,31 @@ import com.dfsek.terra.api.world.generator.ChunkGeneratorProvider;
|
||||
@Version("1.0.0")
|
||||
public class NoiseChunkGenerator3DAddon extends TerraAddon {
|
||||
@Inject
|
||||
private Platform main;
|
||||
private Platform platform;
|
||||
|
||||
@Override
|
||||
public void initialize() {
|
||||
main.getEventManager()
|
||||
.getHandler(FunctionalEventHandler.class)
|
||||
.register(this, ConfigPackPreLoadEvent.class)
|
||||
.then(event -> {
|
||||
platform.getEventManager()
|
||||
.getHandler(FunctionalEventHandler.class)
|
||||
.register(this, ConfigPackPreLoadEvent.class)
|
||||
.then(event -> {
|
||||
event.getPack().getOrCreateRegistry(ChunkGeneratorProvider.class).register("NOISE_3D",
|
||||
pack -> new NoiseChunkGenerator3D(pack, main));
|
||||
pack -> new NoiseChunkGenerator3D(pack,
|
||||
platform));
|
||||
event.getPack()
|
||||
.applyLoader(SlantHolder.class, new SlantHolderLoader())
|
||||
.applyLoader(PaletteHolder.class, new PaletteHolderLoader());
|
||||
})
|
||||
.failThrough();
|
||||
.failThrough();
|
||||
|
||||
main.getEventManager()
|
||||
.getHandler(FunctionalEventHandler.class)
|
||||
.register(this, ConfigurationLoadEvent.class)
|
||||
.then(event -> {
|
||||
platform.getEventManager()
|
||||
.getHandler(FunctionalEventHandler.class)
|
||||
.register(this, ConfigurationLoadEvent.class)
|
||||
.then(event -> {
|
||||
if(event.is(TerraBiome.class)) {
|
||||
event.getLoadedObject(TerraBiome.class).getContext().put(event.load(new BiomePaletteTemplate()).get());
|
||||
}
|
||||
})
|
||||
.failThrough();
|
||||
.failThrough();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.dfsek.terra.addons.chunkgenerator.generation.generators;
|
||||
|
||||
import com.dfsek.terra.api.Platform;
|
||||
|
||||
import net.jafama.FastMath;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -10,7 +12,6 @@ import java.util.Random;
|
||||
import com.dfsek.terra.addons.chunkgenerator.PaletteUtil;
|
||||
import com.dfsek.terra.addons.chunkgenerator.generation.math.samplers.Sampler3D;
|
||||
import com.dfsek.terra.addons.chunkgenerator.palette.PaletteInfo;
|
||||
import com.dfsek.terra.api.Platform;
|
||||
import com.dfsek.terra.api.block.state.BlockState;
|
||||
import com.dfsek.terra.api.block.state.properties.base.Properties;
|
||||
import com.dfsek.terra.api.block.state.properties.enums.Direction;
|
||||
@@ -31,21 +32,21 @@ import com.dfsek.terra.api.util.math.Sampler;
|
||||
|
||||
public class NoiseChunkGenerator3D implements ChunkGenerator {
|
||||
private final ConfigPack configPack;
|
||||
private final Platform main;
|
||||
private final Platform platform;
|
||||
private final List<GenerationStage> generationStages = new ArrayList<>();
|
||||
|
||||
private final BlockState air;
|
||||
|
||||
public NoiseChunkGenerator3D(ConfigPack c, Platform main) {
|
||||
public NoiseChunkGenerator3D(ConfigPack c, Platform platform) {
|
||||
this.configPack = c;
|
||||
this.main = main;
|
||||
this.air = main.getWorldHandle().air();
|
||||
this.platform = platform;
|
||||
this.air = platform.getWorldHandle().air();
|
||||
c.getStages().forEach(stage -> generationStages.add(stage.newInstance(c)));
|
||||
}
|
||||
|
||||
@SuppressWarnings("try")
|
||||
static void biomes(@NotNull World world, int chunkX, int chunkZ, @NotNull BiomeGrid biome, Platform main) {
|
||||
try(ProfileFrame ignore = main.getProfiler().profile("biomes")) {
|
||||
static void biomes(@NotNull World world, int chunkX, int chunkZ, @NotNull BiomeGrid biome, Platform platform) {
|
||||
try(ProfileFrame ignore = platform.getProfiler().profile("biomes")) {
|
||||
int xOrig = (chunkX << 4);
|
||||
int zOrig = (chunkZ << 4);
|
||||
long seed = world.getSeed();
|
||||
@@ -65,7 +66,7 @@ public class NoiseChunkGenerator3D implements ChunkGenerator {
|
||||
@Override
|
||||
@SuppressWarnings("try")
|
||||
public ChunkData generateChunkData(@NotNull World world, Random random, int chunkX, int chunkZ, ChunkData chunk) {
|
||||
try(ProfileFrame ignore = main.getProfiler().profile("chunk_base_3d")) {
|
||||
try(ProfileFrame ignore = platform.getProfiler().profile("chunk_base_3d")) {
|
||||
BiomeProvider grid = world.getBiomeProvider();
|
||||
|
||||
int xOrig = (chunkX << 4);
|
||||
@@ -87,7 +88,7 @@ public class NoiseChunkGenerator3D implements ChunkGenerator {
|
||||
PaletteInfo paletteInfo = biome.getContext().get(PaletteInfo.class);
|
||||
|
||||
if(paletteInfo == null) {
|
||||
main.logger().info("null palette: " + biome.getID());
|
||||
platform.logger().info("null palette: " + biome.getID());
|
||||
}
|
||||
|
||||
GenerationSettings generationSettings = biome.getGenerator();
|
||||
@@ -125,7 +126,7 @@ public class NoiseChunkGenerator3D implements ChunkGenerator {
|
||||
|
||||
@Override
|
||||
public void generateBiomes(@NotNull World world, @NotNull Random random, int chunkX, int chunkZ, @NotNull BiomeGrid biome) {
|
||||
biomes(world, chunkX, chunkZ, biome, main);
|
||||
biomes(world, chunkX, chunkZ, biome, platform);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -139,8 +140,8 @@ public class NoiseChunkGenerator3D implements ChunkGenerator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Platform getMain() {
|
||||
return main;
|
||||
public Platform getPlatform() {
|
||||
return platform;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -17,17 +17,17 @@ import com.dfsek.terra.api.inject.annotations.Inject;
|
||||
@Version("1.0.0")
|
||||
public class BiomeAddon extends TerraAddon {
|
||||
@Inject
|
||||
private Platform main;
|
||||
private Platform platform;
|
||||
|
||||
@Override
|
||||
public void initialize() {
|
||||
main.getEventManager()
|
||||
.getHandler(FunctionalEventHandler.class)
|
||||
.register(this, ConfigPackPreLoadEvent.class)
|
||||
.then(event -> {
|
||||
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();
|
||||
.failThrough();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,8 +35,8 @@ public class BiomeConfigType implements ConfigType<BiomeTemplate, TerraBiome> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BiomeTemplate getTemplate(ConfigPack pack, Platform main) {
|
||||
return new BiomeTemplate(pack, main);
|
||||
public BiomeTemplate getTemplate(ConfigPack pack, Platform platform) {
|
||||
return new BiomeTemplate(pack, platform);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -14,7 +14,7 @@ public class BiomeFactory implements ConfigFactory<BiomeTemplate, TerraBiome> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public TerraBiome build(BiomeTemplate template, Platform main) {
|
||||
public TerraBiome build(BiomeTemplate template, Platform platform) {
|
||||
UserDefinedGenerationSettings generator = new UserDefinedGenerationSettings(template.getNoiseEquation(),
|
||||
template.getElevationEquation(),
|
||||
template.getCarvingEquation(), template.getBiomeNoise(),
|
||||
|
||||
@@ -113,7 +113,7 @@ public class BiomeTemplate implements AbstractableTemplate, ValidatedConfigTempl
|
||||
private @Meta Map<String, @Meta Integer> colors = new HashMap<>();
|
||||
// Plain ol' map, so platforms can decide what to do with colors (if anything).
|
||||
|
||||
public BiomeTemplate(ConfigPack pack, Platform main) {
|
||||
public BiomeTemplate(ConfigPack pack, Platform platform) {
|
||||
this.pack = pack;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
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.Platform;
|
||||
import com.dfsek.terra.api.util.vector.Vector3;
|
||||
import com.dfsek.terra.api.world.World;
|
||||
import com.dfsek.terra.api.world.biome.TerraBiome;
|
||||
@@ -23,15 +24,15 @@ public class AsyncBiomeFinder implements Runnable {
|
||||
protected final int centerX;
|
||||
protected final int centerZ;
|
||||
protected final World world;
|
||||
protected final Platform main;
|
||||
protected final Platform platform;
|
||||
private final Consumer<Vector3> callback;
|
||||
protected int searchSize = 1;
|
||||
|
||||
public AsyncBiomeFinder(BiomeProvider provider, TerraBiome target, @NotNull Vector3 origin, World world, int startRadius, int maxRadius,
|
||||
Consumer<Vector3> callback, Platform main) {
|
||||
Consumer<Vector3> callback, Platform platform) {
|
||||
this.provider = provider;
|
||||
this.target = target;
|
||||
this.main = main;
|
||||
this.platform = platform;
|
||||
this.startRadius = startRadius;
|
||||
this.maxRadius = maxRadius;
|
||||
this.centerX = origin.getBlockX();
|
||||
@@ -41,7 +42,7 @@ public class AsyncBiomeFinder implements Runnable {
|
||||
}
|
||||
|
||||
public Vector3 finalizeVector(Vector3 orig) {
|
||||
return orig.multiply(main.getTerraConfig().getBiomeSearchResolution());
|
||||
return orig.multiply(platform.getTerraConfig().getBiomeSearchResolution());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -90,7 +91,7 @@ public class AsyncBiomeFinder implements Runnable {
|
||||
* @return TerraBiome at coordinates
|
||||
*/
|
||||
public boolean isValid(int x, int z, TerraBiome target) {
|
||||
int res = main.getTerraConfig().getBiomeSearchResolution();
|
||||
int res = platform.getTerraConfig().getBiomeSearchResolution();
|
||||
return getProvider().getBiome(x * res, z * res, world.getSeed()).equals(target);
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
||||
@PlayerCommand
|
||||
public class BiomeCommand implements CommandTemplate {
|
||||
@Inject
|
||||
private Platform main;
|
||||
private Platform platform;
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender) {
|
||||
|
||||
@@ -51,7 +51,7 @@ public class BiomeLocateCommand implements CommandTemplate {
|
||||
private boolean teleport;
|
||||
|
||||
@Inject
|
||||
private Platform main;
|
||||
private Platform platform;
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender) {
|
||||
@@ -59,7 +59,7 @@ public class BiomeLocateCommand implements CommandTemplate {
|
||||
Player player = (Player) sender;
|
||||
|
||||
new Thread(new AsyncBiomeFinder(player.world().getBiomeProvider(), biome,
|
||||
player.position().clone().multiply((1D / main.getTerraConfig().getBiomeSearchResolution())),
|
||||
player.position().clone().multiply((1D / platform.getTerraConfig().getBiomeSearchResolution())),
|
||||
player.world(), 0, radius, location -> {
|
||||
if(location != null) {
|
||||
sender.sendMessage(
|
||||
@@ -67,11 +67,11 @@ public class BiomeLocateCommand implements CommandTemplate {
|
||||
location.getBlockX(), location.getBlockZ(),
|
||||
location.add(new Vector3(0, player.position().getY(), 0)).distance(player.position())));
|
||||
if(teleport) {
|
||||
main.runPossiblyUnsafeTask(
|
||||
platform.runPossiblyUnsafeTask(
|
||||
() -> player.position(new Vector3(location.getX(), player.position().getY(), location.getZ())));
|
||||
}
|
||||
} else sender.sendMessage("Unable to locate biome \"" + biome.getID() + "\"");
|
||||
}, main), "Biome Location Thread").start();
|
||||
}, platform), "Biome Location Thread").start();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ import com.dfsek.terra.api.world.biome.TerraBiome;
|
||||
|
||||
public class BiomeArgumentParser implements ArgumentParser<TerraBiome> {
|
||||
@Inject
|
||||
private Platform main;
|
||||
private Platform platform;
|
||||
|
||||
@Override
|
||||
public TerraBiome parse(CommandSender sender, String arg) {
|
||||
|
||||
@@ -13,7 +13,7 @@ import com.dfsek.terra.api.world.biome.TerraBiome;
|
||||
|
||||
public class BiomeTabCompleter implements TabCompleter {
|
||||
@Inject
|
||||
private Platform main;
|
||||
private Platform platform;
|
||||
|
||||
@Override
|
||||
public List<String> complete(CommandSender sender) {
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.dfsek.terra.addons.carver;
|
||||
|
||||
import com.dfsek.terra.api.Platform;
|
||||
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
import com.google.common.cache.CacheLoader;
|
||||
import com.google.common.cache.LoadingCache;
|
||||
@@ -11,7 +13,6 @@ import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import com.dfsek.terra.addons.carver.carving.Worm;
|
||||
import com.dfsek.terra.api.Platform;
|
||||
import com.dfsek.terra.api.util.MathUtil;
|
||||
import com.dfsek.terra.api.util.PopulationUtil;
|
||||
import com.dfsek.terra.api.util.vector.Vector3;
|
||||
@@ -25,9 +26,9 @@ public class CarverCache {
|
||||
private final LoadingCache<Long, List<Worm.WormPoint>> cache;
|
||||
private final UserDefinedCarver carver;
|
||||
|
||||
public CarverCache(World w, Platform main, UserDefinedCarver carver) {
|
||||
public CarverCache(World w, Platform platform, UserDefinedCarver carver) {
|
||||
this.carver = carver;
|
||||
cache = CacheBuilder.newBuilder().maximumSize(main.getTerraConfig().getCarverCacheSize())
|
||||
cache = CacheBuilder.newBuilder().maximumSize(platform.getTerraConfig().getCarverCacheSize())
|
||||
.build(new CacheLoader<>() {
|
||||
@Override
|
||||
public List<Worm.WormPoint> load(@NotNull Long key) {
|
||||
|
||||
@@ -21,7 +21,7 @@ public class CarverFactory implements ConfigFactory<CarverTemplate, UserDefinedC
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserDefinedCarver build(CarverTemplate config, Platform main) throws LoadException {
|
||||
public UserDefinedCarver build(CarverTemplate config, Platform platform) throws LoadException {
|
||||
double[] start = { config.getStartX(), config.getStartY(), config.getStartZ() };
|
||||
double[] mutate = { config.getMutateX(), config.getMutateY(), config.getMutateZ() };
|
||||
List<String> radius = Arrays.asList(config.getRadMX(), config.getRadMY(), config.getRadMZ());
|
||||
@@ -29,7 +29,7 @@ public class CarverFactory implements ConfigFactory<CarverTemplate, UserDefinedC
|
||||
UserDefinedCarver carver;
|
||||
try {
|
||||
carver = new UserDefinedCarver(config.getHeight(), config.getLength(), start, mutate, radius, new Scope(), hash,
|
||||
config.getCutTop(), config.getCutBottom(), config, main);
|
||||
config.getCutTop(), config.getCutBottom(), config, platform);
|
||||
} catch(ParseException e) {
|
||||
throw new LoadException("Unable to parse radius equations", e);
|
||||
}
|
||||
|
||||
@@ -22,16 +22,16 @@ import com.dfsek.terra.api.world.generator.GenerationStage;
|
||||
public class CavePopulator implements GenerationStage, Chunkified {
|
||||
private static final Map<BlockType, BlockState> shiftStorage = new HashMap<>();
|
||||
// Persist BlockData created for shifts, to avoid re-calculating each time.
|
||||
private final Platform main;
|
||||
private final Platform platform;
|
||||
|
||||
public CavePopulator(Platform main) {
|
||||
this.main = main;
|
||||
public CavePopulator(Platform platform) {
|
||||
this.platform = platform;
|
||||
}
|
||||
|
||||
@SuppressWarnings("try")
|
||||
@Override
|
||||
public void populate(@NotNull World world, @NotNull Chunk chunk) {
|
||||
try(ProfileFrame ignore = main.getProfiler().profile("carving")) {
|
||||
try(ProfileFrame ignore = platform.getProfiler().profile("carving")) {
|
||||
Random random = PopulationUtil.getRandom(chunk);
|
||||
WorldConfig config = world.getConfig();
|
||||
if(config.disableCarving()) return;
|
||||
@@ -40,7 +40,7 @@ public class CavePopulator implements GenerationStage, Chunkified {
|
||||
CarverTemplate template = c.getConfig();
|
||||
Map<Vector3, BlockState> shiftCandidate = new HashMap<>();
|
||||
c.carve(chunk.getX(), chunk.getZ(), world, (v, type) -> {
|
||||
try(ProfileFrame ignored = main.getProfiler().profile("carving:" + c.getConfig().getID())) {
|
||||
try(ProfileFrame ignored = platform.getProfiler().profile("carving:" + c.getConfig().getID())) {
|
||||
BlockState m = chunk.getBlock(v.getBlockX(), v.getBlockY(), v.getBlockZ());
|
||||
BlockType re = m.getBlockType();
|
||||
switch(type) {
|
||||
|
||||
@@ -34,13 +34,13 @@ public class UserDefinedCarver extends Carver {
|
||||
private final Expression zRad;
|
||||
|
||||
private final Map<Long, CarverCache> cacheMap = new ConcurrentHashMap<>();
|
||||
private final Platform main;
|
||||
private final Platform platform;
|
||||
private double step = 2;
|
||||
private Range recalc = new ConstantRange(8, 10);
|
||||
private double recalcMagnitude = 3;
|
||||
|
||||
public UserDefinedCarver(Range height, Range length, double[] start, double[] mutate, List<String> radii, Scope parent, long hash,
|
||||
int topCut, int bottomCut, CarverTemplate config, Platform main) throws ParseException {
|
||||
int topCut, int bottomCut, CarverTemplate config, Platform platform) throws ParseException {
|
||||
super(height.getMin(), height.getMax());
|
||||
this.length = length;
|
||||
this.start = start;
|
||||
@@ -49,7 +49,7 @@ public class UserDefinedCarver extends Carver {
|
||||
this.topCut = topCut;
|
||||
this.bottomCut = bottomCut;
|
||||
this.config = config;
|
||||
this.main = main;
|
||||
this.platform = platform;
|
||||
|
||||
Parser p = new Parser();
|
||||
|
||||
@@ -74,7 +74,7 @@ public class UserDefinedCarver extends Carver {
|
||||
@Override
|
||||
public void carve(int chunkX, int chunkZ, World w, BiConsumer<Vector3, CarvingType> consumer) {
|
||||
synchronized(cacheMap) {
|
||||
CarverCache cache = cacheMap.computeIfAbsent(w.getSeed(), world -> new CarverCache(w, main, this));
|
||||
CarverCache cache = cacheMap.computeIfAbsent(w.getSeed(), world -> new CarverCache(w, platform, this));
|
||||
int carvingRadius = getCarvingRadius();
|
||||
for(int x = chunkX - carvingRadius; x <= chunkX + carvingRadius; x++) {
|
||||
for(int z = chunkZ - carvingRadius; z <= chunkZ + carvingRadius; z++) {
|
||||
|
||||
@@ -31,14 +31,14 @@ public class DistributorAddon extends TerraAddon {
|
||||
public static final TypeKey<Supplier<ObjectTemplate<Distributor>>> DISTRIBUTOR_TOKEN = new TypeKey<>() {
|
||||
};
|
||||
@Inject
|
||||
private Platform main;
|
||||
private Platform platform;
|
||||
|
||||
@Override
|
||||
public void initialize() {
|
||||
main.getEventManager()
|
||||
.getHandler(FunctionalEventHandler.class)
|
||||
.register(this, ConfigPackPreLoadEvent.class)
|
||||
.then(event -> {
|
||||
platform.getEventManager()
|
||||
.getHandler(FunctionalEventHandler.class)
|
||||
.register(this, ConfigPackPreLoadEvent.class)
|
||||
.then(event -> {
|
||||
CheckedRegistry<Supplier<ObjectTemplate<Distributor>>> distributorRegistry = event.getPack().getOrCreateRegistry(
|
||||
DISTRIBUTOR_TOKEN);
|
||||
distributorRegistry.register("NOISE", NoiseDistributorTemplate::new);
|
||||
@@ -51,6 +51,6 @@ public class DistributorAddon extends TerraAddon {
|
||||
event.getPack()
|
||||
.applyLoader(Point.class, PointTemplate::new);
|
||||
})
|
||||
.failThrough();
|
||||
.failThrough();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,14 +15,14 @@ import com.dfsek.terra.api.inject.annotations.Inject;
|
||||
@Author("Terra")
|
||||
public class FeatureAddon extends TerraAddon {
|
||||
@Inject
|
||||
private Platform main;
|
||||
private Platform platform;
|
||||
|
||||
@Override
|
||||
public void initialize() {
|
||||
main.getEventManager()
|
||||
.getHandler(FunctionalEventHandler.class)
|
||||
.register(this, ConfigPackPreLoadEvent.class)
|
||||
.then(event -> event.getPack().registerConfigType(new FeatureConfigType(), "FEATURE", 3))
|
||||
.failThrough();
|
||||
platform.getEventManager()
|
||||
.getHandler(FunctionalEventHandler.class)
|
||||
.register(this, ConfigPackPreLoadEvent.class)
|
||||
.then(event -> event.getPack().registerConfigType(new FeatureConfigType(), "FEATURE", 3))
|
||||
.failThrough();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ public class FeatureConfigType implements ConfigType<FeatureTemplate, Feature> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public FeatureTemplate getTemplate(ConfigPack pack, Platform main) {
|
||||
public FeatureTemplate getTemplate(ConfigPack pack, Platform platform) {
|
||||
return new FeatureTemplate();
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ import com.dfsek.terra.api.structure.feature.Feature;
|
||||
|
||||
public class FeatureFactory implements ConfigFactory<FeatureTemplate, Feature> {
|
||||
@Override
|
||||
public Feature build(FeatureTemplate config, Platform main) throws LoadException {
|
||||
public Feature build(FeatureTemplate config, Platform platform) throws LoadException {
|
||||
return new ConfiguredFeature(config.getStructures(), config.getStructureNoise(), config.getDistributor(), config.getLocator());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,17 +17,17 @@ import com.dfsek.terra.api.inject.annotations.Inject;
|
||||
@Version("0.1.0")
|
||||
public class FloraAddon extends TerraAddon {
|
||||
@Inject
|
||||
private Platform main;
|
||||
private Platform platform;
|
||||
|
||||
@Override
|
||||
public void initialize() {
|
||||
main.getEventManager()
|
||||
.getHandler(FunctionalEventHandler.class)
|
||||
.register(this, ConfigPackPreLoadEvent.class)
|
||||
.then(event -> {
|
||||
platform.getEventManager()
|
||||
.getHandler(FunctionalEventHandler.class)
|
||||
.register(this, ConfigPackPreLoadEvent.class)
|
||||
.then(event -> {
|
||||
event.getPack().registerConfigType(new FloraConfigType(), "FLORA", 2);
|
||||
event.getPack().applyLoader(BlockLayer.class, BlockLayerTemplate::new);
|
||||
})
|
||||
.failThrough();
|
||||
.failThrough();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ public class FloraConfigType implements ConfigType<FloraTemplate, Structure> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public FloraTemplate getTemplate(ConfigPack pack, Platform main) {
|
||||
public FloraTemplate getTemplate(ConfigPack pack, Platform platform) {
|
||||
return new FloraTemplate();
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import com.dfsek.terra.api.structure.Structure;
|
||||
|
||||
public class FloraFactory implements ConfigFactory<FloraTemplate, Structure> {
|
||||
@Override
|
||||
public TerraFlora build(FloraTemplate config, Platform main) {
|
||||
public TerraFlora build(FloraTemplate config, Platform platform) {
|
||||
return new TerraFlora(config.getLayers(), config.doPhysics(), config.isCeiling(),
|
||||
config.getRotatable(),
|
||||
config.getNoiseDistribution(), config.getID());
|
||||
|
||||
@@ -42,16 +42,16 @@ public class LocatorAddon extends TerraAddon {
|
||||
public static final TypeKey<Supplier<ObjectTemplate<Pattern>>> PATTERN_TOKEN = new TypeKey<>() {
|
||||
};
|
||||
@Inject
|
||||
private Platform main;
|
||||
private Platform platform;
|
||||
|
||||
@Override
|
||||
public void initialize() {
|
||||
main.getEventManager()
|
||||
.getHandler(FunctionalEventHandler.class)
|
||||
.register(this, ConfigPackPreLoadEvent.class)
|
||||
.then(event -> {
|
||||
platform.getEventManager()
|
||||
.getHandler(FunctionalEventHandler.class)
|
||||
.register(this, ConfigPackPreLoadEvent.class)
|
||||
.then(event -> {
|
||||
CheckedRegistry<Supplier<ObjectTemplate<Locator>>> locatorRegistry = event.getPack().getOrCreateRegistry(LOCATOR_TOKEN);
|
||||
locatorRegistry.register("SURFACE", () -> new SurfaceLocatorTemplate(main));
|
||||
locatorRegistry.register("SURFACE", () -> new SurfaceLocatorTemplate(platform));
|
||||
locatorRegistry.register("RANDOM", RandomLocatorTemplate::new);
|
||||
locatorRegistry.register("PATTERN", PatternLocatorTemplate::new);
|
||||
locatorRegistry.register("NOISE", NoiseLocatorTemplate::new);
|
||||
@@ -60,7 +60,7 @@ public class LocatorAddon extends TerraAddon {
|
||||
locatorRegistry.register("AND", AndLocatorTemplate::new);
|
||||
locatorRegistry.register("OR", OrLocatorTemplate::new);
|
||||
})
|
||||
.then(event -> {
|
||||
.then(event -> {
|
||||
CheckedRegistry<Supplier<ObjectTemplate<Pattern>>> patternRegistry = event.getPack().getOrCreateRegistry(PATTERN_TOKEN);
|
||||
patternRegistry.register("MATCH_AIR", AirMatchPatternTemplate::new);
|
||||
patternRegistry.register("MATCH_SOLID", SolidMatchPatternTemplate::new);
|
||||
@@ -71,6 +71,6 @@ public class LocatorAddon extends TerraAddon {
|
||||
patternRegistry.register("OR", OrPatternTemplate::new);
|
||||
patternRegistry.register("NOT", NotPatternTemplate::new);
|
||||
})
|
||||
.failThrough();
|
||||
.failThrough();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,17 +11,17 @@ import com.dfsek.terra.api.util.Range;
|
||||
|
||||
|
||||
public class SurfaceLocatorTemplate implements ObjectTemplate<Locator> {
|
||||
private final Platform main;
|
||||
private final Platform platform;
|
||||
|
||||
@Value("range")
|
||||
private @Meta Range range;
|
||||
|
||||
public SurfaceLocatorTemplate(Platform main) {
|
||||
this.main = main;
|
||||
public SurfaceLocatorTemplate(Platform platform) {
|
||||
this.platform = platform;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Locator get() {
|
||||
return new SurfaceLocator(range, main);
|
||||
return new SurfaceLocator(range, platform);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,9 +13,9 @@ public class SurfaceLocator implements Locator {
|
||||
|
||||
private final BlockState air;
|
||||
|
||||
public SurfaceLocator(Range search, Platform main) {
|
||||
public SurfaceLocator(Range search, Platform platform) {
|
||||
this.search = search;
|
||||
this.air = main.getWorldHandle().air();
|
||||
this.air = platform.getWorldHandle().air();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -333,7 +333,7 @@ public class CellularSampler extends NoiseFunction {
|
||||
distance1 = fastSqrt(distance1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return switch(returnType) {
|
||||
case CellValue -> closestHash * (1 / 2147483648.0);
|
||||
case Distance -> distance0 - 1;
|
||||
@@ -493,7 +493,7 @@ public class CellularSampler extends NoiseFunction {
|
||||
distance1 = fastSqrt(distance1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return switch(returnType) {
|
||||
case CellValue -> closestHash * (1 / 2147483648.0);
|
||||
case Distance -> distance0 - 1;
|
||||
|
||||
@@ -16,17 +16,17 @@ import com.dfsek.terra.api.world.generator.GenerationStageProvider;
|
||||
@Version("1.0.0")
|
||||
public class OreAddon extends TerraAddon {
|
||||
@Inject
|
||||
private Platform main;
|
||||
private Platform platform;
|
||||
|
||||
@Override
|
||||
public void initialize() {
|
||||
main.getEventManager()
|
||||
.getHandler(FunctionalEventHandler.class)
|
||||
.register(this, ConfigPackPreLoadEvent.class)
|
||||
.then(event -> {
|
||||
platform.getEventManager()
|
||||
.getHandler(FunctionalEventHandler.class)
|
||||
.register(this, ConfigPackPreLoadEvent.class)
|
||||
.then(event -> {
|
||||
event.getPack().registerConfigType(new OreConfigType(), "ORE", 1);
|
||||
event.getPack().getOrCreateRegistry(GenerationStageProvider.class).register("ORE", pack -> new OrePopulator(main));
|
||||
event.getPack().getOrCreateRegistry(GenerationStageProvider.class).register("ORE", pack -> new OrePopulator(platform));
|
||||
})
|
||||
.failThrough();
|
||||
.failThrough();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ public class OreConfigType implements ConfigType<OreTemplate, Ore> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public OreTemplate getTemplate(ConfigPack pack, Platform main) {
|
||||
public OreTemplate getTemplate(ConfigPack pack, Platform platform) {
|
||||
return new OreTemplate();
|
||||
}
|
||||
|
||||
|
||||
@@ -9,8 +9,8 @@ import com.dfsek.terra.api.config.ConfigFactory;
|
||||
|
||||
public class OreFactory implements ConfigFactory<OreTemplate, Ore> {
|
||||
@Override
|
||||
public Ore build(OreTemplate config, Platform main) {
|
||||
public Ore build(OreTemplate config, Platform platform) {
|
||||
BlockState m = config.getMaterial();
|
||||
return new VanillaOre(m, config.getReplaceable(), config.doPhysics(), config.getSize(), main, config.getMaterialOverrides());
|
||||
return new VanillaOre(m, config.getReplaceable(), config.doPhysics(), config.getSize(), platform, config.getMaterialOverrides());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,16 +14,16 @@ import com.dfsek.terra.api.world.generator.GenerationStage;
|
||||
|
||||
|
||||
public class OrePopulator implements GenerationStage {
|
||||
private final Platform main;
|
||||
private final Platform platform;
|
||||
|
||||
public OrePopulator(Platform main) {
|
||||
this.main = main;
|
||||
public OrePopulator(Platform platform) {
|
||||
this.platform = platform;
|
||||
}
|
||||
|
||||
@SuppressWarnings("try")
|
||||
@Override
|
||||
public void populate(@NotNull World world, @NotNull Chunk chunk) {
|
||||
try(ProfileFrame ignore = main.getProfiler().profile("ore")) {
|
||||
try(ProfileFrame ignore = platform.getProfiler().profile("ore")) {
|
||||
if(world.getConfig().disableOres()) return;
|
||||
|
||||
for(int cx = -1; cx <= 1; cx++) {
|
||||
|
||||
@@ -17,13 +17,13 @@ public abstract class Ore {
|
||||
private final MaterialSet replaceable;
|
||||
private final boolean applyGravity;
|
||||
private final Map<BlockType, BlockState> materials;
|
||||
protected Platform main;
|
||||
protected Platform platform;
|
||||
|
||||
public Ore(BlockState material, MaterialSet replaceable, boolean applyGravity, Platform main, Map<BlockType, BlockState> materials) {
|
||||
public Ore(BlockState material, MaterialSet replaceable, boolean applyGravity, Platform platform, Map<BlockType, BlockState> materials) {
|
||||
this.material = material;
|
||||
this.replaceable = replaceable;
|
||||
this.applyGravity = applyGravity;
|
||||
this.main = main;
|
||||
this.platform = platform;
|
||||
this.materials = materials;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
package com.dfsek.terra.addons.ore.ores;
|
||||
|
||||
import com.dfsek.terra.api.Platform;
|
||||
|
||||
import net.jafama.FastMath;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
import com.dfsek.terra.api.Platform;
|
||||
import com.dfsek.terra.api.block.BlockType;
|
||||
import com.dfsek.terra.api.block.state.BlockState;
|
||||
import com.dfsek.terra.api.util.Range;
|
||||
@@ -17,9 +18,9 @@ import com.dfsek.terra.api.world.Chunk;
|
||||
public class VanillaOre extends Ore {
|
||||
private final Range sizeRange;
|
||||
|
||||
public VanillaOre(BlockState material, MaterialSet replaceable, boolean applyGravity, Range size, Platform main,
|
||||
public VanillaOre(BlockState material, MaterialSet replaceable, boolean applyGravity, Range size, Platform platform,
|
||||
Map<BlockType, BlockState> materials) {
|
||||
super(material, replaceable, applyGravity, main, materials);
|
||||
super(material, replaceable, applyGravity, platform, materials);
|
||||
this.sizeRange = size;
|
||||
}
|
||||
|
||||
|
||||
@@ -17,17 +17,17 @@ import com.dfsek.terra.api.inject.annotations.Inject;
|
||||
@Version("1.0.0")
|
||||
public class PaletteAddon extends TerraAddon {
|
||||
@Inject
|
||||
private Platform main;
|
||||
private Platform platform;
|
||||
|
||||
@Override
|
||||
public void initialize() {
|
||||
main.getEventManager()
|
||||
.getHandler(FunctionalEventHandler.class)
|
||||
.register(this, ConfigPackPreLoadEvent.class)
|
||||
.then(event -> {
|
||||
event.getPack().registerConfigType(new PaletteConfigType(main), "PALETTE", 2);
|
||||
platform.getEventManager()
|
||||
.getHandler(FunctionalEventHandler.class)
|
||||
.register(this, ConfigPackPreLoadEvent.class)
|
||||
.then(event -> {
|
||||
event.getPack().registerConfigType(new PaletteConfigType(platform), "PALETTE", 2);
|
||||
event.getPack().applyLoader(PaletteLayerHolder.class, new PaletteLayerLoader());
|
||||
})
|
||||
.failThrough();
|
||||
.failThrough();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,10 +19,10 @@ public class PaletteConfigType implements ConfigType<PaletteTemplate, Palette> {
|
||||
public static final TypeKey<Palette> PALETTE_TYPE_TOKEN = new TypeKey<>() {
|
||||
};
|
||||
private final PaletteFactory factory = new PaletteFactory();
|
||||
private final Platform main;
|
||||
private final Platform platform;
|
||||
|
||||
public PaletteConfigType(Platform main) {
|
||||
this.main = main;
|
||||
public PaletteConfigType(Platform platform) {
|
||||
this.platform = platform;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -30,7 +30,7 @@ public class PaletteConfigType implements ConfigType<PaletteTemplate, Palette> {
|
||||
return () -> pack.getRegistryFactory().create(registry -> (TypeLoader<Palette>) (t, c, loader) -> {
|
||||
if(((String) c).startsWith("BLOCK:"))
|
||||
return new PaletteImpl.Singleton(
|
||||
main.getWorldHandle().createBlockData(((String) c).substring(6))); // Return single palette for BLOCK: shortcut.
|
||||
platform.getWorldHandle().createBlockData(((String) c).substring(6))); // Return single palette for BLOCK: shortcut.
|
||||
Palette obj = registry.get((String) c);
|
||||
if(obj == null)
|
||||
throw new LoadException("No such " + t.getType().getTypeName() + " matching \"" + c + "\" was found in this registry.");
|
||||
@@ -39,7 +39,7 @@ public class PaletteConfigType implements ConfigType<PaletteTemplate, Palette> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public PaletteTemplate getTemplate(ConfigPack pack, Platform main) {
|
||||
public PaletteTemplate getTemplate(ConfigPack pack, Platform platform) {
|
||||
return new PaletteTemplate();
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ import com.dfsek.terra.api.world.generator.Palette;
|
||||
|
||||
public class PaletteFactory implements ConfigFactory<PaletteTemplate, Palette> {
|
||||
@Override
|
||||
public Palette build(PaletteTemplate config, Platform main) {
|
||||
public Palette build(PaletteTemplate config, Platform platform) {
|
||||
NoisePalette palette = new NoisePalette(config.getNoise());
|
||||
for(PaletteLayerHolder layer : config.getPalette()) {
|
||||
palette.add(layer.getLayer(), layer.getSize(), layer.getSampler());
|
||||
|
||||
@@ -16,14 +16,14 @@ import com.dfsek.terra.api.structure.configured.ConfiguredStructure;
|
||||
@Author("Terra")
|
||||
public class StructureAddon extends TerraAddon {
|
||||
@Inject
|
||||
private Platform main;
|
||||
private Platform platform;
|
||||
|
||||
@Override
|
||||
public void initialize() {
|
||||
main.getEventManager()
|
||||
.getHandler(FunctionalEventHandler.class)
|
||||
.register(this, ConfigPackPreLoadEvent.class)
|
||||
.then(event -> event.getPack().applyLoader(ConfiguredStructure.class, (t, o, l) -> null))
|
||||
.failThrough();
|
||||
platform.getEventManager()
|
||||
.getHandler(FunctionalEventHandler.class)
|
||||
.register(this, ConfigPackPreLoadEvent.class)
|
||||
.then(event -> event.getPack().applyLoader(ConfiguredStructure.class, (t, o, l) -> null))
|
||||
.failThrough();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import com.dfsek.terra.api.structure.configured.ConfiguredStructure;
|
||||
|
||||
public class StructureFactory implements ConfigFactory<StructureTemplate, ConfiguredStructure> {
|
||||
@Override
|
||||
public ConfiguredStructure build(StructureTemplate config, Platform main) {
|
||||
public ConfiguredStructure build(StructureTemplate config, Platform platform) {
|
||||
return new TerraStructure(config.getStructures(), config.getY(), config.getSpawn());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
package com.dfsek.terra.addons.structure;
|
||||
|
||||
import com.dfsek.terra.api.Platform;
|
||||
|
||||
import net.jafama.FastMath;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import com.dfsek.terra.api.Platform;
|
||||
import com.dfsek.terra.api.config.WorldConfig;
|
||||
import com.dfsek.terra.api.profiler.ProfileFrame;
|
||||
import com.dfsek.terra.api.structure.configured.ConfiguredStructure;
|
||||
@@ -20,16 +21,16 @@ import com.dfsek.terra.api.world.generator.GenerationStage;
|
||||
|
||||
|
||||
public class StructurePopulator implements GenerationStage, Chunkified {
|
||||
private final Platform main;
|
||||
private final Platform platform;
|
||||
|
||||
public StructurePopulator(Platform main) {
|
||||
this.main = main;
|
||||
public StructurePopulator(Platform platform) {
|
||||
this.platform = platform;
|
||||
}
|
||||
|
||||
@SuppressWarnings("try")
|
||||
@Override
|
||||
public void populate(@NotNull World world, @NotNull Chunk chunk) {
|
||||
try(ProfileFrame ignore = main.getProfiler().profile("structure")) {
|
||||
try(ProfileFrame ignore = platform.getProfiler().profile("structure")) {
|
||||
if(world.getConfig().disableStructures()) return;
|
||||
|
||||
int cx = (chunk.getX() << 4);
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
package com.dfsek.terra.addons.structure.command;
|
||||
|
||||
import com.dfsek.terra.api.Platform;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import com.dfsek.terra.api.Platform;
|
||||
import com.dfsek.terra.api.structure.configured.ConfiguredStructure;
|
||||
import com.dfsek.terra.api.util.vector.Vector3;
|
||||
import com.dfsek.terra.api.world.World;
|
||||
@@ -19,16 +20,16 @@ public class AsyncStructureFinder implements Runnable {
|
||||
protected final int centerX;
|
||||
protected final int centerZ;
|
||||
protected final World world;
|
||||
protected final Platform main;
|
||||
protected final Platform platform;
|
||||
private final Consumer<Vector3> callback;
|
||||
protected int searchSize = 1;
|
||||
|
||||
public AsyncStructureFinder(BiomeProvider provider, ConfiguredStructure target, @NotNull Vector3 origin, World world, int startRadius,
|
||||
int maxRadius, Consumer<Vector3> callback, Platform main) {
|
||||
int maxRadius, Consumer<Vector3> callback, Platform platform) {
|
||||
//setSearchSize(target.getSpawn().getWidth() + 2 * target.getSpawn().getSeparation());
|
||||
this.provider = provider;
|
||||
this.target = target;
|
||||
this.main = main;
|
||||
this.platform = platform;
|
||||
this.startRadius = startRadius;
|
||||
this.maxRadius = maxRadius;
|
||||
this.centerX = origin.getBlockX();
|
||||
|
||||
@@ -29,7 +29,7 @@ import com.dfsek.terra.api.util.vector.Vector3;
|
||||
@Command(arguments = @Argument("id"), usage = "/terra structure export <ID>")
|
||||
public class StructureExportCommand implements CommandTemplate {
|
||||
@Inject
|
||||
private Platform main;
|
||||
private Platform platform;
|
||||
|
||||
@ArgumentTarget("id")
|
||||
private String id;
|
||||
@@ -38,7 +38,7 @@ public class StructureExportCommand implements CommandTemplate {
|
||||
public void execute(CommandSender sender) {
|
||||
Player player = (Player) sender;
|
||||
|
||||
Pair<Vector3, Vector3> l = main.getWorldHandle().getSelectedLocation(player);
|
||||
Pair<Vector3, Vector3> l = platform.getWorldHandle().getSelectedLocation(player);
|
||||
|
||||
Vector3 l1 = l.getLeft();
|
||||
Vector3 l2 = l.getRight();
|
||||
@@ -75,7 +75,7 @@ public class StructureExportCommand implements CommandTemplate {
|
||||
if(state instanceof Sign) {
|
||||
Sign sign = (Sign) state;
|
||||
if(sign.getLine(0).equals("[TERRA]")) {
|
||||
data = main.getWorldHandle().createBlockData(sign.getLine(2) + sign.getLine(3));
|
||||
data = platform.getWorldHandle().createBlockData(sign.getLine(2) + sign.getLine(3));
|
||||
}
|
||||
}
|
||||
if(!data.isStructureVoid()) {
|
||||
@@ -88,7 +88,7 @@ public class StructureExportCommand implements CommandTemplate {
|
||||
}
|
||||
}
|
||||
|
||||
File file = new File(main.getDataFolder() + File.separator + "export" + File.separator + "structures", id + ".tesf");
|
||||
File file = new File(platform.getDataFolder() + File.separator + "export" + File.separator + "structures", id + ".tesf");
|
||||
try {
|
||||
file.getParentFile().mkdirs();
|
||||
file.createNewFile();
|
||||
|
||||
@@ -54,7 +54,7 @@ public class StructureLoadCommand implements CommandTemplate {
|
||||
private Structure script;
|
||||
|
||||
@Inject
|
||||
private Platform main;
|
||||
private Platform platform;
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender) {
|
||||
|
||||
@@ -42,7 +42,7 @@ import com.dfsek.terra.api.util.vector.Vector3;
|
||||
))
|
||||
public class StructureLocateCommand implements CommandTemplate {
|
||||
@Inject
|
||||
private Platform main;
|
||||
private Platform platform;
|
||||
|
||||
@ArgumentTarget("structure")
|
||||
private ConfiguredStructure structure;
|
||||
@@ -58,7 +58,7 @@ public class StructureLocateCommand implements CommandTemplate {
|
||||
Player player = (Player) sender;
|
||||
|
||||
new Thread(new AsyncStructureFinder(player.world().getBiomeProvider(), structure,
|
||||
player.position().clone().multiply((1D / main.getTerraConfig().getBiomeSearchResolution())),
|
||||
player.position().clone().multiply((1D / platform.getTerraConfig().getBiomeSearchResolution())),
|
||||
player.world(), 0, radius, location -> {
|
||||
if(location != null) {
|
||||
sender.sendMessage(
|
||||
@@ -66,10 +66,10 @@ public class StructureLocateCommand implements CommandTemplate {
|
||||
location.getBlockX(), location.getBlockZ(),
|
||||
location.add(new Vector3(0, player.position().getY(), 0)).distance(player.position())));
|
||||
if(teleport) {
|
||||
main.runPossiblyUnsafeTask(
|
||||
platform.runPossiblyUnsafeTask(
|
||||
() -> player.position(new Vector3(location.getX(), player.position().getY(), location.getZ())));
|
||||
}
|
||||
} //else LangUtil.send("command.biome.unable-to-locate", sender);
|
||||
}, main), "Biome Location Thread").start();
|
||||
}, platform), "Biome Location Thread").start();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ import com.dfsek.terra.api.structure.Structure;
|
||||
|
||||
public class ScriptArgumentParser implements ArgumentParser<Structure> {
|
||||
@Inject
|
||||
private Platform main;
|
||||
private Platform platform;
|
||||
|
||||
@Override
|
||||
public Structure parse(CommandSender sender, String arg) {
|
||||
|
||||
@@ -10,7 +10,7 @@ import com.dfsek.terra.api.structure.configured.ConfiguredStructure;
|
||||
|
||||
public class StructureArgumentParser implements ArgumentParser<ConfiguredStructure> {
|
||||
@Inject
|
||||
private Platform main;
|
||||
private Platform platform;
|
||||
|
||||
@Override
|
||||
public ConfiguredStructure parse(CommandSender sender, String arg) {
|
||||
|
||||
@@ -13,7 +13,7 @@ import com.dfsek.terra.api.structure.Structure;
|
||||
|
||||
public class ScriptCompleter implements TabCompleter {
|
||||
@Inject
|
||||
private Platform main;
|
||||
private Platform platform;
|
||||
|
||||
@Override
|
||||
public List<String> complete(CommandSender sender) {
|
||||
|
||||
@@ -13,7 +13,7 @@ import com.dfsek.terra.api.structure.configured.ConfiguredStructure;
|
||||
|
||||
public class StructureCompleter implements TabCompleter {
|
||||
@Inject
|
||||
private Platform main;
|
||||
private Platform platform;
|
||||
|
||||
@Override
|
||||
public List<String> complete(CommandSender sender) {
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.dfsek.terra.addons.structure.structures.loot;
|
||||
|
||||
import com.dfsek.terra.api.Platform;
|
||||
|
||||
import net.jafama.FastMath;
|
||||
import org.json.simple.JSONArray;
|
||||
import org.json.simple.JSONObject;
|
||||
@@ -12,7 +14,6 @@ import com.dfsek.terra.addons.structure.structures.loot.functions.AmountFunction
|
||||
import com.dfsek.terra.addons.structure.structures.loot.functions.DamageFunction;
|
||||
import com.dfsek.terra.addons.structure.structures.loot.functions.EnchantFunction;
|
||||
import com.dfsek.terra.addons.structure.structures.loot.functions.LootFunction;
|
||||
import com.dfsek.terra.api.Platform;
|
||||
import com.dfsek.terra.api.inventory.Item;
|
||||
import com.dfsek.terra.api.inventory.ItemStack;
|
||||
|
||||
@@ -30,9 +31,9 @@ public class Entry {
|
||||
*
|
||||
* @param entry The JSON Object to instantiate from.
|
||||
*/
|
||||
public Entry(JSONObject entry, Platform main) {
|
||||
public Entry(JSONObject entry, Platform platform) {
|
||||
String id = entry.get("name").toString();
|
||||
this.item = main.getItemHandle().createItem(id);
|
||||
this.item = platform.getItemHandle().createItem(id);
|
||||
|
||||
long weight1;
|
||||
try {
|
||||
@@ -69,7 +70,7 @@ public class Entry {
|
||||
if(((JSONObject) function).containsKey("disabled_enchants"))
|
||||
disabled = (JSONArray) ((JSONObject) function).get("disabled_enchants");
|
||||
functions.add(
|
||||
new EnchantFunction(FastMath.toIntExact(minEnchant), FastMath.toIntExact(maxEnchant), disabled, main));
|
||||
new EnchantFunction(FastMath.toIntExact(minEnchant), FastMath.toIntExact(maxEnchant), disabled, platform));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,12 +27,12 @@ public class LootTableImpl implements com.dfsek.terra.api.structure.LootTable {
|
||||
*
|
||||
* @throws ParseException if malformed JSON is passed.
|
||||
*/
|
||||
public LootTableImpl(String json, Platform main) throws ParseException {
|
||||
public LootTableImpl(String json, Platform platform) throws ParseException {
|
||||
JSONParser jsonParser = new JSONParser();
|
||||
Object tableJSON = jsonParser.parse(json);
|
||||
JSONArray poolArray = (JSONArray) ((JSONObject) tableJSON).get("pools");
|
||||
for(Object pool : poolArray) {
|
||||
pools.add(new Pool((JSONObject) pool, main));
|
||||
pools.add(new Pool((JSONObject) pool, platform));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.dfsek.terra.addons.structure.structures.loot;
|
||||
|
||||
import com.dfsek.terra.api.Platform;
|
||||
|
||||
import net.jafama.FastMath;
|
||||
import org.json.simple.JSONArray;
|
||||
import org.json.simple.JSONObject;
|
||||
@@ -8,7 +10,6 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import com.dfsek.terra.api.Platform;
|
||||
import com.dfsek.terra.api.inventory.ItemStack;
|
||||
import com.dfsek.terra.api.util.collection.ProbabilityCollection;
|
||||
|
||||
@@ -26,7 +27,7 @@ public class Pool {
|
||||
*
|
||||
* @param pool The JSON Object to instantiate from.
|
||||
*/
|
||||
public Pool(JSONObject pool, Platform main) {
|
||||
public Pool(JSONObject pool, Platform platform) {
|
||||
entries = new ProbabilityCollection<>();
|
||||
Object amount = pool.get("rolls");
|
||||
if(amount instanceof Long) {
|
||||
@@ -38,7 +39,7 @@ public class Pool {
|
||||
}
|
||||
|
||||
for(Object entryJSON : (JSONArray) pool.get("entries")) {
|
||||
Entry entry = new Entry((JSONObject) entryJSON, main);
|
||||
Entry entry = new Entry((JSONObject) entryJSON, platform);
|
||||
entries.add(entry, FastMath.toIntExact(entry.getWeight()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.dfsek.terra.addons.structure.structures.loot.functions;
|
||||
|
||||
import com.dfsek.terra.api.Platform;
|
||||
|
||||
import net.jafama.FastMath;
|
||||
import org.json.simple.JSONArray;
|
||||
|
||||
@@ -8,7 +10,6 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import com.dfsek.terra.api.Platform;
|
||||
import com.dfsek.terra.api.inventory.ItemStack;
|
||||
import com.dfsek.terra.api.inventory.item.Enchantment;
|
||||
import com.dfsek.terra.api.inventory.item.ItemMeta;
|
||||
@@ -18,14 +19,14 @@ public class EnchantFunction implements LootFunction {
|
||||
private final int min;
|
||||
private final int max;
|
||||
private final JSONArray disabled;
|
||||
private final Platform main;
|
||||
private final Platform platform;
|
||||
|
||||
|
||||
public EnchantFunction(int min, int max, JSONArray disabled, Platform main) {
|
||||
public EnchantFunction(int min, int max, JSONArray disabled, Platform platform) {
|
||||
this.max = max;
|
||||
this.min = min;
|
||||
this.disabled = disabled;
|
||||
this.main = main;
|
||||
this.platform = platform;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -42,7 +43,7 @@ public class EnchantFunction implements LootFunction {
|
||||
|
||||
double enchant = (r.nextDouble() * (max - min)) + min;
|
||||
List<Enchantment> possible = new ArrayList<>();
|
||||
for(Enchantment ench : main.getItemHandle().getEnchantments()) {
|
||||
for(Enchantment ench : platform.getItemHandle().getEnchantments()) {
|
||||
if(ench.canEnchantItem(original) && (disabled == null || !this.disabled.contains(ench.getID()))) {
|
||||
possible.add(ench);
|
||||
}
|
||||
@@ -60,7 +61,7 @@ public class EnchantFunction implements LootFunction {
|
||||
try {
|
||||
meta.addEnchantment(chosen, FastMath.max(lvl, 1));
|
||||
} catch(IllegalArgumentException e) {
|
||||
main.logger().warning(
|
||||
platform.logger().warning(
|
||||
"Attempted to enchant " + original.getType() + " with " + chosen + " at level " + FastMath.max(lvl, 1) +
|
||||
", but an unexpected exception occurred! Usually this is caused by a misbehaving enchantment plugin.");
|
||||
}
|
||||
|
||||
@@ -19,26 +19,26 @@ import com.dfsek.terra.api.world.generator.GenerationStageProvider;
|
||||
@Author("Terra")
|
||||
public class FeatureGenerationAddon extends TerraAddon {
|
||||
@Inject
|
||||
private Platform main;
|
||||
private Platform platform;
|
||||
|
||||
@Override
|
||||
public void initialize() {
|
||||
main.getEventManager()
|
||||
.getHandler(FunctionalEventHandler.class)
|
||||
.register(this, ConfigPackPreLoadEvent.class)
|
||||
.then(event -> event.getPack()
|
||||
platform.getEventManager()
|
||||
.getHandler(FunctionalEventHandler.class)
|
||||
.register(this, ConfigPackPreLoadEvent.class)
|
||||
.then(event -> event.getPack()
|
||||
.getOrCreateRegistry(GenerationStageProvider.class)
|
||||
.register("FEATURE", pack -> new FeatureGenerationStage(main)))
|
||||
.failThrough();
|
||||
.register("FEATURE", pack -> new FeatureGenerationStage(platform)))
|
||||
.failThrough();
|
||||
|
||||
main.getEventManager()
|
||||
.getHandler(FunctionalEventHandler.class)
|
||||
.register(this, ConfigurationLoadEvent.class)
|
||||
.then(event -> {
|
||||
platform.getEventManager()
|
||||
.getHandler(FunctionalEventHandler.class)
|
||||
.register(this, ConfigurationLoadEvent.class)
|
||||
.then(event -> {
|
||||
if(event.is(TerraBiome.class)) {
|
||||
event.getLoadedObject(TerraBiome.class).getContext().put(event.load(new BiomeFeaturesTemplate()).get());
|
||||
}
|
||||
})
|
||||
.failThrough();
|
||||
.failThrough();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,16 +12,16 @@ import com.dfsek.terra.api.world.generator.GenerationStage;
|
||||
|
||||
|
||||
public class FeatureGenerationStage implements GenerationStage {
|
||||
private final Platform main;
|
||||
private final Platform platform;
|
||||
|
||||
public FeatureGenerationStage(Platform main) {
|
||||
this.main = main;
|
||||
public FeatureGenerationStage(Platform platform) {
|
||||
this.platform = platform;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("try")
|
||||
public void populate(World world, Chunk chunk) {
|
||||
try(ProfileFrame ignore = main.getProfiler().profile("feature")) {
|
||||
try(ProfileFrame ignore = platform.getProfiler().profile("feature")) {
|
||||
int cx = chunk.getX() << 4;
|
||||
int cz = chunk.getZ() << 4;
|
||||
long seed = world.getSeed();
|
||||
|
||||
@@ -17,17 +17,17 @@ import com.dfsek.terra.api.inject.annotations.Inject;
|
||||
@Author("Terra")
|
||||
public class YamlAddon extends TerraAddon {
|
||||
@Inject
|
||||
private Platform main;
|
||||
private Platform platform;
|
||||
|
||||
@Override
|
||||
public void initialize() {
|
||||
main.getEventManager()
|
||||
.getHandler(FunctionalEventHandler.class)
|
||||
.register(this, ConfigurationDiscoveryEvent.class)
|
||||
.then(event -> event.getLoader().open("", ".yml").thenEntries(entries -> entries.forEach(entry -> {
|
||||
main.getDebugLogger().info("Discovered config " + entry.getKey());
|
||||
platform.getEventManager()
|
||||
.getHandler(FunctionalEventHandler.class)
|
||||
.register(this, ConfigurationDiscoveryEvent.class)
|
||||
.then(event -> event.getLoader().open("", ".yml").thenEntries(entries -> entries.forEach(entry -> {
|
||||
platform.getDebugLogger().info("Discovered config " + entry.getKey());
|
||||
event.register(entry.getKey(), new YamlConfiguration(entry.getValue(), entry.getKey()));
|
||||
})))
|
||||
.failThrough();
|
||||
.failThrough();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,20 +25,20 @@ import com.dfsek.terra.api.structure.Structure;
|
||||
@Version("1.0.0")
|
||||
public class TerraScriptAddon extends TerraAddon {
|
||||
@Inject
|
||||
private Platform main;
|
||||
private Platform platform;
|
||||
|
||||
@Override
|
||||
public void initialize() {
|
||||
main.getEventManager()
|
||||
.getHandler(FunctionalEventHandler.class)
|
||||
.register(this, ConfigPackPreLoadEvent.class)
|
||||
.then(event -> {
|
||||
platform.getEventManager()
|
||||
.getHandler(FunctionalEventHandler.class)
|
||||
.register(this, ConfigPackPreLoadEvent.class)
|
||||
.then(event -> {
|
||||
CheckedRegistry<Structure> structureRegistry = event.getPack().getOrCreateRegistry(Structure.class);
|
||||
CheckedRegistry<LootTable> lootRegistry = event.getPack().getOrCreateRegistry(LootTable.class);
|
||||
event.getPack().getLoader().open("", ".tesf").thenEntries(entries -> {
|
||||
for(Map.Entry<String, InputStream> entry : entries) {
|
||||
try {
|
||||
StructureScript structureScript = new StructureScript(entry.getValue(), main, structureRegistry, lootRegistry,
|
||||
StructureScript structureScript = new StructureScript(entry.getValue(), platform, structureRegistry, lootRegistry,
|
||||
event.getPack().getRegistryFactory().create());
|
||||
structureRegistry.register(structureScript.getID(), structureScript);
|
||||
} catch(ParseException e) {
|
||||
@@ -47,6 +47,6 @@ public class TerraScriptAddon extends TerraAddon {
|
||||
}
|
||||
}).close();
|
||||
})
|
||||
.failThrough();
|
||||
.failThrough();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,13 +11,13 @@ import com.dfsek.terra.api.world.World;
|
||||
public class BufferedBlock implements BufferedItem {
|
||||
private final BlockState data;
|
||||
private final boolean overwrite;
|
||||
private final Platform main;
|
||||
private final Platform platform;
|
||||
private final boolean waterlog;
|
||||
|
||||
public BufferedBlock(BlockState data, boolean overwrite, Platform main, boolean waterlog) {
|
||||
public BufferedBlock(BlockState data, boolean overwrite, Platform platform, boolean waterlog) {
|
||||
this.data = data;
|
||||
this.overwrite = overwrite;
|
||||
this.main = main;
|
||||
this.platform = platform;
|
||||
this.waterlog = waterlog;
|
||||
}
|
||||
|
||||
@@ -32,8 +32,8 @@ public class BufferedBlock implements BufferedItem {
|
||||
world.setBlockData(origin, data);
|
||||
}
|
||||
} catch(RuntimeException e) {
|
||||
main.logger().severe("Failed to place block at location " + origin + ": " + e.getMessage());
|
||||
main.getDebugLogger().stack(e);
|
||||
platform.logger().severe("Failed to place block at location " + origin + ": " + e.getMessage());
|
||||
platform.getDebugLogger().stack(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,16 +12,16 @@ import com.dfsek.terra.api.world.World;
|
||||
public class BufferedEntity implements BufferedItem {
|
||||
|
||||
private final EntityType type;
|
||||
private final Platform main;
|
||||
private final Platform platform;
|
||||
|
||||
public BufferedEntity(EntityType type, Platform main) {
|
||||
public BufferedEntity(EntityType type, Platform platform) {
|
||||
this.type = type;
|
||||
this.main = main;
|
||||
this.platform = platform;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paste(Vector3 origin, World world) {
|
||||
Entity entity = world.spawnEntity(origin.clone().add(0.5, 0, 0.5), type);
|
||||
main.getEventManager().callEvent(new EntitySpawnEvent(entity.world().getConfig().getPack(), entity));
|
||||
platform.getEventManager().callEvent(new EntitySpawnEvent(entity.world().getConfig().getPack(), entity));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,12 +15,12 @@ import com.dfsek.terra.api.world.World;
|
||||
|
||||
public class BufferedLootApplication implements BufferedItem {
|
||||
private final LootTable table;
|
||||
private final Platform main;
|
||||
private final Platform platform;
|
||||
private final StructureScript structure;
|
||||
|
||||
public BufferedLootApplication(LootTable table, Platform main, StructureScript structure) {
|
||||
public BufferedLootApplication(LootTable table, Platform platform, StructureScript structure) {
|
||||
this.table = table;
|
||||
this.main = main;
|
||||
this.platform = platform;
|
||||
this.structure = structure;
|
||||
}
|
||||
|
||||
@@ -29,19 +29,19 @@ public class BufferedLootApplication implements BufferedItem {
|
||||
try {
|
||||
BlockEntity data = world.getBlockState(origin);
|
||||
if(!(data instanceof Container)) {
|
||||
main.logger().severe("Failed to place loot at " + origin + "; block " + data + " is not container.");
|
||||
platform.logger().severe("Failed to place loot at " + origin + "; block " + data + " is not container.");
|
||||
return;
|
||||
}
|
||||
Container container = (Container) data;
|
||||
|
||||
LootPopulateEvent event = new LootPopulateEvent(container, table, world.getConfig().getPack(), structure);
|
||||
main.getEventManager().callEvent(event);
|
||||
platform.getEventManager().callEvent(event);
|
||||
if(event.isCancelled()) return;
|
||||
|
||||
event.getTable().fillInventory(container.getInventory(), new Random(origin.hashCode()));
|
||||
data.update(false);
|
||||
} catch(Exception e) {
|
||||
main.logger().warning("Could not apply loot at " + origin + ": " + e.getMessage());
|
||||
platform.logger().warning("Could not apply loot at " + origin + ": " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,11 +8,11 @@ import com.dfsek.terra.api.world.World;
|
||||
|
||||
|
||||
public class BufferedStateManipulator implements BufferedItem {
|
||||
private final Platform main;
|
||||
private final Platform platform;
|
||||
private final String data;
|
||||
|
||||
public BufferedStateManipulator(Platform main, String state) {
|
||||
this.main = main;
|
||||
public BufferedStateManipulator(Platform platform, String state) {
|
||||
this.platform = platform;
|
||||
this.data = state;
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ public class BufferedStateManipulator implements BufferedItem {
|
||||
state.applyState(data);
|
||||
state.update(false);
|
||||
} catch(Exception e) {
|
||||
main.logger().warning("Could not apply BlockState at " + origin + ": " + e.getMessage());
|
||||
platform.logger().warning("Could not apply BlockState at " + origin + ": " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,10 +52,10 @@ public class StructureScript implements Structure {
|
||||
private final Block block;
|
||||
private final String id;
|
||||
private final Cache<Vector3, StructureBuffer> cache;
|
||||
private final Platform main;
|
||||
private final Platform platform;
|
||||
private String tempID;
|
||||
|
||||
public StructureScript(InputStream inputStream, Platform main, Registry<Structure> registry, Registry<LootTable> lootRegistry,
|
||||
public StructureScript(InputStream inputStream, Platform platform, Registry<Structure> registry, Registry<LootTable> lootRegistry,
|
||||
Registry<FunctionBuilder<?>> functionRegistry) throws ParseException {
|
||||
Parser parser;
|
||||
try {
|
||||
@@ -67,20 +67,20 @@ public class StructureScript implements Structure {
|
||||
functionRegistry.forEach(parser::registerFunction); // Register registry functions.
|
||||
|
||||
parser
|
||||
.registerFunction("block", new BlockFunctionBuilder(main))
|
||||
.registerFunction("debugBlock", new BlockFunctionBuilder(main))
|
||||
.registerFunction("check", new CheckFunctionBuilder(main))
|
||||
.registerFunction("structure", new StructureFunctionBuilder(registry, main))
|
||||
.registerFunction("block", new BlockFunctionBuilder(platform))
|
||||
.registerFunction("debugBlock", new BlockFunctionBuilder(platform))
|
||||
.registerFunction("check", new CheckFunctionBuilder(platform))
|
||||
.registerFunction("structure", new StructureFunctionBuilder(registry, platform))
|
||||
.registerFunction("randomInt", new RandomFunctionBuilder())
|
||||
.registerFunction("recursions", new RecursionsFunctionBuilder())
|
||||
.registerFunction("setMark", new SetMarkFunctionBuilder())
|
||||
.registerFunction("getMark", new GetMarkFunctionBuilder())
|
||||
.registerFunction("pull", new PullFunctionBuilder(main))
|
||||
.registerFunction("loot", new LootFunctionBuilder(main, lootRegistry, this))
|
||||
.registerFunction("entity", new EntityFunctionBuilder(main))
|
||||
.registerFunction("getBiome", new BiomeFunctionBuilder(main))
|
||||
.registerFunction("pull", new PullFunctionBuilder(platform))
|
||||
.registerFunction("loot", new LootFunctionBuilder(platform, lootRegistry, this))
|
||||
.registerFunction("entity", new EntityFunctionBuilder(platform))
|
||||
.registerFunction("getBiome", new BiomeFunctionBuilder(platform))
|
||||
.registerFunction("getBlock", new CheckBlockFunctionBuilder())
|
||||
.registerFunction("state", new StateFunctionBuilder(main))
|
||||
.registerFunction("state", new StateFunctionBuilder(platform))
|
||||
.registerFunction("setWaterlog", new UnaryBooleanFunctionBuilder((waterlog, args) -> args.setWaterlog(waterlog)))
|
||||
.registerFunction("originX", new ZeroArgFunctionBuilder<Number>(arguments -> arguments.getBuffer().getOrigin().getX(),
|
||||
Returnable.ReturnType.NUMBER))
|
||||
@@ -93,7 +93,7 @@ public class StructureScript implements Structure {
|
||||
.registerFunction("rotationDegrees", new ZeroArgFunctionBuilder<>(arguments -> arguments.getRotation().getDegrees(),
|
||||
Returnable.ReturnType.NUMBER))
|
||||
.registerFunction("print",
|
||||
new UnaryStringFunctionBuilder(string -> main.getDebugLogger().info("[" + tempID + "] " + string)))
|
||||
new UnaryStringFunctionBuilder(string -> platform.getDebugLogger().info("[" + tempID + "] " + string)))
|
||||
.registerFunction("abs", new UnaryNumberFunctionBuilder(number -> FastMath.abs(number.doubleValue())))
|
||||
.registerFunction("pow", new BinaryNumberFunctionBuilder(
|
||||
(number, number2) -> FastMath.pow(number.doubleValue(), number2.doubleValue())))
|
||||
@@ -113,21 +113,21 @@ public class StructureScript implements Structure {
|
||||
.registerFunction("min", new BinaryNumberFunctionBuilder(
|
||||
(number, number2) -> FastMath.min(number.doubleValue(), number2.doubleValue())));
|
||||
|
||||
if(!main.getTerraConfig().isDebugScript()) {
|
||||
if(!platform.getTerraConfig().isDebugScript()) {
|
||||
parser.ignoreFunction("debugBlock");
|
||||
}
|
||||
|
||||
block = parser.parse();
|
||||
this.id = parser.getID();
|
||||
tempID = id;
|
||||
this.main = main;
|
||||
this.cache = CacheBuilder.newBuilder().maximumSize(main.getTerraConfig().getStructureCache()).build();
|
||||
this.platform = platform;
|
||||
this.cache = CacheBuilder.newBuilder().maximumSize(platform.getTerraConfig().getStructureCache()).build();
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("try")
|
||||
public boolean generate(Vector3 location, World world, Chunk chunk, Random random, Rotation rotation) {
|
||||
try(ProfileFrame ignore = main.getProfiler().profile("terrascript_chunk:" + id)) {
|
||||
try(ProfileFrame ignore = platform.getProfiler().profile("terrascript_chunk:" + id)) {
|
||||
StructureBuffer buffer = computeBuffer(location, world, random, rotation);
|
||||
buffer.paste(location, chunk);
|
||||
return buffer.succeeded();
|
||||
@@ -137,7 +137,7 @@ public class StructureScript implements Structure {
|
||||
@Override
|
||||
@SuppressWarnings("try")
|
||||
public boolean generate(Buffer buffer, World world, Random random, Rotation rotation, int recursions) {
|
||||
try(ProfileFrame ignore = main.getProfiler().profile("terrascript_recursive:" + id)) {
|
||||
try(ProfileFrame ignore = platform.getProfiler().profile("terrascript_recursive:" + id)) {
|
||||
return applyBlock(new TerraImplementationArguments(buffer, rotation, random, world, recursions));
|
||||
}
|
||||
}
|
||||
@@ -145,7 +145,7 @@ public class StructureScript implements Structure {
|
||||
@Override
|
||||
@SuppressWarnings("try")
|
||||
public boolean generate(Vector3 location, World world, Random random, Rotation rotation) {
|
||||
try(ProfileFrame ignore = main.getProfiler().profile("terrascript_direct:" + id)) {
|
||||
try(ProfileFrame ignore = platform.getProfiler().profile("terrascript_direct:" + id)) {
|
||||
DirectBuffer buffer = new DirectBuffer(location, world);
|
||||
return applyBlock(new TerraImplementationArguments(buffer, rotation, random, world, 0));
|
||||
}
|
||||
@@ -153,7 +153,7 @@ public class StructureScript implements Structure {
|
||||
|
||||
@SuppressWarnings("try")
|
||||
public boolean test(Vector3 location, World world, Random random, Rotation rotation) {
|
||||
try(ProfileFrame ignore = main.getProfiler().profile("terrascript_test:" + id)) {
|
||||
try(ProfileFrame ignore = platform.getProfiler().profile("terrascript_test:" + id)) {
|
||||
StructureBuffer buffer = computeBuffer(location, world, random, rotation);
|
||||
return buffer.succeeded();
|
||||
}
|
||||
@@ -175,8 +175,8 @@ public class StructureScript implements Structure {
|
||||
try {
|
||||
return block.apply(arguments).getLevel() != Block.ReturnLevel.FAIL;
|
||||
} catch(RuntimeException e) {
|
||||
main.logger().severe("Failed to generate structure at " + arguments.getBuffer().getOrigin() + ": " + e.getMessage());
|
||||
main.getDebugLogger().stack(e);
|
||||
platform.logger().severe("Failed to generate structure at " + arguments.getBuffer().getOrigin() + ": " + e.getMessage());
|
||||
platform.getDebugLogger().stack(e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,16 +10,16 @@ import com.dfsek.terra.api.Platform;
|
||||
|
||||
|
||||
public class BiomeFunctionBuilder implements FunctionBuilder<BiomeFunction> {
|
||||
private final Platform main;
|
||||
private final Platform platform;
|
||||
|
||||
public BiomeFunctionBuilder(Platform main) {
|
||||
this.main = main;
|
||||
public BiomeFunctionBuilder(Platform platform) {
|
||||
this.platform = platform;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public BiomeFunction build(List<Returnable<?>> argumentList, Position position) {
|
||||
return new BiomeFunction(main, (Returnable<Number>) argumentList.get(0), (Returnable<Number>) argumentList.get(1),
|
||||
return new BiomeFunction(platform, (Returnable<Number>) argumentList.get(0), (Returnable<Number>) argumentList.get(1),
|
||||
(Returnable<Number>) argumentList.get(2), position);
|
||||
}
|
||||
|
||||
|
||||
@@ -13,10 +13,10 @@ import com.dfsek.terra.api.Platform;
|
||||
|
||||
|
||||
public class BlockFunctionBuilder implements FunctionBuilder<BlockFunction> {
|
||||
private final Platform main;
|
||||
private final Platform platform;
|
||||
|
||||
public BlockFunctionBuilder(Platform main) {
|
||||
this.main = main;
|
||||
public BlockFunctionBuilder(Platform platform) {
|
||||
this.platform = platform;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@@ -28,11 +28,11 @@ public class BlockFunctionBuilder implements FunctionBuilder<BlockFunction> {
|
||||
if(argumentList.get(3) instanceof StringConstant) {
|
||||
return new BlockFunction.Constant((Returnable<Number>) argumentList.get(0), (Returnable<Number>) argumentList.get(1),
|
||||
(Returnable<Number>) argumentList.get(2), (StringConstant) argumentList.get(3),
|
||||
booleanReturnable, main, position);
|
||||
booleanReturnable, platform, position);
|
||||
}
|
||||
return new BlockFunction((Returnable<Number>) argumentList.get(0), (Returnable<Number>) argumentList.get(1),
|
||||
(Returnable<Number>) argumentList.get(2), (Returnable<String>) argumentList.get(3), booleanReturnable,
|
||||
main, position);
|
||||
platform, position);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -11,16 +11,16 @@ import com.dfsek.terra.api.Platform;
|
||||
|
||||
|
||||
public class CheckFunctionBuilder implements FunctionBuilder<CheckFunction> {
|
||||
private final Platform main;
|
||||
private final Platform platform;
|
||||
|
||||
public CheckFunctionBuilder(Platform main) {
|
||||
this.main = main;
|
||||
public CheckFunctionBuilder(Platform platform) {
|
||||
this.platform = platform;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public CheckFunction build(List<Returnable<?>> argumentList, Position position) throws ParseException {
|
||||
return new CheckFunction(main, (Returnable<Number>) argumentList.get(0), (Returnable<Number>) argumentList.get(1),
|
||||
return new CheckFunction(platform, (Returnable<Number>) argumentList.get(0), (Returnable<Number>) argumentList.get(1),
|
||||
(Returnable<Number>) argumentList.get(2), position);
|
||||
}
|
||||
|
||||
|
||||
@@ -11,17 +11,17 @@ import com.dfsek.terra.api.Platform;
|
||||
|
||||
|
||||
public class EntityFunctionBuilder implements FunctionBuilder<EntityFunction> {
|
||||
private final Platform main;
|
||||
private final Platform platform;
|
||||
|
||||
public EntityFunctionBuilder(Platform main) {
|
||||
this.main = main;
|
||||
public EntityFunctionBuilder(Platform platform) {
|
||||
this.platform = platform;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public EntityFunction build(List<Returnable<?>> argumentList, Position position) throws ParseException {
|
||||
return new EntityFunction((Returnable<Number>) argumentList.get(0), (Returnable<Number>) argumentList.get(1),
|
||||
(Returnable<Number>) argumentList.get(2), (Returnable<String>) argumentList.get(3), main, position);
|
||||
(Returnable<Number>) argumentList.get(2), (Returnable<String>) argumentList.get(3), platform, position);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -13,12 +13,12 @@ import com.dfsek.terra.api.structure.LootTable;
|
||||
|
||||
|
||||
public class LootFunctionBuilder implements FunctionBuilder<LootFunction> {
|
||||
private final Platform main;
|
||||
private final Platform platform;
|
||||
private final Registry<LootTable> registry;
|
||||
private final StructureScript script;
|
||||
|
||||
public LootFunctionBuilder(Platform main, Registry<LootTable> registry, StructureScript script) {
|
||||
this.main = main;
|
||||
public LootFunctionBuilder(Platform platform, Registry<LootTable> registry, StructureScript script) {
|
||||
this.platform = platform;
|
||||
this.registry = registry;
|
||||
this.script = script;
|
||||
}
|
||||
@@ -27,7 +27,7 @@ public class LootFunctionBuilder implements FunctionBuilder<LootFunction> {
|
||||
@Override
|
||||
public LootFunction build(List<Returnable<?>> argumentList, Position position) {
|
||||
return new LootFunction(registry, (Returnable<Number>) argumentList.get(0), (Returnable<Number>) argumentList.get(1),
|
||||
(Returnable<Number>) argumentList.get(2), (Returnable<String>) argumentList.get(3), main, position, script);
|
||||
(Returnable<Number>) argumentList.get(2), (Returnable<String>) argumentList.get(3), platform, position, script);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -11,17 +11,17 @@ import com.dfsek.terra.api.Platform;
|
||||
|
||||
|
||||
public class PullFunctionBuilder implements FunctionBuilder<PullFunction> {
|
||||
private final Platform main;
|
||||
private final Platform platform;
|
||||
|
||||
public PullFunctionBuilder(Platform main) {
|
||||
this.main = main;
|
||||
public PullFunctionBuilder(Platform platform) {
|
||||
this.platform = platform;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public PullFunction build(List<Returnable<?>> argumentList, Position position) throws ParseException {
|
||||
return new PullFunction((Returnable<Number>) argumentList.get(0), (Returnable<Number>) argumentList.get(1),
|
||||
(Returnable<Number>) argumentList.get(2), (Returnable<String>) argumentList.get(3), main, position);
|
||||
(Returnable<Number>) argumentList.get(2), (Returnable<String>) argumentList.get(3), platform, position);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -11,10 +11,10 @@ import com.dfsek.terra.api.Platform;
|
||||
|
||||
|
||||
public class StateFunctionBuilder implements FunctionBuilder<StateFunction> {
|
||||
private final Platform main;
|
||||
private final Platform platform;
|
||||
|
||||
public StateFunctionBuilder(Platform main) {
|
||||
this.main = main;
|
||||
public StateFunctionBuilder(Platform platform) {
|
||||
this.platform = platform;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@@ -22,7 +22,7 @@ public class StateFunctionBuilder implements FunctionBuilder<StateFunction> {
|
||||
public StateFunction build(List<Returnable<?>> argumentList, Position position) throws ParseException {
|
||||
if(argumentList.size() < 4) throw new ParseException("Expected data", position);
|
||||
return new StateFunction((Returnable<Number>) argumentList.get(0), (Returnable<Number>) argumentList.get(1),
|
||||
(Returnable<Number>) argumentList.get(2), (Returnable<String>) argumentList.get(3), main, position);
|
||||
(Returnable<Number>) argumentList.get(2), (Returnable<String>) argumentList.get(3), platform, position);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -15,11 +15,11 @@ import com.dfsek.terra.api.structure.Structure;
|
||||
|
||||
public class StructureFunctionBuilder implements FunctionBuilder<StructureFunction> {
|
||||
private final Registry<Structure> registry;
|
||||
private final Platform main;
|
||||
private final Platform platform;
|
||||
|
||||
public StructureFunctionBuilder(Registry<Structure> registry, Platform main) {
|
||||
public StructureFunctionBuilder(Registry<Structure> registry, Platform platform) {
|
||||
this.registry = registry;
|
||||
this.main = main;
|
||||
this.platform = platform;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@@ -30,7 +30,7 @@ public class StructureFunctionBuilder implements FunctionBuilder<StructureFuncti
|
||||
return new StructureFunction((Returnable<Number>) argumentList.remove(0), (Returnable<Number>) argumentList.remove(0),
|
||||
(Returnable<Number>) argumentList.remove(0), (Returnable<String>) argumentList.remove(0),
|
||||
argumentList.stream().map(item -> ((Returnable<String>) item)).collect(Collectors.toList()), registry,
|
||||
position, main);
|
||||
position, platform);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.dfsek.terra.addons.terrascript.script.functions;
|
||||
|
||||
import com.dfsek.terra.api.Platform;
|
||||
|
||||
import net.jafama.FastMath;
|
||||
|
||||
import java.util.Map;
|
||||
@@ -10,7 +12,6 @@ import com.dfsek.terra.addons.terrascript.parser.lang.functions.Function;
|
||||
import com.dfsek.terra.addons.terrascript.parser.lang.variables.Variable;
|
||||
import com.dfsek.terra.addons.terrascript.script.TerraImplementationArguments;
|
||||
import com.dfsek.terra.addons.terrascript.tokenizer.Position;
|
||||
import com.dfsek.terra.api.Platform;
|
||||
import com.dfsek.terra.api.util.RotationUtil;
|
||||
import com.dfsek.terra.api.util.vector.Vector2;
|
||||
import com.dfsek.terra.api.util.vector.Vector3;
|
||||
@@ -18,13 +19,13 @@ import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
||||
|
||||
|
||||
public class BiomeFunction implements Function<String> {
|
||||
private final Platform main;
|
||||
private final Platform platform;
|
||||
private final Returnable<Number> x, y, z;
|
||||
private final Position position;
|
||||
|
||||
|
||||
public BiomeFunction(Platform main, Returnable<Number> x, Returnable<Number> y, Returnable<Number> z, Position position) {
|
||||
this.main = main;
|
||||
public BiomeFunction(Platform platform, Returnable<Number> x, Returnable<Number> y, Returnable<Number> z, Position position) {
|
||||
this.platform = platform;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.dfsek.terra.addons.terrascript.script.functions;
|
||||
|
||||
import com.dfsek.terra.api.Platform;
|
||||
|
||||
import net.jafama.FastMath;
|
||||
|
||||
import java.util.HashMap;
|
||||
@@ -13,7 +15,6 @@ import com.dfsek.terra.addons.terrascript.parser.lang.functions.Function;
|
||||
import com.dfsek.terra.addons.terrascript.parser.lang.variables.Variable;
|
||||
import com.dfsek.terra.addons.terrascript.script.TerraImplementationArguments;
|
||||
import com.dfsek.terra.addons.terrascript.tokenizer.Position;
|
||||
import com.dfsek.terra.api.Platform;
|
||||
import com.dfsek.terra.api.block.state.BlockState;
|
||||
import com.dfsek.terra.api.util.RotationUtil;
|
||||
import com.dfsek.terra.api.util.vector.Vector2;
|
||||
@@ -23,19 +24,19 @@ import com.dfsek.terra.api.util.vector.Vector3;
|
||||
public class BlockFunction implements Function<Void> {
|
||||
protected final Returnable<Number> x, y, z;
|
||||
protected final Returnable<String> blockData;
|
||||
protected final Platform main;
|
||||
protected final Platform platform;
|
||||
private final Map<String, BlockState> data = new HashMap<>();
|
||||
private final Returnable<Boolean> overwrite;
|
||||
private final Position position;
|
||||
|
||||
public BlockFunction(Returnable<Number> x, Returnable<Number> y, Returnable<Number> z, Returnable<String> blockData,
|
||||
Returnable<Boolean> overwrite, Platform main, Position position) {
|
||||
Returnable<Boolean> overwrite, Platform platform, Position position) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
this.blockData = blockData;
|
||||
this.overwrite = overwrite;
|
||||
this.main = main;
|
||||
this.platform = platform;
|
||||
this.position = position;
|
||||
}
|
||||
|
||||
@@ -66,13 +67,13 @@ public class BlockFunction implements Function<Void> {
|
||||
|
||||
RotationUtil.rotateBlockData(rot, arguments.getRotation().inverse());
|
||||
arguments.getBuffer().addItem(
|
||||
new BufferedBlock(rot, overwrite.apply(implementationArguments, variableMap), main, arguments.isWaterlog()),
|
||||
new BufferedBlock(rot, overwrite.apply(implementationArguments, variableMap), platform, arguments.isWaterlog()),
|
||||
new Vector3(FastMath.roundToInt(xz.getX()), y.apply(implementationArguments, variableMap).doubleValue(),
|
||||
FastMath.roundToInt(xz.getZ())));
|
||||
}
|
||||
|
||||
protected BlockState getBlockState(ImplementationArguments arguments, Map<String, Variable<?>> variableMap) {
|
||||
return data.computeIfAbsent(blockData.apply(arguments, variableMap), main.getWorldHandle()::createBlockData);
|
||||
return data.computeIfAbsent(blockData.apply(arguments, variableMap), platform.getWorldHandle()::createBlockData);
|
||||
}
|
||||
|
||||
|
||||
@@ -80,9 +81,9 @@ public class BlockFunction implements Function<Void> {
|
||||
private final BlockState state;
|
||||
|
||||
public Constant(Returnable<Number> x, Returnable<Number> y, Returnable<Number> z, StringConstant blockData,
|
||||
Returnable<Boolean> overwrite, Platform main, Position position) {
|
||||
super(x, y, z, blockData, overwrite, main, position);
|
||||
this.state = main.getWorldHandle().createBlockData(blockData.getConstant());
|
||||
Returnable<Boolean> overwrite, Platform platform, Position position) {
|
||||
super(x, y, z, blockData, overwrite, platform, position);
|
||||
this.state = platform.getWorldHandle().createBlockData(blockData.getConstant());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -19,12 +19,12 @@ import com.dfsek.terra.api.world.generator.SamplerCache;
|
||||
|
||||
|
||||
public class CheckFunction implements Function<String> {
|
||||
private final Platform main;
|
||||
private final Platform platform;
|
||||
private final Returnable<Number> x, y, z;
|
||||
private final Position position;
|
||||
|
||||
public CheckFunction(Platform main, Returnable<Number> x, Returnable<Number> y, Returnable<Number> z, Position position) {
|
||||
this.main = main;
|
||||
public CheckFunction(Platform platform, Returnable<Number> x, Returnable<Number> y, Returnable<Number> z, Position position) {
|
||||
this.platform = platform;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
|
||||
@@ -22,15 +22,15 @@ public class EntityFunction implements Function<Void> {
|
||||
private final EntityType data;
|
||||
private final Returnable<Number> x, y, z;
|
||||
private final Position position;
|
||||
private final Platform main;
|
||||
private final Platform platform;
|
||||
|
||||
public EntityFunction(Returnable<Number> x, Returnable<Number> y, Returnable<Number> z, Returnable<String> data, Platform main,
|
||||
public EntityFunction(Returnable<Number> x, Returnable<Number> y, Returnable<Number> z, Returnable<String> data, Platform platform,
|
||||
Position position) throws ParseException {
|
||||
this.position = position;
|
||||
this.main = main;
|
||||
this.platform = platform;
|
||||
if(!(data instanceof ConstantExpression)) throw new ParseException("Entity data must be constant", data.getPosition());
|
||||
|
||||
this.data = main.getWorldHandle().getEntity(((ConstantExpression<String>) data).getConstant());
|
||||
this.data = platform.getWorldHandle().getEntity(((ConstantExpression<String>) data).getConstant());
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
@@ -44,7 +44,7 @@ public class EntityFunction implements Function<Void> {
|
||||
|
||||
RotationUtil.rotateVector(xz, arguments.getRotation());
|
||||
|
||||
arguments.getBuffer().addItem(new BufferedEntity(data, main),
|
||||
arguments.getBuffer().addItem(new BufferedEntity(data, platform),
|
||||
new Vector3(xz.getX(), y.apply(implementationArguments, variableMap).doubleValue(), xz.getZ()));
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -25,18 +25,18 @@ public class LootFunction implements Function<Void> {
|
||||
private final Returnable<String> data;
|
||||
private final Returnable<Number> x, y, z;
|
||||
private final Position position;
|
||||
private final Platform main;
|
||||
private final Platform platform;
|
||||
private final StructureScript script;
|
||||
|
||||
public LootFunction(Registry<LootTable> registry, Returnable<Number> x, Returnable<Number> y, Returnable<Number> z,
|
||||
Returnable<String> data, Platform main, Position position, StructureScript script) {
|
||||
Returnable<String> data, Platform platform, Position position, StructureScript script) {
|
||||
this.registry = registry;
|
||||
this.position = position;
|
||||
this.data = data;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
this.main = main;
|
||||
this.platform = platform;
|
||||
this.script = script;
|
||||
}
|
||||
|
||||
@@ -52,11 +52,11 @@ public class LootFunction implements Function<Void> {
|
||||
LootTable table = registry.get(id);
|
||||
|
||||
if(table == null) {
|
||||
main.logger().severe("No such loot table " + id);
|
||||
platform.logger().severe("No such loot table " + id);
|
||||
return null;
|
||||
}
|
||||
|
||||
arguments.getBuffer().addItem(new BufferedLootApplication(table, main, script),
|
||||
arguments.getBuffer().addItem(new BufferedLootApplication(table, platform, script),
|
||||
new Vector3(FastMath.roundToInt(xz.getX()), y.apply(implementationArguments, variableMap).intValue(),
|
||||
FastMath.roundToInt(xz.getZ())));
|
||||
return null;
|
||||
|
||||
@@ -25,12 +25,12 @@ public class PullFunction implements Function<Void> {
|
||||
private final Returnable<Number> x, y, z;
|
||||
private final Position position;
|
||||
|
||||
public PullFunction(Returnable<Number> x, Returnable<Number> y, Returnable<Number> z, Returnable<String> data, Platform main,
|
||||
public PullFunction(Returnable<Number> x, Returnable<Number> y, Returnable<Number> z, Returnable<String> data, Platform platform,
|
||||
Position position) throws ParseException {
|
||||
this.position = position;
|
||||
if(!(data instanceof ConstantExpression)) throw new ParseException("Block data must be constant", data.getPosition());
|
||||
|
||||
this.data = main.getWorldHandle().createBlockData(((ConstantExpression<String>) data).getConstant());
|
||||
this.data = platform.getWorldHandle().createBlockData(((ConstantExpression<String>) data).getConstant());
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
|
||||
@@ -21,12 +21,12 @@ public class StateFunction implements Function<Void> {
|
||||
private final Returnable<String> data;
|
||||
private final Returnable<Number> x, y, z;
|
||||
private final Position position;
|
||||
private final Platform main;
|
||||
private final Platform platform;
|
||||
|
||||
public StateFunction(Returnable<Number> x, Returnable<Number> y, Returnable<Number> z, Returnable<String> data, Platform main,
|
||||
public StateFunction(Returnable<Number> x, Returnable<Number> y, Returnable<Number> z, Returnable<String> data, Platform platform,
|
||||
Position position) {
|
||||
this.position = position;
|
||||
this.main = main;
|
||||
this.platform = platform;
|
||||
this.data = data;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
@@ -40,7 +40,7 @@ public class StateFunction implements Function<Void> {
|
||||
z.apply(implementationArguments, variableMap).doubleValue());
|
||||
RotationUtil.rotateVector(xz, arguments.getRotation());
|
||||
|
||||
arguments.getBuffer().addItem(new BufferedStateManipulator(main, data.apply(implementationArguments, variableMap)),
|
||||
arguments.getBuffer().addItem(new BufferedStateManipulator(platform, data.apply(implementationArguments, variableMap)),
|
||||
new Vector3(FastMath.roundToInt(xz.getX()), y.apply(implementationArguments, variableMap).intValue(),
|
||||
FastMath.roundToInt(xz.getZ())));
|
||||
return null;
|
||||
|
||||
@@ -26,18 +26,18 @@ public class StructureFunction implements Function<Boolean> {
|
||||
private final Returnable<String> id;
|
||||
private final Returnable<Number> x, y, z;
|
||||
private final Position position;
|
||||
private final Platform main;
|
||||
private final Platform platform;
|
||||
private final List<Returnable<String>> rotations;
|
||||
|
||||
public StructureFunction(Returnable<Number> x, Returnable<Number> y, Returnable<Number> z, Returnable<String> id,
|
||||
List<Returnable<String>> rotations, Registry<Structure> registry, Position position, Platform main) {
|
||||
List<Returnable<String>> rotations, Registry<Structure> registry, Position position, Platform platform) {
|
||||
this.registry = registry;
|
||||
this.id = id;
|
||||
this.position = position;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
this.main = main;
|
||||
this.platform = platform;
|
||||
this.rotations = rotations;
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ public class StructureFunction implements Function<Boolean> {
|
||||
public Boolean apply(ImplementationArguments implementationArguments, Map<String, Variable<?>> variableMap) {
|
||||
TerraImplementationArguments arguments = (TerraImplementationArguments) implementationArguments;
|
||||
|
||||
if(arguments.getRecursions() > main.getTerraConfig().getMaxRecursion())
|
||||
if(arguments.getRecursions() > platform.getTerraConfig().getMaxRecursion())
|
||||
throw new RuntimeException("Structure recursion too deep: " + arguments.getRecursions());
|
||||
|
||||
Vector2 xz = new Vector2(x.apply(implementationArguments, variableMap).doubleValue(),
|
||||
@@ -61,7 +61,7 @@ public class StructureFunction implements Function<Boolean> {
|
||||
String app = id.apply(implementationArguments, variableMap);
|
||||
Structure script = registry.get(app);
|
||||
if(script == null) {
|
||||
main.logger().severe("No such structure " + app);
|
||||
platform.logger().severe("No such structure " + app);
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ public class StructureFunction implements Function<Boolean> {
|
||||
try {
|
||||
rotation1 = Rotation.valueOf(rotString);
|
||||
} catch(IllegalArgumentException e) {
|
||||
main.logger().severe("Invalid rotation " + rotString);
|
||||
platform.logger().severe("Invalid rotation " + rotString);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ import com.dfsek.terra.api.registry.CheckedRegistry;
|
||||
public interface AddonLoader {
|
||||
/**
|
||||
* Load all addons.
|
||||
* @param main TerraPlugin instance.
|
||||
* @param platform TerraPlugin instance.
|
||||
*/
|
||||
void load(Platform main, CheckedRegistry<Addon> addons);
|
||||
void load(Platform platform, CheckedRegistry<Addon> addons);
|
||||
}
|
||||
|
||||
@@ -7,5 +7,5 @@ import com.dfsek.terra.api.Platform;
|
||||
|
||||
|
||||
public interface ConfigFactory<C extends ConfigTemplate, O> {
|
||||
O build(C config, Platform main) throws LoadException;
|
||||
O build(C config, Platform platform) throws LoadException;
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ import com.dfsek.terra.api.util.reflection.TypeKey;
|
||||
public interface ConfigType<T extends AbstractableTemplate, R> {
|
||||
Supplier<OpenRegistry<R>> registrySupplier(ConfigPack pack);
|
||||
|
||||
T getTemplate(ConfigPack pack, Platform main);
|
||||
T getTemplate(ConfigPack pack, Platform platform);
|
||||
|
||||
ConfigFactory<T, R> getFactory();
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import com.dfsek.terra.api.Platform;
|
||||
|
||||
|
||||
public interface PluginConfig {
|
||||
void load(Platform main);
|
||||
void load(Platform platform);
|
||||
|
||||
boolean dumpDefaultConfig();
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ public interface ChunkGenerator {
|
||||
|
||||
ConfigPack getConfigPack();
|
||||
|
||||
Platform getMain();
|
||||
Platform getPlatform();
|
||||
|
||||
List<GenerationStage> getGenerationStages();
|
||||
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
package com.dfsek.terra;
|
||||
|
||||
import com.dfsek.tectonic.loading.TypeRegistry;
|
||||
|
||||
import com.dfsek.terra.api.Platform;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.yaml.snakeyaml.Yaml;
|
||||
@@ -17,7 +20,6 @@ import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
import com.dfsek.terra.api.util.Logger;
|
||||
import com.dfsek.terra.api.Platform;
|
||||
import com.dfsek.terra.api.addon.TerraAddon;
|
||||
import com.dfsek.terra.api.command.CommandManager;
|
||||
import com.dfsek.terra.api.command.exception.MalformedCommandException;
|
||||
|
||||
@@ -12,12 +12,12 @@ import com.dfsek.terra.api.inject.annotations.Inject;
|
||||
)
|
||||
public class AddonsCommand implements CommandTemplate {
|
||||
@Inject
|
||||
private Platform main;
|
||||
private Platform platform;
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender) {
|
||||
sender.sendMessage("Installed Addons:");
|
||||
main.getAddons().forEach(
|
||||
platform.getAddons().forEach(
|
||||
addon -> sender.sendMessage(" - " + addon.getName() + " v" + addon.getVersion() + " by " + addon.getAuthor()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ import com.dfsek.terra.api.inject.annotations.Inject;
|
||||
)
|
||||
public class GetBlockCommand implements CommandTemplate {
|
||||
@Inject
|
||||
private Platform main;
|
||||
private Platform platform;
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender) {
|
||||
|
||||
@@ -15,11 +15,11 @@ import com.dfsek.terra.config.lang.LangUtil;
|
||||
)
|
||||
public class PacksCommand implements CommandTemplate {
|
||||
@Inject
|
||||
private Platform main;
|
||||
private Platform platform;
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender) {
|
||||
CheckedRegistry<ConfigPack> registry = main.getConfigRegistry();
|
||||
CheckedRegistry<ConfigPack> registry = platform.getConfigRegistry();
|
||||
|
||||
if(registry.entries().size() == 0) {
|
||||
LangUtil.send("command.packs.none", sender);
|
||||
|
||||
@@ -13,11 +13,11 @@ import com.dfsek.terra.config.lang.LangUtil;
|
||||
)
|
||||
public class ReloadCommand implements CommandTemplate {
|
||||
@Inject
|
||||
private Platform main;
|
||||
private Platform platform;
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender) {
|
||||
if(!main.reload()) {
|
||||
if(!platform.reload()) {
|
||||
LangUtil.send("command.reload-error", sender);
|
||||
} else {
|
||||
LangUtil.send("command.reload", sender);
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.dfsek.terra.commands;
|
||||
|
||||
import com.dfsek.terra.api.Platform;
|
||||
|
||||
import net.jafama.FastMath;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
@@ -12,7 +14,6 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.dfsek.terra.api.Platform;
|
||||
import com.dfsek.terra.api.command.CommandManager;
|
||||
import com.dfsek.terra.api.command.CommandTemplate;
|
||||
import com.dfsek.terra.api.command.annotation.Argument;
|
||||
@@ -41,11 +42,11 @@ import com.dfsek.terra.inject.InjectorImpl;
|
||||
public class TerraCommandManager implements CommandManager {
|
||||
private final Map<String, CommandHolder> commands = new HashMap<>();
|
||||
private final InjectorImpl<Platform> pluginInjector;
|
||||
private final Platform main;
|
||||
private final Platform platform;
|
||||
|
||||
public TerraCommandManager(Platform main) {
|
||||
this.main = main;
|
||||
this.pluginInjector = new InjectorImpl<>(main);
|
||||
public TerraCommandManager(Platform platform) {
|
||||
this.platform = platform;
|
||||
this.pluginInjector = new InjectorImpl<>(platform);
|
||||
pluginInjector.addExplicitTarget(Platform.class);
|
||||
}
|
||||
|
||||
@@ -81,7 +82,7 @@ public class TerraCommandManager implements CommandManager {
|
||||
private void execute(CommandHolder commandHolder, CommandSender sender, List<String> args) throws CommandException {
|
||||
Class<? extends CommandTemplate> commandClass = commandHolder.clazz;
|
||||
|
||||
if(commandClass.isAnnotationPresent(DebugCommand.class) && !main.getTerraConfig().isDebugCommands()) {
|
||||
if(commandClass.isAnnotationPresent(DebugCommand.class) && !platform.getTerraConfig().isDebugCommands()) {
|
||||
sender.sendMessage("Command must be executed with debug commands enabled.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -13,11 +13,11 @@ import com.dfsek.terra.config.lang.LangUtil;
|
||||
)
|
||||
public class VersionCommand implements CommandTemplate {
|
||||
@Inject
|
||||
private Platform main;
|
||||
private Platform platform;
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender) {
|
||||
String terraVersion = main.getVersion();
|
||||
LangUtil.send("command.version", sender, terraVersion, main.platformName());
|
||||
String terraVersion = platform.getVersion();
|
||||
LangUtil.send("command.version", sender, terraVersion, platform.platformName());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,13 +12,13 @@ import com.dfsek.terra.api.inject.annotations.Inject;
|
||||
@DebugCommand
|
||||
public class ProfileQueryCommand implements CommandTemplate {
|
||||
@Inject
|
||||
private Platform main;
|
||||
private Platform platform;
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender) {
|
||||
StringBuilder data = new StringBuilder("Terra Profiler data dump: \n");
|
||||
main.getProfiler().getTimings().forEach((id, timings) -> data.append(id).append(": ").append(timings.toString()).append('\n'));
|
||||
main.logger().info(data.toString());
|
||||
platform.getProfiler().getTimings().forEach((id, timings) -> data.append(id).append(": ").append(timings.toString()).append('\n'));
|
||||
platform.logger().info(data.toString());
|
||||
sender.sendMessage("Profiler data dumped to console.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,11 +12,11 @@ import com.dfsek.terra.api.inject.annotations.Inject;
|
||||
@DebugCommand
|
||||
public class ProfileResetCommand implements CommandTemplate {
|
||||
@Inject
|
||||
private Platform main;
|
||||
private Platform platform;
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender) {
|
||||
main.getProfiler().reset();
|
||||
platform.getProfiler().reset();
|
||||
sender.sendMessage("Profiler reset.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,11 +12,11 @@ import com.dfsek.terra.api.inject.annotations.Inject;
|
||||
@DebugCommand
|
||||
public class ProfileStartCommand implements CommandTemplate {
|
||||
@Inject
|
||||
private Platform main;
|
||||
private Platform platform;
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender) {
|
||||
main.getProfiler().start();
|
||||
platform.getProfiler().start();
|
||||
sender.sendMessage("Profiling enabled.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,11 +12,11 @@ import com.dfsek.terra.api.inject.annotations.Inject;
|
||||
@DebugCommand
|
||||
public class ProfileStopCommand implements CommandTemplate {
|
||||
@Inject
|
||||
private Platform main;
|
||||
private Platform platform;
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender) {
|
||||
main.getProfiler().stop();
|
||||
platform.getProfiler().stop();
|
||||
sender.sendMessage("Profiling disabled.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,10 +19,10 @@ import com.dfsek.terra.config.loaders.RangeLoader;
|
||||
|
||||
|
||||
public class GenericLoaders implements LoaderRegistrar {
|
||||
private final Platform main;
|
||||
private final Platform platform;
|
||||
|
||||
public GenericLoaders(Platform main) {
|
||||
this.main = main;
|
||||
public GenericLoaders(Platform platform) {
|
||||
this.platform = platform;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -32,11 +32,11 @@ public class GenericLoaders implements LoaderRegistrar {
|
||||
.registerLoader(MaterialSet.class, new MaterialSetLoader())
|
||||
.registerLoader(LinkedHashMap.class, new LinkedHashMapLoader());
|
||||
|
||||
if(main != null) {
|
||||
registry.registerLoader(TerraAddon.class, main.getAddons())
|
||||
if(platform != null) {
|
||||
registry.registerLoader(TerraAddon.class, platform.getAddons())
|
||||
.registerLoader(BlockType.class,
|
||||
(t, object, cf) -> main.getWorldHandle().createBlockData((String) object).getBlockType())
|
||||
.registerLoader(BlockState.class, (t, object, cf) -> main.getWorldHandle().createBlockData((String) object));
|
||||
(t, object, cf) -> platform.getWorldHandle().createBlockData((String) object).getBlockType())
|
||||
.registerLoader(BlockState.class, (t, object, cf) -> platform.getWorldHandle().createBlockData((String) object));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,10 +76,10 @@ public class PluginConfigImpl implements ConfigTemplate, com.dfsek.terra.api.con
|
||||
private int maxRecursion = 1000;
|
||||
|
||||
@Override
|
||||
public void load(Platform main) {
|
||||
Logger logger = main.logger();
|
||||
public void load(Platform platform) {
|
||||
Logger logger = platform.logger();
|
||||
logger.info("Loading config values");
|
||||
try(FileInputStream file = new FileInputStream(new File(main.getDataFolder(), "config.yml"))) {
|
||||
try(FileInputStream file = new FileInputStream(new File(platform.getDataFolder(), "config.yml"))) {
|
||||
ConfigLoader loader = new ConfigLoader();
|
||||
loader.load(this, new YamlConfiguration(file, "config.yml"));
|
||||
} catch(ConfigException | IOException | UncheckedIOException e) {
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user