mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-04-12 18:56:04 +00:00
Merge remote-tracking branch 'origin/ver/6.0.0' into architecture/slf4j-logging
# Conflicts: # common/addons/chunk-generator-noise-3d/src/main/java/com/dfsek/terra/addons/chunkgenerator/generation/generators/NoiseChunkGenerator3D.java # common/addons/config-structure/src/main/java/com/dfsek/terra/addons/structure/command/structure/StructureExportCommand.java # common/addons/config-structure/src/main/java/com/dfsek/terra/addons/structure/structures/loot/functions/EnchantFunction.java # common/addons/language-yaml/src/main/java/com/dfsek/terra/addons/yaml/YamlAddon.java # common/addons/structure-terrascript-loader/src/main/java/com/dfsek/terra/addons/terrascript/buffer/items/BufferedBlock.java # common/addons/structure-terrascript-loader/src/main/java/com/dfsek/terra/addons/terrascript/buffer/items/BufferedLootApplication.java # common/addons/structure-terrascript-loader/src/main/java/com/dfsek/terra/addons/terrascript/buffer/items/BufferedStateManipulator.java # common/addons/structure-terrascript-loader/src/main/java/com/dfsek/terra/addons/terrascript/script/StructureScript.java # common/addons/structure-terrascript-loader/src/main/java/com/dfsek/terra/addons/terrascript/script/functions/LootFunction.java # common/addons/structure-terrascript-loader/src/main/java/com/dfsek/terra/addons/terrascript/script/functions/StructureFunction.java # common/api/core/src/main/java/com/dfsek/terra/api/Platform.java # common/implementation/src/main/java/com/dfsek/terra/AbstractPlatform.java # common/implementation/src/main/java/com/dfsek/terra/InternalAddon.java # common/implementation/src/main/java/com/dfsek/terra/commands/AddonsCommand.java # common/implementation/src/main/java/com/dfsek/terra/commands/ReloadCommand.java # common/implementation/src/main/java/com/dfsek/terra/commands/profiler/ProfileQueryCommand.java # common/implementation/src/main/java/com/dfsek/terra/config/PluginConfigImpl.java # common/implementation/src/main/java/com/dfsek/terra/config/lang/LangUtil.java # common/implementation/src/main/java/com/dfsek/terra/config/pack/ConfigPackImpl.java # common/implementation/src/main/java/com/dfsek/terra/event/FunctionalEventHandlerImpl.java # common/implementation/src/main/java/com/dfsek/terra/registry/config/ConfigTypeRegistry.java # common/implementation/src/main/java/com/dfsek/terra/registry/master/AddonRegistry.java # common/implementation/src/main/java/com/dfsek/terra/registry/master/ConfigRegistry.java # platforms/bukkit/src/main/java/com/dfsek/terra/bukkit/BukkitAddon.java # platforms/bukkit/src/main/java/com/dfsek/terra/bukkit/PlatformImpl.java # platforms/bukkit/src/main/java/com/dfsek/terra/bukkit/listeners/SpigotListener.java # platforms/fabric/src/main/java/com/dfsek/terra/fabric/FabricAddon.java # platforms/fabric/src/main/java/com/dfsek/terra/fabric/FabricEntryPoint.java # platforms/fabric/src/main/java/com/dfsek/terra/fabric/PlatformImpl.java # platforms/fabric/src/main/java/com/dfsek/terra/fabric/generation/FabricChunkGeneratorWrapper.java # platforms/sponge/src/main/java/com/dfsek/terra/sponge/PlatformImpl.java
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
|
||||
|
||||
@@ -4,7 +4,7 @@ import com.dfsek.tectonic.loading.object.ObjectTemplate;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.Platform;
|
||||
import com.dfsek.terra.api.addon.TerraAddon;
|
||||
import com.dfsek.terra.api.addon.annotations.Addon;
|
||||
import com.dfsek.terra.api.addon.annotations.Author;
|
||||
@@ -26,18 +26,18 @@ public class ImageBiomeProviderAddon extends TerraAddon {
|
||||
};
|
||||
|
||||
@Inject
|
||||
private TerraPlugin 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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ public class BiomePipeline {
|
||||
|
||||
public static final class BiomePipelineBuilder {
|
||||
private final int init;
|
||||
List<Stage> stages = new ArrayList<>();
|
||||
private final List<Stage> stages = new ArrayList<>();
|
||||
private int expand;
|
||||
|
||||
public BiomePipelineBuilder(int init) {
|
||||
|
||||
@@ -14,7 +14,7 @@ import com.dfsek.terra.addons.biome.pipeline.config.stage.mutator.ReplaceListMut
|
||||
import com.dfsek.terra.addons.biome.pipeline.config.stage.mutator.ReplaceMutatorTemplate;
|
||||
import com.dfsek.terra.addons.biome.pipeline.config.stage.mutator.SmoothMutatorTemplate;
|
||||
import com.dfsek.terra.addons.biome.pipeline.source.BiomeSource;
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.Platform;
|
||||
import com.dfsek.terra.api.addon.TerraAddon;
|
||||
import com.dfsek.terra.api.addon.annotations.Addon;
|
||||
import com.dfsek.terra.api.addon.annotations.Author;
|
||||
@@ -40,24 +40,24 @@ public class BiomePipelineAddon extends TerraAddon {
|
||||
public static final TypeKey<Supplier<ObjectTemplate<BiomeProvider>>> PROVIDER_REGISTRY_KEY = new TypeKey<>() {
|
||||
};
|
||||
@Inject
|
||||
private TerraPlugin 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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import net.jafama.FastMath;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import com.dfsek.terra.addons.biome.pipeline.api.BiomeHolder;
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.Platform;
|
||||
import com.dfsek.terra.api.noise.NoiseSampler;
|
||||
import com.dfsek.terra.api.world.biome.TerraBiome;
|
||||
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
||||
@@ -20,14 +20,14 @@ public class BiomePipelineProvider implements BiomeProvider {
|
||||
private final NoiseSampler mutator;
|
||||
private final double noiseAmp;
|
||||
|
||||
public BiomePipelineProvider(BiomePipeline pipeline, TerraPlugin 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<SeededVector, BiomeHolder>() {
|
||||
new CacheLoader<>() {
|
||||
@Override
|
||||
public BiomeHolder load(@NotNull SeededVector key) {
|
||||
return pipeline.getBiomes(key.x, key.z, key.seed);
|
||||
|
||||
@@ -9,14 +9,14 @@ import com.dfsek.terra.addons.biome.pipeline.BiomePipeline;
|
||||
import com.dfsek.terra.addons.biome.pipeline.BiomePipelineProvider;
|
||||
import com.dfsek.terra.addons.biome.pipeline.api.Stage;
|
||||
import com.dfsek.terra.addons.biome.pipeline.source.BiomeSource;
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.Platform;
|
||||
import com.dfsek.terra.api.config.meta.Meta;
|
||||
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
||||
|
||||
|
||||
@SuppressWarnings({ "FieldMayBeFinal", "unused" })
|
||||
public class BiomePipelineTemplate extends BiomeProviderTemplate {
|
||||
private final TerraPlugin 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(TerraPlugin 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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import com.dfsek.tectonic.loading.object.ObjectTemplate;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.Platform;
|
||||
import com.dfsek.terra.api.addon.TerraAddon;
|
||||
import com.dfsek.terra.api.addon.annotations.Addon;
|
||||
import com.dfsek.terra.api.addon.annotations.Author;
|
||||
@@ -25,18 +25,18 @@ public class SingleBiomeProviderAddon extends TerraAddon {
|
||||
};
|
||||
|
||||
@Inject
|
||||
private TerraPlugin 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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import com.dfsek.terra.addons.chunkgenerator.palette.PaletteHolder;
|
||||
import com.dfsek.terra.addons.chunkgenerator.palette.PaletteHolderLoader;
|
||||
import com.dfsek.terra.addons.chunkgenerator.palette.SlantHolder;
|
||||
import com.dfsek.terra.addons.chunkgenerator.palette.SlantHolderLoader;
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.Platform;
|
||||
import com.dfsek.terra.api.addon.TerraAddon;
|
||||
import com.dfsek.terra.api.addon.annotations.Addon;
|
||||
import com.dfsek.terra.api.addon.annotations.Author;
|
||||
@@ -23,30 +23,31 @@ import com.dfsek.terra.api.world.generator.ChunkGeneratorProvider;
|
||||
@Version("1.0.0")
|
||||
public class NoiseChunkGenerator3DAddon extends TerraAddon {
|
||||
@Inject
|
||||
private TerraPlugin 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;
|
||||
import org.slf4j.Logger;
|
||||
@@ -12,7 +14,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.TerraPlugin;
|
||||
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;
|
||||
@@ -35,21 +36,21 @@ public class NoiseChunkGenerator3D implements ChunkGenerator {
|
||||
private static final Logger logger = LoggerFactory.getLogger(NoiseChunkGenerator3D.class);
|
||||
|
||||
private final ConfigPack configPack;
|
||||
private final TerraPlugin main;
|
||||
private final Platform platform;
|
||||
private final List<GenerationStage> generationStages = new ArrayList<>();
|
||||
|
||||
private final BlockState air;
|
||||
|
||||
public NoiseChunkGenerator3D(ConfigPack c, TerraPlugin 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, TerraPlugin 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();
|
||||
@@ -69,7 +70,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);
|
||||
@@ -129,7 +130,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
|
||||
@@ -143,8 +144,8 @@ public class NoiseChunkGenerator3D implements ChunkGenerator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public TerraPlugin getMain() {
|
||||
return main;
|
||||
public Platform getPlatform() {
|
||||
return platform;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.dfsek.terra.addons.biome;
|
||||
|
||||
import com.dfsek.terra.addons.biome.holder.PaletteHolder;
|
||||
import com.dfsek.terra.addons.biome.holder.PaletteHolderLoader;
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.Platform;
|
||||
import com.dfsek.terra.api.addon.TerraAddon;
|
||||
import com.dfsek.terra.api.addon.annotations.Addon;
|
||||
import com.dfsek.terra.api.addon.annotations.Author;
|
||||
@@ -17,17 +17,17 @@ import com.dfsek.terra.api.inject.annotations.Inject;
|
||||
@Version("1.0.0")
|
||||
public class BiomeAddon extends TerraAddon {
|
||||
@Inject
|
||||
private TerraPlugin 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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import com.dfsek.tectonic.loading.TypeLoader;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.Platform;
|
||||
import com.dfsek.terra.api.config.ConfigFactory;
|
||||
import com.dfsek.terra.api.config.ConfigPack;
|
||||
import com.dfsek.terra.api.config.ConfigType;
|
||||
@@ -35,8 +35,8 @@ public class BiomeConfigType implements ConfigType<BiomeTemplate, TerraBiome> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BiomeTemplate getTemplate(ConfigPack pack, TerraPlugin main) {
|
||||
return new BiomeTemplate(pack, main);
|
||||
public BiomeTemplate getTemplate(ConfigPack pack, Platform platform) {
|
||||
return new BiomeTemplate(pack, platform);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.dfsek.terra.addons.biome;
|
||||
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.Platform;
|
||||
import com.dfsek.terra.api.config.ConfigFactory;
|
||||
import com.dfsek.terra.api.config.ConfigPack;
|
||||
import com.dfsek.terra.api.world.biome.TerraBiome;
|
||||
@@ -14,7 +14,7 @@ public class BiomeFactory implements ConfigFactory<BiomeTemplate, TerraBiome> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public TerraBiome build(BiomeTemplate template, TerraPlugin main) {
|
||||
public TerraBiome build(BiomeTemplate template, Platform platform) {
|
||||
UserDefinedGenerationSettings generator = new UserDefinedGenerationSettings(template.getNoiseEquation(),
|
||||
template.getElevationEquation(),
|
||||
template.getCarvingEquation(), template.getBiomeNoise(),
|
||||
|
||||
@@ -13,7 +13,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.Platform;
|
||||
import com.dfsek.terra.api.block.BlockType;
|
||||
import com.dfsek.terra.api.config.AbstractableTemplate;
|
||||
import com.dfsek.terra.api.config.ConfigPack;
|
||||
@@ -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, TerraPlugin 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.TerraPlugin;
|
||||
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 TerraPlugin 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, TerraPlugin 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);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.dfsek.terra.addons.biome.command.biome;
|
||||
|
||||
import com.dfsek.terra.addons.biome.UserDefinedBiome;
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.Platform;
|
||||
import com.dfsek.terra.api.command.CommandTemplate;
|
||||
import com.dfsek.terra.api.command.annotation.Command;
|
||||
import com.dfsek.terra.api.command.annotation.Subcommand;
|
||||
@@ -24,7 +24,7 @@ import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
||||
@PlayerCommand
|
||||
public class BiomeCommand implements CommandTemplate {
|
||||
@Inject
|
||||
private TerraPlugin main;
|
||||
private Platform platform;
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender) {
|
||||
|
||||
@@ -4,7 +4,7 @@ import java.util.Locale;
|
||||
|
||||
import com.dfsek.terra.addons.biome.command.biome.arg.BiomeArgumentParser;
|
||||
import com.dfsek.terra.addons.biome.command.biome.tab.BiomeTabCompleter;
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.Platform;
|
||||
import com.dfsek.terra.api.command.CommandTemplate;
|
||||
import com.dfsek.terra.api.command.annotation.Argument;
|
||||
import com.dfsek.terra.api.command.annotation.Command;
|
||||
@@ -51,7 +51,7 @@ public class BiomeLocateCommand implements CommandTemplate {
|
||||
private boolean teleport;
|
||||
|
||||
@Inject
|
||||
private TerraPlugin 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();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.dfsek.terra.addons.biome.command.biome.arg;
|
||||
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.Platform;
|
||||
import com.dfsek.terra.api.command.arg.ArgumentParser;
|
||||
import com.dfsek.terra.api.entity.CommandSender;
|
||||
import com.dfsek.terra.api.entity.Player;
|
||||
@@ -10,7 +10,7 @@ import com.dfsek.terra.api.world.biome.TerraBiome;
|
||||
|
||||
public class BiomeArgumentParser implements ArgumentParser<TerraBiome> {
|
||||
@Inject
|
||||
private TerraPlugin main;
|
||||
private Platform platform;
|
||||
|
||||
@Override
|
||||
public TerraBiome parse(CommandSender sender, String arg) {
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.dfsek.terra.addons.biome.command.biome.tab;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.Platform;
|
||||
import com.dfsek.terra.api.command.tab.TabCompleter;
|
||||
import com.dfsek.terra.api.entity.CommandSender;
|
||||
import com.dfsek.terra.api.entity.Player;
|
||||
@@ -13,7 +13,7 @@ import com.dfsek.terra.api.world.biome.TerraBiome;
|
||||
|
||||
public class BiomeTabCompleter implements TabCompleter {
|
||||
@Inject
|
||||
private TerraPlugin 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.TerraPlugin;
|
||||
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, TerraPlugin 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) {
|
||||
|
||||
@@ -7,7 +7,7 @@ import com.dfsek.tectonic.exception.LoadException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.Platform;
|
||||
import com.dfsek.terra.api.config.ConfigFactory;
|
||||
import com.dfsek.terra.api.config.ConfigPack;
|
||||
import com.dfsek.terra.api.util.MathUtil;
|
||||
@@ -21,7 +21,7 @@ public class CarverFactory implements ConfigFactory<CarverTemplate, UserDefinedC
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserDefinedCarver build(CarverTemplate config, TerraPlugin 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);
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
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.config.WorldConfig;
|
||||
@@ -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 TerraPlugin main;
|
||||
private final Platform platform;
|
||||
|
||||
public CavePopulator(TerraPlugin 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) {
|
||||
|
||||
@@ -14,7 +14,7 @@ import java.util.function.BiConsumer;
|
||||
|
||||
import com.dfsek.terra.addons.carver.carving.Carver;
|
||||
import com.dfsek.terra.addons.carver.carving.Worm;
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.Platform;
|
||||
import com.dfsek.terra.api.util.ConstantRange;
|
||||
import com.dfsek.terra.api.util.Range;
|
||||
import com.dfsek.terra.api.util.vector.Vector3;
|
||||
@@ -34,13 +34,13 @@ public class UserDefinedCarver extends Carver {
|
||||
private final Expression zRad;
|
||||
|
||||
private final Map<Long, CarverCache> cacheMap = new ConcurrentHashMap<>();
|
||||
private final TerraPlugin 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, TerraPlugin 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++) {
|
||||
|
||||
@@ -8,9 +8,10 @@ import com.dfsek.terra.addons.feature.distributor.config.AndDistributorTemplate;
|
||||
import com.dfsek.terra.addons.feature.distributor.config.NoiseDistributorTemplate;
|
||||
import com.dfsek.terra.addons.feature.distributor.config.OrDistributorTemplate;
|
||||
import com.dfsek.terra.addons.feature.distributor.config.PointSetDistributorTemplate;
|
||||
import com.dfsek.terra.addons.feature.distributor.config.YesDistributorTemplate;
|
||||
import com.dfsek.terra.addons.feature.distributor.util.Point;
|
||||
import com.dfsek.terra.addons.feature.distributor.util.PointTemplate;
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.Platform;
|
||||
import com.dfsek.terra.api.addon.TerraAddon;
|
||||
import com.dfsek.terra.api.addon.annotations.Addon;
|
||||
import com.dfsek.terra.api.addon.annotations.Author;
|
||||
@@ -30,24 +31,26 @@ public class DistributorAddon extends TerraAddon {
|
||||
public static final TypeKey<Supplier<ObjectTemplate<Distributor>>> DISTRIBUTOR_TOKEN = new TypeKey<>() {
|
||||
};
|
||||
@Inject
|
||||
private TerraPlugin 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);
|
||||
distributorRegistry.register("POINTS", PointSetDistributorTemplate::new);
|
||||
distributorRegistry.register("AND", AndDistributorTemplate::new);
|
||||
distributorRegistry.register("OR", OrDistributorTemplate::new);
|
||||
distributorRegistry.register("YES", YesDistributorTemplate::new);
|
||||
distributorRegistry.register("NO", NoiseDistributorTemplate::new);
|
||||
|
||||
event.getPack()
|
||||
.applyLoader(Point.class, PointTemplate::new);
|
||||
})
|
||||
.failThrough();
|
||||
.failThrough();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.dfsek.terra.addons.feature.distributor.config;
|
||||
|
||||
import com.dfsek.tectonic.loading.object.ObjectTemplate;
|
||||
|
||||
import com.dfsek.terra.api.structure.feature.Distributor;
|
||||
|
||||
|
||||
public class NoDistributorTemplate implements ObjectTemplate<Distributor> {
|
||||
@Override
|
||||
public Distributor get() {
|
||||
return Distributor.no();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.dfsek.terra.addons.feature.distributor.config;
|
||||
|
||||
import com.dfsek.tectonic.loading.object.ObjectTemplate;
|
||||
|
||||
import com.dfsek.terra.api.structure.feature.Distributor;
|
||||
|
||||
|
||||
public class YesDistributorTemplate implements ObjectTemplate<Distributor> {
|
||||
@Override
|
||||
public Distributor get() {
|
||||
return Distributor.yes();
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.dfsek.terra.addons.feature;
|
||||
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.Platform;
|
||||
import com.dfsek.terra.api.addon.TerraAddon;
|
||||
import com.dfsek.terra.api.addon.annotations.Addon;
|
||||
import com.dfsek.terra.api.addon.annotations.Author;
|
||||
@@ -15,14 +15,14 @@ import com.dfsek.terra.api.inject.annotations.Inject;
|
||||
@Author("Terra")
|
||||
public class FeatureAddon extends TerraAddon {
|
||||
@Inject
|
||||
private TerraPlugin 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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.dfsek.terra.addons.feature;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.Platform;
|
||||
import com.dfsek.terra.api.config.ConfigFactory;
|
||||
import com.dfsek.terra.api.config.ConfigPack;
|
||||
import com.dfsek.terra.api.config.ConfigType;
|
||||
@@ -23,7 +23,7 @@ public class FeatureConfigType implements ConfigType<FeatureTemplate, Feature> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public FeatureTemplate getTemplate(ConfigPack pack, TerraPlugin main) {
|
||||
public FeatureTemplate getTemplate(ConfigPack pack, Platform platform) {
|
||||
return new FeatureTemplate();
|
||||
}
|
||||
|
||||
|
||||
@@ -2,14 +2,14 @@ package com.dfsek.terra.addons.feature;
|
||||
|
||||
import com.dfsek.tectonic.exception.LoadException;
|
||||
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.Platform;
|
||||
import com.dfsek.terra.api.config.ConfigFactory;
|
||||
import com.dfsek.terra.api.structure.feature.Feature;
|
||||
|
||||
|
||||
public class FeatureFactory implements ConfigFactory<FeatureTemplate, Feature> {
|
||||
@Override
|
||||
public Feature build(FeatureTemplate config, TerraPlugin main) throws LoadException {
|
||||
public Feature build(FeatureTemplate config, Platform platform) throws LoadException {
|
||||
return new ConfiguredFeature(config.getStructures(), config.getStructureNoise(), config.getDistributor(), config.getLocator());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.dfsek.terra.addons.flora;
|
||||
|
||||
import com.dfsek.terra.addons.flora.config.BlockLayerTemplate;
|
||||
import com.dfsek.terra.addons.flora.flora.gen.BlockLayer;
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.Platform;
|
||||
import com.dfsek.terra.api.addon.TerraAddon;
|
||||
import com.dfsek.terra.api.addon.annotations.Addon;
|
||||
import com.dfsek.terra.api.addon.annotations.Author;
|
||||
@@ -17,17 +17,17 @@ import com.dfsek.terra.api.inject.annotations.Inject;
|
||||
@Version("0.1.0")
|
||||
public class FloraAddon extends TerraAddon {
|
||||
@Inject
|
||||
private TerraPlugin 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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,14 +2,13 @@ package com.dfsek.terra.addons.flora;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.Platform;
|
||||
import com.dfsek.terra.api.config.ConfigFactory;
|
||||
import com.dfsek.terra.api.config.ConfigPack;
|
||||
import com.dfsek.terra.api.config.ConfigType;
|
||||
import com.dfsek.terra.api.registry.OpenRegistry;
|
||||
import com.dfsek.terra.api.structure.Structure;
|
||||
import com.dfsek.terra.api.util.reflection.TypeKey;
|
||||
import com.dfsek.terra.api.world.Flora;
|
||||
|
||||
|
||||
public class FloraConfigType implements ConfigType<FloraTemplate, Structure> {
|
||||
@@ -23,7 +22,7 @@ public class FloraConfigType implements ConfigType<FloraTemplate, Structure> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public FloraTemplate getTemplate(ConfigPack pack, TerraPlugin main) {
|
||||
public FloraTemplate getTemplate(ConfigPack pack, Platform platform) {
|
||||
return new FloraTemplate();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
package com.dfsek.terra.addons.flora;
|
||||
|
||||
import com.dfsek.terra.addons.flora.flora.gen.TerraFlora;
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.Platform;
|
||||
import com.dfsek.terra.api.config.ConfigFactory;
|
||||
import com.dfsek.terra.api.structure.Structure;
|
||||
|
||||
|
||||
public class FloraFactory implements ConfigFactory<FloraTemplate, Structure> {
|
||||
@Override
|
||||
public TerraFlora build(FloraTemplate config, TerraPlugin main) {
|
||||
public TerraFlora build(FloraTemplate config, Platform platform) {
|
||||
return new TerraFlora(config.getLayers(), config.doPhysics(), config.isCeiling(),
|
||||
config.getRotatable(),
|
||||
config.getNoiseDistribution(), config.getID());
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.dfsek.tectonic.loading.object.ObjectTemplate;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import com.dfsek.terra.addons.feature.locator.config.AndLocatorTemplate;
|
||||
import com.dfsek.terra.addons.feature.locator.config.Noise3DLocatorTemplate;
|
||||
import com.dfsek.terra.addons.feature.locator.config.NoiseLocatorTemplate;
|
||||
import com.dfsek.terra.addons.feature.locator.config.OrLocatorTemplate;
|
||||
import com.dfsek.terra.addons.feature.locator.config.PatternLocatorTemplate;
|
||||
@@ -18,7 +19,7 @@ import com.dfsek.terra.addons.feature.locator.config.pattern.OrPatternTemplate;
|
||||
import com.dfsek.terra.addons.feature.locator.config.pattern.SingleBlockMatchPatternTemplate;
|
||||
import com.dfsek.terra.addons.feature.locator.config.pattern.SolidMatchPatternTemplate;
|
||||
import com.dfsek.terra.addons.feature.locator.patterns.Pattern;
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.Platform;
|
||||
import com.dfsek.terra.api.addon.TerraAddon;
|
||||
import com.dfsek.terra.api.addon.annotations.Addon;
|
||||
import com.dfsek.terra.api.addon.annotations.Author;
|
||||
@@ -41,24 +42,25 @@ public class LocatorAddon extends TerraAddon {
|
||||
public static final TypeKey<Supplier<ObjectTemplate<Pattern>>> PATTERN_TOKEN = new TypeKey<>() {
|
||||
};
|
||||
@Inject
|
||||
private TerraPlugin 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);
|
||||
locatorRegistry.register("NOISE_3D", Noise3DLocatorTemplate::new);
|
||||
|
||||
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);
|
||||
@@ -69,6 +71,6 @@ public class LocatorAddon extends TerraAddon {
|
||||
patternRegistry.register("OR", OrPatternTemplate::new);
|
||||
patternRegistry.register("NOT", NotPatternTemplate::new);
|
||||
})
|
||||
.failThrough();
|
||||
.failThrough();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.dfsek.terra.addons.feature.locator.config;
|
||||
|
||||
import com.dfsek.tectonic.annotations.Value;
|
||||
import com.dfsek.tectonic.loading.object.ObjectTemplate;
|
||||
|
||||
import com.dfsek.terra.addons.feature.locator.locators.Noise3DLocator;
|
||||
import com.dfsek.terra.api.config.meta.Meta;
|
||||
import com.dfsek.terra.api.noise.NoiseSampler;
|
||||
import com.dfsek.terra.api.structure.feature.Locator;
|
||||
|
||||
|
||||
public class Noise3DLocatorTemplate implements ObjectTemplate<Locator> {
|
||||
@Value("sampler")
|
||||
private @Meta NoiseSampler sampler;
|
||||
|
||||
@Override
|
||||
public Locator get() {
|
||||
return new Noise3DLocator(sampler);
|
||||
}
|
||||
}
|
||||
@@ -4,24 +4,24 @@ import com.dfsek.tectonic.annotations.Value;
|
||||
import com.dfsek.tectonic.loading.object.ObjectTemplate;
|
||||
|
||||
import com.dfsek.terra.addons.feature.locator.locators.SurfaceLocator;
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.Platform;
|
||||
import com.dfsek.terra.api.config.meta.Meta;
|
||||
import com.dfsek.terra.api.structure.feature.Locator;
|
||||
import com.dfsek.terra.api.util.Range;
|
||||
|
||||
|
||||
public class SurfaceLocatorTemplate implements ObjectTemplate<Locator> {
|
||||
private final TerraPlugin main;
|
||||
private final Platform platform;
|
||||
|
||||
@Value("range")
|
||||
private @Meta Range range;
|
||||
|
||||
public SurfaceLocatorTemplate(TerraPlugin 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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.dfsek.terra.addons.feature.locator.locators;
|
||||
|
||||
import com.dfsek.terra.api.noise.NoiseSampler;
|
||||
import com.dfsek.terra.api.structure.feature.BinaryColumn;
|
||||
import com.dfsek.terra.api.structure.feature.Locator;
|
||||
import com.dfsek.terra.api.world.Column;
|
||||
|
||||
|
||||
public class Noise3DLocator implements Locator {
|
||||
private final NoiseSampler sampler;
|
||||
|
||||
public Noise3DLocator(NoiseSampler sampler) {
|
||||
this.sampler = sampler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BinaryColumn getSuitableCoordinates(Column column) {
|
||||
BinaryColumn results = column.newBinaryColumn();
|
||||
long seed = column.getWorld().getSeed();
|
||||
int x = column.getX();
|
||||
int z = column.getZ();
|
||||
column.forEach(y -> {
|
||||
if(sampler.getNoiseSeeded(seed, x, y, z) > 0) results.set(y);
|
||||
});
|
||||
return results;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.dfsek.terra.addons.feature.locator.locators;
|
||||
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.Platform;
|
||||
import com.dfsek.terra.api.block.state.BlockState;
|
||||
import com.dfsek.terra.api.structure.feature.BinaryColumn;
|
||||
import com.dfsek.terra.api.structure.feature.Locator;
|
||||
@@ -13,9 +13,9 @@ public class SurfaceLocator implements Locator {
|
||||
|
||||
private final BlockState air;
|
||||
|
||||
public SurfaceLocator(Range search, TerraPlugin main) {
|
||||
public SurfaceLocator(Range search, Platform platform) {
|
||||
this.search = search;
|
||||
this.air = main.getWorldHandle().air();
|
||||
this.air = platform.getWorldHandle().air();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -30,7 +30,7 @@ import com.dfsek.terra.addons.noise.samplers.noise.simplex.PerlinSampler;
|
||||
import com.dfsek.terra.addons.noise.samplers.noise.simplex.SimplexSampler;
|
||||
import com.dfsek.terra.addons.noise.samplers.noise.value.ValueCubicSampler;
|
||||
import com.dfsek.terra.addons.noise.samplers.noise.value.ValueSampler;
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.Platform;
|
||||
import com.dfsek.terra.api.addon.TerraAddon;
|
||||
import com.dfsek.terra.api.addon.annotations.Addon;
|
||||
import com.dfsek.terra.api.addon.annotations.Author;
|
||||
@@ -50,7 +50,7 @@ public class NoiseAddon extends TerraAddon {
|
||||
public static final TypeKey<Supplier<ObjectTemplate<NoiseSampler>>> NOISE_SAMPLER_TOKEN = new TypeKey<>() {
|
||||
};
|
||||
@Inject
|
||||
private TerraPlugin plugin;
|
||||
private Platform plugin;
|
||||
|
||||
@Override
|
||||
public void initialize() {
|
||||
|
||||
@@ -334,36 +334,21 @@ public class CellularSampler extends NoiseFunction {
|
||||
}
|
||||
}
|
||||
|
||||
switch(returnType) {
|
||||
case CellValue:
|
||||
return closestHash * (1 / 2147483648.0);
|
||||
case Distance:
|
||||
return distance0 - 1;
|
||||
case Distance2:
|
||||
return distance1 - 1;
|
||||
case Distance2Add:
|
||||
return (distance1 + distance0) * 0.5 - 1;
|
||||
case Distance2Sub:
|
||||
return distance1 - distance0 - 1;
|
||||
case Distance2Mul:
|
||||
return distance1 * distance0 * 0.5 - 1;
|
||||
case Distance2Div:
|
||||
return distance0 / distance1 - 1;
|
||||
case NoiseLookup:
|
||||
return noiseLookup.getNoiseSeeded(sl, center.getX(), center.getZ());
|
||||
case Distance3:
|
||||
return distance2 - 1;
|
||||
case Distance3Add:
|
||||
return (distance2 + distance0) * 0.5 - 1;
|
||||
case Distance3Sub:
|
||||
return distance2 - distance0 - 1;
|
||||
case Distance3Mul:
|
||||
return distance2 * distance0 - 1;
|
||||
case Distance3Div:
|
||||
return distance0 / distance2 - 1;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return switch(returnType) {
|
||||
case CellValue -> closestHash * (1 / 2147483648.0);
|
||||
case Distance -> distance0 - 1;
|
||||
case Distance2 -> distance1 - 1;
|
||||
case Distance2Add -> (distance1 + distance0) * 0.5 - 1;
|
||||
case Distance2Sub -> distance1 - distance0 - 1;
|
||||
case Distance2Mul -> distance1 * distance0 * 0.5 - 1;
|
||||
case Distance2Div -> distance0 / distance1 - 1;
|
||||
case NoiseLookup -> noiseLookup.getNoiseSeeded(sl, center.getX(), center.getZ());
|
||||
case Distance3 -> distance2 - 1;
|
||||
case Distance3Add -> (distance2 + distance0) * 0.5 - 1;
|
||||
case Distance3Sub -> distance2 - distance0 - 1;
|
||||
case Distance3Mul -> distance2 * distance0 - 1;
|
||||
case Distance3Div -> distance0 / distance2 - 1;
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -509,36 +494,21 @@ public class CellularSampler extends NoiseFunction {
|
||||
}
|
||||
}
|
||||
|
||||
switch(returnType) {
|
||||
case CellValue:
|
||||
return closestHash * (1 / 2147483648.0);
|
||||
case Distance:
|
||||
return distance0 - 1;
|
||||
case Distance2:
|
||||
return distance1 - 1;
|
||||
case Distance2Add:
|
||||
return (distance1 + distance0) * 0.5 - 1;
|
||||
case Distance2Sub:
|
||||
return distance1 - distance0 - 1;
|
||||
case Distance2Mul:
|
||||
return distance1 * distance0 * 0.5 - 1;
|
||||
case Distance2Div:
|
||||
return distance0 / distance1 - 1;
|
||||
case NoiseLookup:
|
||||
return noiseLookup.getNoiseSeeded(sl, center.getX(), center.getY(), center.getZ());
|
||||
case Distance3:
|
||||
return distance2 - 1;
|
||||
case Distance3Add:
|
||||
return (distance2 + distance0) * 0.5 - 1;
|
||||
case Distance3Sub:
|
||||
return distance2 - distance0 - 1;
|
||||
case Distance3Mul:
|
||||
return distance2 * distance0 - 1;
|
||||
case Distance3Div:
|
||||
return distance0 / distance2 - 1;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return switch(returnType) {
|
||||
case CellValue -> closestHash * (1 / 2147483648.0);
|
||||
case Distance -> distance0 - 1;
|
||||
case Distance2 -> distance1 - 1;
|
||||
case Distance2Add -> (distance1 + distance0) * 0.5 - 1;
|
||||
case Distance2Sub -> distance1 - distance0 - 1;
|
||||
case Distance2Mul -> distance1 * distance0 * 0.5 - 1;
|
||||
case Distance2Div -> distance0 / distance1 - 1;
|
||||
case NoiseLookup -> noiseLookup.getNoiseSeeded(sl, center.getX(), center.getY(), center.getZ());
|
||||
case Distance3 -> distance2 - 1;
|
||||
case Distance3Add -> (distance2 + distance0) * 0.5 - 1;
|
||||
case Distance3Sub -> distance2 - distance0 - 1;
|
||||
case Distance3Mul -> distance2 * distance0 - 1;
|
||||
case Distance3Div -> distance0 / distance2 - 1;
|
||||
};
|
||||
}
|
||||
|
||||
public enum DistanceFunction {
|
||||
|
||||
@@ -34,6 +34,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||
package com.dfsek.terra.addons.noise.util;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Arrays;
|
||||
import java.util.NoSuchElementException;
|
||||
|
||||
|
||||
@@ -67,8 +68,8 @@ public class HashMapDoubleDouble extends HashIntrinsic {
|
||||
}
|
||||
|
||||
public boolean containsValue(double value) {
|
||||
for(int i = 0; i < this.table.length; ++i) {
|
||||
for(HashMapDoubleDouble.Entry e = this.table[i]; e != null; e = e.next) {
|
||||
for(Entry entry : this.table) {
|
||||
for(Entry e = entry; e != null; e = e.next) {
|
||||
if(value == e.value) {
|
||||
return true;
|
||||
}
|
||||
@@ -144,15 +145,13 @@ public class HashMapDoubleDouble extends HashIntrinsic {
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
for(int i = 0; i < this.table.length; ++i) {
|
||||
this.table[i] = null;
|
||||
}
|
||||
Arrays.fill(this.table, null);
|
||||
|
||||
this.size = 0;
|
||||
}
|
||||
|
||||
public long memoryEstimate(int ptrsize) {
|
||||
return (long) ptrsize * (long) (this.capMinus1 + this.size + 1) + (long) (this.size * 64 / 4);
|
||||
return (long) ptrsize * (long) (this.capMinus1 + this.size + 1) + (this.size * 64L / 4);
|
||||
}
|
||||
|
||||
public HashMapDoubleDouble.Iterator iterator() {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.dfsek.terra.addons.ore;
|
||||
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.Platform;
|
||||
import com.dfsek.terra.api.addon.TerraAddon;
|
||||
import com.dfsek.terra.api.addon.annotations.Addon;
|
||||
import com.dfsek.terra.api.addon.annotations.Author;
|
||||
@@ -16,17 +16,17 @@ import com.dfsek.terra.api.world.generator.GenerationStageProvider;
|
||||
@Version("1.0.0")
|
||||
public class OreAddon extends TerraAddon {
|
||||
@Inject
|
||||
private TerraPlugin 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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.dfsek.terra.addons.ore;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import com.dfsek.terra.addons.ore.ores.Ore;
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.Platform;
|
||||
import com.dfsek.terra.api.config.ConfigFactory;
|
||||
import com.dfsek.terra.api.config.ConfigPack;
|
||||
import com.dfsek.terra.api.config.ConfigType;
|
||||
@@ -22,7 +22,7 @@ public class OreConfigType implements ConfigType<OreTemplate, Ore> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public OreTemplate getTemplate(ConfigPack pack, TerraPlugin main) {
|
||||
public OreTemplate getTemplate(ConfigPack pack, Platform platform) {
|
||||
return new OreTemplate();
|
||||
}
|
||||
|
||||
|
||||
@@ -2,15 +2,15 @@ package com.dfsek.terra.addons.ore;
|
||||
|
||||
import com.dfsek.terra.addons.ore.ores.Ore;
|
||||
import com.dfsek.terra.addons.ore.ores.VanillaOre;
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.Platform;
|
||||
import com.dfsek.terra.api.block.state.BlockState;
|
||||
import com.dfsek.terra.api.config.ConfigFactory;
|
||||
|
||||
|
||||
public class OreFactory implements ConfigFactory<OreTemplate, Ore> {
|
||||
@Override
|
||||
public Ore build(OreTemplate config, TerraPlugin 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());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.Platform;
|
||||
import com.dfsek.terra.api.profiler.ProfileFrame;
|
||||
import com.dfsek.terra.api.util.PopulationUtil;
|
||||
import com.dfsek.terra.api.world.Chunk;
|
||||
@@ -14,16 +14,16 @@ import com.dfsek.terra.api.world.generator.GenerationStage;
|
||||
|
||||
|
||||
public class OrePopulator implements GenerationStage {
|
||||
private final TerraPlugin main;
|
||||
private final Platform platform;
|
||||
|
||||
public OrePopulator(TerraPlugin 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++) {
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.dfsek.terra.addons.ore.ores;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
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.collection.MaterialSet;
|
||||
@@ -17,13 +17,13 @@ public abstract class Ore {
|
||||
private final MaterialSet replaceable;
|
||||
private final boolean applyGravity;
|
||||
private final Map<BlockType, BlockState> materials;
|
||||
protected TerraPlugin main;
|
||||
protected Platform platform;
|
||||
|
||||
public Ore(BlockState material, MaterialSet replaceable, boolean applyGravity, TerraPlugin 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.TerraPlugin;
|
||||
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, TerraPlugin 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;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.dfsek.terra.addons.palette;
|
||||
|
||||
import com.dfsek.terra.addons.palette.palette.PaletteLayerHolder;
|
||||
import com.dfsek.terra.addons.palette.palette.PaletteLayerLoader;
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.Platform;
|
||||
import com.dfsek.terra.api.addon.TerraAddon;
|
||||
import com.dfsek.terra.api.addon.annotations.Addon;
|
||||
import com.dfsek.terra.api.addon.annotations.Author;
|
||||
@@ -17,17 +17,17 @@ import com.dfsek.terra.api.inject.annotations.Inject;
|
||||
@Version("1.0.0")
|
||||
public class PaletteAddon extends TerraAddon {
|
||||
@Inject
|
||||
private TerraPlugin 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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import com.dfsek.tectonic.loading.TypeLoader;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import com.dfsek.terra.addons.palette.palette.PaletteImpl;
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.Platform;
|
||||
import com.dfsek.terra.api.config.ConfigFactory;
|
||||
import com.dfsek.terra.api.config.ConfigPack;
|
||||
import com.dfsek.terra.api.config.ConfigType;
|
||||
@@ -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 TerraPlugin main;
|
||||
private final Platform platform;
|
||||
|
||||
public PaletteConfigType(TerraPlugin 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, TerraPlugin main) {
|
||||
public PaletteTemplate getTemplate(ConfigPack pack, Platform platform) {
|
||||
return new PaletteTemplate();
|
||||
}
|
||||
|
||||
|
||||
@@ -2,14 +2,14 @@ package com.dfsek.terra.addons.palette;
|
||||
|
||||
import com.dfsek.terra.addons.palette.palette.NoisePalette;
|
||||
import com.dfsek.terra.addons.palette.palette.PaletteLayerHolder;
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.Platform;
|
||||
import com.dfsek.terra.api.config.ConfigFactory;
|
||||
import com.dfsek.terra.api.world.generator.Palette;
|
||||
|
||||
|
||||
public class PaletteFactory implements ConfigFactory<PaletteTemplate, Palette> {
|
||||
@Override
|
||||
public Palette build(PaletteTemplate config, TerraPlugin 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());
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.dfsek.terra.addons.structure;
|
||||
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.Platform;
|
||||
import com.dfsek.terra.api.addon.TerraAddon;
|
||||
import com.dfsek.terra.api.addon.annotations.Addon;
|
||||
import com.dfsek.terra.api.addon.annotations.Author;
|
||||
@@ -16,14 +16,14 @@ import com.dfsek.terra.api.structure.configured.ConfiguredStructure;
|
||||
@Author("Terra")
|
||||
public class StructureAddon extends TerraAddon {
|
||||
@Inject
|
||||
private TerraPlugin 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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
package com.dfsek.terra.addons.structure;
|
||||
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.Platform;
|
||||
import com.dfsek.terra.api.config.ConfigFactory;
|
||||
import com.dfsek.terra.api.structure.configured.ConfiguredStructure;
|
||||
|
||||
|
||||
public class StructureFactory implements ConfigFactory<StructureTemplate, ConfiguredStructure> {
|
||||
@Override
|
||||
public ConfiguredStructure build(StructureTemplate config, TerraPlugin 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.TerraPlugin;
|
||||
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 TerraPlugin main;
|
||||
private final Platform platform;
|
||||
|
||||
public StructurePopulator(TerraPlugin 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.TerraPlugin;
|
||||
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 TerraPlugin 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, TerraPlugin 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();
|
||||
|
||||
@@ -8,7 +8,7 @@ import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.Platform;
|
||||
import com.dfsek.terra.api.block.entity.BlockEntity;
|
||||
import com.dfsek.terra.api.block.entity.Sign;
|
||||
import com.dfsek.terra.api.block.state.BlockState;
|
||||
@@ -34,7 +34,7 @@ public class StructureExportCommand implements CommandTemplate {
|
||||
private static final Logger logger = LoggerFactory.getLogger(StructureExportCommand.class);
|
||||
|
||||
@Inject
|
||||
private TerraPlugin main;
|
||||
private Platform platform;
|
||||
|
||||
@ArgumentTarget("id")
|
||||
private String id;
|
||||
@@ -43,7 +43,7 @@ public class StructureExportCommand implements CommandTemplate {
|
||||
public void execute(CommandSender sender) {
|
||||
Player player = (Player) sender;
|
||||
|
||||
Pair<Vector3, Vector3> area = main.getWorldHandle().getSelectedLocation(player);
|
||||
Pair<Vector3, Vector3> area = platform.getWorldHandle().getSelectedLocation(player);
|
||||
|
||||
Vector3 firstCorner = area.getLeft();
|
||||
Vector3 secondCorner = area.getRight();
|
||||
@@ -78,7 +78,7 @@ public class StructureExportCommand implements CommandTemplate {
|
||||
BlockEntity state = player.world().getBlockState(x, y, z);
|
||||
if(state instanceof Sign sign) {
|
||||
if("[TERRA]".equals(sign.getLine(0))) {
|
||||
data = main.getWorldHandle().createBlockData(sign.getLine(2) + sign.getLine(3));
|
||||
data = platform.getWorldHandle().createBlockData(sign.getLine(2) + sign.getLine(3));
|
||||
}
|
||||
}
|
||||
if(!data.isStructureVoid()) {
|
||||
@@ -91,7 +91,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();
|
||||
|
||||
@@ -6,7 +6,7 @@ import java.util.concurrent.ThreadLocalRandom;
|
||||
import com.dfsek.terra.addons.structure.command.structure.argument.ScriptArgumentParser;
|
||||
import com.dfsek.terra.addons.structure.command.structure.completer.RotationCompleter;
|
||||
import com.dfsek.terra.addons.structure.command.structure.completer.ScriptCompleter;
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.Platform;
|
||||
import com.dfsek.terra.api.command.CommandTemplate;
|
||||
import com.dfsek.terra.api.command.annotation.Argument;
|
||||
import com.dfsek.terra.api.command.annotation.Command;
|
||||
@@ -54,7 +54,7 @@ public class StructureLoadCommand implements CommandTemplate {
|
||||
private Structure script;
|
||||
|
||||
@Inject
|
||||
private TerraPlugin main;
|
||||
private Platform platform;
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender) {
|
||||
|
||||
@@ -5,7 +5,7 @@ import java.util.Locale;
|
||||
import com.dfsek.terra.addons.structure.command.AsyncStructureFinder;
|
||||
import com.dfsek.terra.addons.structure.command.structure.argument.StructureArgumentParser;
|
||||
import com.dfsek.terra.addons.structure.command.structure.completer.StructureCompleter;
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.Platform;
|
||||
import com.dfsek.terra.api.command.CommandTemplate;
|
||||
import com.dfsek.terra.api.command.annotation.Argument;
|
||||
import com.dfsek.terra.api.command.annotation.Command;
|
||||
@@ -42,7 +42,7 @@ import com.dfsek.terra.api.util.vector.Vector3;
|
||||
))
|
||||
public class StructureLocateCommand implements CommandTemplate {
|
||||
@Inject
|
||||
private TerraPlugin 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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.dfsek.terra.addons.structure.command.structure.argument;
|
||||
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.Platform;
|
||||
import com.dfsek.terra.api.command.arg.ArgumentParser;
|
||||
import com.dfsek.terra.api.entity.CommandSender;
|
||||
import com.dfsek.terra.api.entity.Player;
|
||||
@@ -10,7 +10,7 @@ import com.dfsek.terra.api.structure.Structure;
|
||||
|
||||
public class ScriptArgumentParser implements ArgumentParser<Structure> {
|
||||
@Inject
|
||||
private TerraPlugin main;
|
||||
private Platform platform;
|
||||
|
||||
@Override
|
||||
public Structure parse(CommandSender sender, String arg) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.dfsek.terra.addons.structure.command.structure.argument;
|
||||
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.Platform;
|
||||
import com.dfsek.terra.api.command.arg.ArgumentParser;
|
||||
import com.dfsek.terra.api.entity.CommandSender;
|
||||
import com.dfsek.terra.api.entity.Player;
|
||||
@@ -10,7 +10,7 @@ import com.dfsek.terra.api.structure.configured.ConfiguredStructure;
|
||||
|
||||
public class StructureArgumentParser implements ArgumentParser<ConfiguredStructure> {
|
||||
@Inject
|
||||
private TerraPlugin main;
|
||||
private Platform platform;
|
||||
|
||||
@Override
|
||||
public ConfiguredStructure parse(CommandSender sender, String arg) {
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.dfsek.terra.addons.structure.command.structure.completer;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.Platform;
|
||||
import com.dfsek.terra.api.command.tab.TabCompleter;
|
||||
import com.dfsek.terra.api.entity.CommandSender;
|
||||
import com.dfsek.terra.api.entity.Player;
|
||||
@@ -13,7 +13,7 @@ import com.dfsek.terra.api.structure.Structure;
|
||||
|
||||
public class ScriptCompleter implements TabCompleter {
|
||||
@Inject
|
||||
private TerraPlugin main;
|
||||
private Platform platform;
|
||||
|
||||
@Override
|
||||
public List<String> complete(CommandSender sender) {
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.dfsek.terra.addons.structure.command.structure.completer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.Platform;
|
||||
import com.dfsek.terra.api.command.tab.TabCompleter;
|
||||
import com.dfsek.terra.api.entity.CommandSender;
|
||||
import com.dfsek.terra.api.entity.Player;
|
||||
@@ -13,7 +13,7 @@ import com.dfsek.terra.api.structure.configured.ConfiguredStructure;
|
||||
|
||||
public class StructureCompleter implements TabCompleter {
|
||||
@Inject
|
||||
private TerraPlugin 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.TerraPlugin;
|
||||
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, TerraPlugin 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 {
|
||||
@@ -45,8 +46,7 @@ public class Entry {
|
||||
if(entry.containsKey("functions")) {
|
||||
for(Object function : (JSONArray) entry.get("functions")) {
|
||||
switch(((String) ((JSONObject) function).get("function"))) {
|
||||
case "minecraft:set_count":
|
||||
case "set_count":
|
||||
case "minecraft:set_count", "set_count" -> {
|
||||
Object loot = ((JSONObject) function).get("count");
|
||||
long max, min;
|
||||
if(loot instanceof Long) {
|
||||
@@ -57,23 +57,21 @@ public class Entry {
|
||||
min = (long) ((JSONObject) loot).get("min");
|
||||
}
|
||||
functions.add(new AmountFunction(FastMath.toIntExact(min), FastMath.toIntExact(max)));
|
||||
break;
|
||||
case "minecraft:set_damage":
|
||||
case "set_damage":
|
||||
}
|
||||
case "minecraft:set_damage", "set_damage" -> {
|
||||
long maxDamage = (long) ((JSONObject) ((JSONObject) function).get("damage")).get("max");
|
||||
long minDamage = (long) ((JSONObject) ((JSONObject) function).get("damage")).get("min");
|
||||
functions.add(new DamageFunction(FastMath.toIntExact(minDamage), FastMath.toIntExact(maxDamage)));
|
||||
break;
|
||||
case "minecraft:enchant_with_levels":
|
||||
case "enchant_with_levels":
|
||||
}
|
||||
case "minecraft:enchant_with_levels", "enchant_with_levels" -> {
|
||||
long maxEnchant = (long) ((JSONObject) ((JSONObject) function).get("levels")).get("max");
|
||||
long minEnchant = (long) ((JSONObject) ((JSONObject) function).get("levels")).get("min");
|
||||
JSONArray disabled = null;
|
||||
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));
|
||||
break;
|
||||
new EnchantFunction(FastMath.toIntExact(minEnchant), FastMath.toIntExact(maxEnchant), disabled, platform));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.Platform;
|
||||
import com.dfsek.terra.api.inventory.Inventory;
|
||||
import com.dfsek.terra.api.inventory.ItemStack;
|
||||
|
||||
@@ -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, TerraPlugin 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.TerraPlugin;
|
||||
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, TerraPlugin 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;
|
||||
import org.slf4j.Logger;
|
||||
@@ -10,7 +12,6 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.inventory.ItemStack;
|
||||
import com.dfsek.terra.api.inventory.item.Enchantment;
|
||||
import com.dfsek.terra.api.inventory.item.ItemMeta;
|
||||
@@ -22,14 +23,14 @@ public class EnchantFunction implements LootFunction {
|
||||
private final int min;
|
||||
private final int max;
|
||||
private final JSONArray disabled;
|
||||
private final TerraPlugin main;
|
||||
private final Platform platform;
|
||||
|
||||
|
||||
public EnchantFunction(int min, int max, JSONArray disabled, TerraPlugin 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;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -46,7 +47,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);
|
||||
}
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
package com.dfsek.terra.addons.generation.feature;
|
||||
|
||||
import com.dfsek.terra.api.block.state.BlockState;
|
||||
import com.dfsek.terra.api.structure.feature.BinaryColumn;
|
||||
import com.dfsek.terra.api.world.Column;
|
||||
import com.dfsek.terra.api.world.World;
|
||||
|
||||
import java.util.function.IntConsumer;
|
||||
|
||||
|
||||
public class ColumnImpl implements Column {
|
||||
private final int x;
|
||||
@@ -45,4 +48,16 @@ public class ColumnImpl implements Column {
|
||||
public int getMaxY() {
|
||||
return world.getMaxHeight();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void forEach(IntConsumer function) {
|
||||
for(int y = world.getMinHeight(); y < world.getMaxHeight(); y++) {
|
||||
function.accept(y);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public BinaryColumn newBinaryColumn() {
|
||||
return new BinaryColumn(getMinY(), getMaxY());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.dfsek.terra.addons.generation.feature;
|
||||
|
||||
import com.dfsek.terra.addons.generation.feature.config.BiomeFeaturesTemplate;
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.Platform;
|
||||
import com.dfsek.terra.api.addon.TerraAddon;
|
||||
import com.dfsek.terra.api.addon.annotations.Addon;
|
||||
import com.dfsek.terra.api.addon.annotations.Author;
|
||||
@@ -19,26 +19,26 @@ import com.dfsek.terra.api.world.generator.GenerationStageProvider;
|
||||
@Author("Terra")
|
||||
public class FeatureGenerationAddon extends TerraAddon {
|
||||
@Inject
|
||||
private TerraPlugin 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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.dfsek.terra.addons.generation.feature;
|
||||
|
||||
import com.dfsek.terra.addons.generation.feature.config.BiomeFeatures;
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.Platform;
|
||||
import com.dfsek.terra.api.profiler.ProfileFrame;
|
||||
import com.dfsek.terra.api.structure.rotation.Rotation;
|
||||
import com.dfsek.terra.api.util.PopulationUtil;
|
||||
@@ -12,16 +12,16 @@ import com.dfsek.terra.api.world.generator.GenerationStage;
|
||||
|
||||
|
||||
public class FeatureGenerationStage implements GenerationStage {
|
||||
private final TerraPlugin main;
|
||||
private final Platform platform;
|
||||
|
||||
public FeatureGenerationStage(TerraPlugin 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();
|
||||
|
||||
@@ -4,7 +4,7 @@ import com.dfsek.tectonic.yaml.YamlConfiguration;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.Platform;
|
||||
import com.dfsek.terra.api.addon.TerraAddon;
|
||||
import com.dfsek.terra.api.addon.annotations.Addon;
|
||||
import com.dfsek.terra.api.addon.annotations.Author;
|
||||
@@ -21,17 +21,17 @@ public class YamlAddon extends TerraAddon {
|
||||
private static final Logger logger = LoggerFactory.getLogger(YamlAddon.class);
|
||||
|
||||
@Inject
|
||||
private TerraPlugin main;
|
||||
private Platform platform;
|
||||
|
||||
@Override
|
||||
public void initialize() {
|
||||
main.getEventManager()
|
||||
platform.getEventManager()
|
||||
.getHandler(FunctionalEventHandler.class)
|
||||
.register(this, ConfigurationDiscoveryEvent.class)
|
||||
.then(event -> event.getLoader().open("", ".yml").thenEntries(entries -> entries.forEach(entry -> {
|
||||
logger.info("Discovered config {}", entry.getKey());
|
||||
event.register(entry.getKey(), new YamlConfiguration(entry.getValue(), entry.getKey()));
|
||||
})))
|
||||
.failThrough();
|
||||
.failThrough();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import java.util.Map;
|
||||
|
||||
import com.dfsek.terra.addons.terrascript.parser.exceptions.ParseException;
|
||||
import com.dfsek.terra.addons.terrascript.script.StructureScript;
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.Platform;
|
||||
import com.dfsek.terra.api.addon.TerraAddon;
|
||||
import com.dfsek.terra.api.addon.annotations.Addon;
|
||||
import com.dfsek.terra.api.addon.annotations.Author;
|
||||
@@ -25,20 +25,20 @@ import com.dfsek.terra.api.structure.Structure;
|
||||
@Version("1.0.0")
|
||||
public class TerraScriptAddon extends TerraAddon {
|
||||
@Inject
|
||||
private TerraPlugin 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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.dfsek.terra.addons.terrascript.buffer.items;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
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.structure.buffer.BufferedItem;
|
||||
@@ -16,13 +16,13 @@ public class BufferedBlock implements BufferedItem {
|
||||
|
||||
private final BlockState data;
|
||||
private final boolean overwrite;
|
||||
private final TerraPlugin main;
|
||||
private final Platform platform;
|
||||
private final boolean waterlog;
|
||||
|
||||
public BufferedBlock(BlockState data, boolean overwrite, TerraPlugin 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;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.dfsek.terra.addons.terrascript.buffer.items;
|
||||
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.Platform;
|
||||
import com.dfsek.terra.api.entity.Entity;
|
||||
import com.dfsek.terra.api.entity.EntityType;
|
||||
import com.dfsek.terra.api.event.events.world.generation.EntitySpawnEvent;
|
||||
@@ -12,16 +12,16 @@ import com.dfsek.terra.api.world.World;
|
||||
public class BufferedEntity implements BufferedItem {
|
||||
|
||||
private final EntityType type;
|
||||
private final TerraPlugin main;
|
||||
private final Platform platform;
|
||||
|
||||
public BufferedEntity(EntityType type, TerraPlugin 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));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import org.slf4j.LoggerFactory;
|
||||
import java.util.Random;
|
||||
|
||||
import com.dfsek.terra.addons.terrascript.script.StructureScript;
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.Platform;
|
||||
import com.dfsek.terra.api.block.entity.BlockEntity;
|
||||
import com.dfsek.terra.api.block.entity.Container;
|
||||
import com.dfsek.terra.api.event.events.world.generation.LootPopulateEvent;
|
||||
@@ -20,12 +20,12 @@ public class BufferedLootApplication implements BufferedItem {
|
||||
private static final Logger logger = LoggerFactory.getLogger(BufferedLootApplication.class);
|
||||
|
||||
private final LootTable table;
|
||||
private final TerraPlugin main;
|
||||
private final Platform platform;
|
||||
private final StructureScript structure;
|
||||
|
||||
public BufferedLootApplication(LootTable table, TerraPlugin main, StructureScript structure) {
|
||||
public BufferedLootApplication(LootTable table, Platform platform, StructureScript structure) {
|
||||
this.table = table;
|
||||
this.main = main;
|
||||
this.platform = platform;
|
||||
this.structure = structure;
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ public class BufferedLootApplication implements BufferedItem {
|
||||
}
|
||||
|
||||
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()));
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.dfsek.terra.addons.terrascript.buffer.items;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.Platform;
|
||||
import com.dfsek.terra.api.block.entity.BlockEntity;
|
||||
import com.dfsek.terra.api.structure.buffer.BufferedItem;
|
||||
import com.dfsek.terra.api.util.vector.Vector3;
|
||||
@@ -13,11 +13,11 @@ import com.dfsek.terra.api.world.World;
|
||||
public class BufferedStateManipulator implements BufferedItem {
|
||||
private static final Logger logger = LoggerFactory.getLogger(BufferedStateManipulator.class);
|
||||
|
||||
private final TerraPlugin main;
|
||||
private final Platform platform;
|
||||
private final String data;
|
||||
|
||||
public BufferedStateManipulator(TerraPlugin main, String state) {
|
||||
this.main = main;
|
||||
public BufferedStateManipulator(Platform platform, String state) {
|
||||
this.platform = platform;
|
||||
this.data = state;
|
||||
}
|
||||
|
||||
|
||||
@@ -98,17 +98,14 @@ public class Parser {
|
||||
ParserUtil.checkType(identifier, Token.Type.IF_STATEMENT, Token.Type.WHILE_LOOP, Token.Type.FOR_LOOP);
|
||||
|
||||
ParserUtil.checkType(tokens.consume(), Token.Type.GROUP_BEGIN);
|
||||
|
||||
switch(identifier.getType()) {
|
||||
case FOR_LOOP:
|
||||
return parseForLoop(tokens, variableMap, identifier.getPosition());
|
||||
case IF_STATEMENT:
|
||||
return parseIfStatement(tokens, variableMap, identifier.getPosition(), loop);
|
||||
case WHILE_LOOP:
|
||||
return parseWhileLoop(tokens, variableMap, identifier.getPosition());
|
||||
default:
|
||||
throw new UnsupportedOperationException("Unknown keyword " + identifier.getContent() + ": " + identifier.getPosition());
|
||||
}
|
||||
|
||||
return switch(identifier.getType()) {
|
||||
case FOR_LOOP -> parseForLoop(tokens, variableMap, identifier.getPosition());
|
||||
case IF_STATEMENT -> parseIfStatement(tokens, variableMap, identifier.getPosition(), loop);
|
||||
case WHILE_LOOP -> parseWhileLoop(tokens, variableMap, identifier.getPosition());
|
||||
default -> throw new UnsupportedOperationException(
|
||||
"Unknown keyword " + identifier.getContent() + ": " + identifier.getPosition());
|
||||
};
|
||||
}
|
||||
|
||||
private WhileKeyword parseWhileLoop(Tokenizer tokens, Map<String, Returnable.ReturnType> variableMap, Position start)
|
||||
|
||||
@@ -90,17 +90,13 @@ public class ParserUtil {
|
||||
}
|
||||
|
||||
public static Returnable.ReturnType getVariableReturnType(Token varToken) throws ParseException {
|
||||
switch(varToken.getType()) {
|
||||
case NUMBER_VARIABLE:
|
||||
return Returnable.ReturnType.NUMBER;
|
||||
case STRING_VARIABLE:
|
||||
return Returnable.ReturnType.STRING;
|
||||
case BOOLEAN_VARIABLE:
|
||||
return Returnable.ReturnType.BOOLEAN;
|
||||
default:
|
||||
throw new ParseException("Unexpected token " + varToken.getType() + "; expected variable declaration",
|
||||
varToken.getPosition());
|
||||
}
|
||||
return switch(varToken.getType()) {
|
||||
case NUMBER_VARIABLE -> Returnable.ReturnType.NUMBER;
|
||||
case STRING_VARIABLE -> Returnable.ReturnType.STRING;
|
||||
case BOOLEAN_VARIABLE -> Returnable.ReturnType.BOOLEAN;
|
||||
default -> throw new ParseException("Unexpected token " + varToken.getType() + "; expected variable declaration",
|
||||
varToken.getPosition());
|
||||
};
|
||||
}
|
||||
|
||||
public static boolean hasPrecedence(Token.Type first, Token.Type second) {
|
||||
|
||||
@@ -9,17 +9,17 @@ import com.dfsek.terra.addons.terrascript.tokenizer.Position;
|
||||
|
||||
|
||||
public interface Function<T> extends Returnable<T> {
|
||||
Function<?> NULL = new Function<Object>() {
|
||||
Function<?> NULL = new Function<>() {
|
||||
@Override
|
||||
public ReturnType returnType() {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Object apply(ImplementationArguments implementationArguments, Map<String, Variable<?>> variableMap) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Position getPosition() {
|
||||
return null;
|
||||
|
||||
@@ -33,15 +33,9 @@ public class Declaration<T> implements Item<T> {
|
||||
public T apply(ImplementationArguments implementationArguments, Map<String, Variable<?>> variableMap) {
|
||||
T result = value.apply(implementationArguments, variableMap);
|
||||
switch(type) {
|
||||
case NUMBER:
|
||||
variableMap.put(identifier, new NumberVariable((Number) result, position));
|
||||
break;
|
||||
case BOOLEAN:
|
||||
variableMap.put(identifier, new BooleanVariable((Boolean) result, position));
|
||||
break;
|
||||
case STRING:
|
||||
variableMap.put(identifier, new StringVariable((String) result, position));
|
||||
break;
|
||||
case NUMBER -> variableMap.put(identifier, new NumberVariable((Number) result, position));
|
||||
case BOOLEAN -> variableMap.put(identifier, new BooleanVariable((Boolean) result, position));
|
||||
case STRING -> variableMap.put(identifier, new StringVariable((String) result, position));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ import com.dfsek.terra.addons.terrascript.script.builders.UnaryBooleanFunctionBu
|
||||
import com.dfsek.terra.addons.terrascript.script.builders.UnaryNumberFunctionBuilder;
|
||||
import com.dfsek.terra.addons.terrascript.script.builders.UnaryStringFunctionBuilder;
|
||||
import com.dfsek.terra.addons.terrascript.script.builders.ZeroArgFunctionBuilder;
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.Platform;
|
||||
import com.dfsek.terra.api.profiler.ProfileFrame;
|
||||
import com.dfsek.terra.api.registry.Registry;
|
||||
import com.dfsek.terra.api.structure.LootTable;
|
||||
@@ -56,10 +56,10 @@ public class StructureScript implements Structure {
|
||||
private final Block block;
|
||||
private final String id;
|
||||
private final Cache<Vector3, StructureBuffer> cache;
|
||||
private final TerraPlugin main;
|
||||
private final Platform platform;
|
||||
private String tempID;
|
||||
|
||||
public StructureScript(InputStream inputStream, TerraPlugin 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 {
|
||||
@@ -71,20 +71,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))
|
||||
@@ -117,21 +117,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();
|
||||
@@ -141,7 +141,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));
|
||||
}
|
||||
}
|
||||
@@ -149,7 +149,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));
|
||||
}
|
||||
@@ -157,7 +157,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();
|
||||
}
|
||||
|
||||
@@ -22,19 +22,19 @@ public class BinaryNumberFunctionBuilder implements FunctionBuilder<Function<Num
|
||||
|
||||
@Override
|
||||
public Function<Number> build(List<Returnable<?>> argumentList, Position position) {
|
||||
return new Function<Number>() {
|
||||
return new Function<>() {
|
||||
@Override
|
||||
public ReturnType returnType() {
|
||||
return ReturnType.NUMBER;
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public Number apply(ImplementationArguments implementationArguments, Map<String, Variable<?>> variableMap) {
|
||||
return function.apply(((Returnable<Number>) argumentList.get(0)).apply(implementationArguments, variableMap),
|
||||
((Returnable<Number>) argumentList.get(1)).apply(implementationArguments, variableMap));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Position getPosition() {
|
||||
return position;
|
||||
|
||||
@@ -6,20 +6,20 @@ import com.dfsek.terra.addons.terrascript.parser.lang.Returnable;
|
||||
import com.dfsek.terra.addons.terrascript.parser.lang.functions.FunctionBuilder;
|
||||
import com.dfsek.terra.addons.terrascript.script.functions.BiomeFunction;
|
||||
import com.dfsek.terra.addons.terrascript.tokenizer.Position;
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.Platform;
|
||||
|
||||
|
||||
public class BiomeFunctionBuilder implements FunctionBuilder<BiomeFunction> {
|
||||
private final TerraPlugin main;
|
||||
private final Platform platform;
|
||||
|
||||
public BiomeFunctionBuilder(TerraPlugin 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);
|
||||
}
|
||||
|
||||
@@ -30,13 +30,9 @@ public class BiomeFunctionBuilder implements FunctionBuilder<BiomeFunction> {
|
||||
|
||||
@Override
|
||||
public Returnable.ReturnType getArgument(int position) {
|
||||
switch(position) {
|
||||
case 0:
|
||||
case 1:
|
||||
case 2:
|
||||
return Returnable.ReturnType.NUMBER;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
return switch(position) {
|
||||
case 0, 1, 2 -> Returnable.ReturnType.NUMBER;
|
||||
default -> null;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,14 +9,14 @@ import com.dfsek.terra.addons.terrascript.parser.lang.constants.StringConstant;
|
||||
import com.dfsek.terra.addons.terrascript.parser.lang.functions.FunctionBuilder;
|
||||
import com.dfsek.terra.addons.terrascript.script.functions.BlockFunction;
|
||||
import com.dfsek.terra.addons.terrascript.tokenizer.Position;
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.Platform;
|
||||
|
||||
|
||||
public class BlockFunctionBuilder implements FunctionBuilder<BlockFunction> {
|
||||
private final TerraPlugin main;
|
||||
private final Platform platform;
|
||||
|
||||
public BlockFunctionBuilder(TerraPlugin 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
|
||||
@@ -42,17 +42,11 @@ public class BlockFunctionBuilder implements FunctionBuilder<BlockFunction> {
|
||||
|
||||
@Override
|
||||
public Returnable.ReturnType getArgument(int position) {
|
||||
switch(position) {
|
||||
case 0:
|
||||
case 1:
|
||||
case 2:
|
||||
return Returnable.ReturnType.NUMBER;
|
||||
case 3:
|
||||
return Returnable.ReturnType.STRING;
|
||||
case 4:
|
||||
return Returnable.ReturnType.BOOLEAN;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
return switch(position) {
|
||||
case 0, 1, 2 -> Returnable.ReturnType.NUMBER;
|
||||
case 3 -> Returnable.ReturnType.STRING;
|
||||
case 4 -> Returnable.ReturnType.BOOLEAN;
|
||||
default -> null;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,13 +23,9 @@ public class CheckBlockFunctionBuilder implements FunctionBuilder<CheckBlockFunc
|
||||
|
||||
@Override
|
||||
public Returnable.ReturnType getArgument(int position) {
|
||||
switch(position) {
|
||||
case 0:
|
||||
case 1:
|
||||
case 2:
|
||||
return Returnable.ReturnType.NUMBER;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
return switch(position) {
|
||||
case 0, 1, 2 -> Returnable.ReturnType.NUMBER;
|
||||
default -> null;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,20 +7,20 @@ import com.dfsek.terra.addons.terrascript.parser.lang.Returnable;
|
||||
import com.dfsek.terra.addons.terrascript.parser.lang.functions.FunctionBuilder;
|
||||
import com.dfsek.terra.addons.terrascript.script.functions.CheckFunction;
|
||||
import com.dfsek.terra.addons.terrascript.tokenizer.Position;
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.Platform;
|
||||
|
||||
|
||||
public class CheckFunctionBuilder implements FunctionBuilder<CheckFunction> {
|
||||
private final TerraPlugin main;
|
||||
private final Platform platform;
|
||||
|
||||
public CheckFunctionBuilder(TerraPlugin 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);
|
||||
}
|
||||
|
||||
@@ -31,13 +31,9 @@ public class CheckFunctionBuilder implements FunctionBuilder<CheckFunction> {
|
||||
|
||||
@Override
|
||||
public Returnable.ReturnType getArgument(int position) {
|
||||
switch(position) {
|
||||
case 0:
|
||||
case 1:
|
||||
case 2:
|
||||
return Returnable.ReturnType.NUMBER;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
return switch(position) {
|
||||
case 0, 1, 2 -> Returnable.ReturnType.NUMBER;
|
||||
default -> null;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,21 +7,21 @@ import com.dfsek.terra.addons.terrascript.parser.lang.Returnable;
|
||||
import com.dfsek.terra.addons.terrascript.parser.lang.functions.FunctionBuilder;
|
||||
import com.dfsek.terra.addons.terrascript.script.functions.EntityFunction;
|
||||
import com.dfsek.terra.addons.terrascript.tokenizer.Position;
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.Platform;
|
||||
|
||||
|
||||
public class EntityFunctionBuilder implements FunctionBuilder<EntityFunction> {
|
||||
private final TerraPlugin main;
|
||||
private final Platform platform;
|
||||
|
||||
public EntityFunctionBuilder(TerraPlugin 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
|
||||
@@ -31,15 +31,10 @@ public class EntityFunctionBuilder implements FunctionBuilder<EntityFunction> {
|
||||
|
||||
@Override
|
||||
public Returnable.ReturnType getArgument(int position) {
|
||||
switch(position) {
|
||||
case 0:
|
||||
case 1:
|
||||
case 2:
|
||||
return Returnable.ReturnType.NUMBER;
|
||||
case 3:
|
||||
return Returnable.ReturnType.STRING;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
return switch(position) {
|
||||
case 0, 1, 2 -> Returnable.ReturnType.NUMBER;
|
||||
case 3 -> Returnable.ReturnType.STRING;
|
||||
default -> null;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,13 +27,9 @@ public class GetMarkFunctionBuilder implements FunctionBuilder<GetMarkFunction>
|
||||
|
||||
@Override
|
||||
public Returnable.ReturnType getArgument(int position) {
|
||||
switch(position) {
|
||||
case 0:
|
||||
case 1:
|
||||
case 2:
|
||||
return Returnable.ReturnType.NUMBER;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
return switch(position) {
|
||||
case 0, 1, 2 -> Returnable.ReturnType.NUMBER;
|
||||
default -> null;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,18 +7,18 @@ import com.dfsek.terra.addons.terrascript.parser.lang.functions.FunctionBuilder;
|
||||
import com.dfsek.terra.addons.terrascript.script.StructureScript;
|
||||
import com.dfsek.terra.addons.terrascript.script.functions.LootFunction;
|
||||
import com.dfsek.terra.addons.terrascript.tokenizer.Position;
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.Platform;
|
||||
import com.dfsek.terra.api.registry.Registry;
|
||||
import com.dfsek.terra.api.structure.LootTable;
|
||||
|
||||
|
||||
public class LootFunctionBuilder implements FunctionBuilder<LootFunction> {
|
||||
private final TerraPlugin main;
|
||||
private final Platform platform;
|
||||
private final Registry<LootTable> registry;
|
||||
private final StructureScript script;
|
||||
|
||||
public LootFunctionBuilder(TerraPlugin 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
|
||||
@@ -37,15 +37,10 @@ public class LootFunctionBuilder implements FunctionBuilder<LootFunction> {
|
||||
|
||||
@Override
|
||||
public Returnable.ReturnType getArgument(int position) {
|
||||
switch(position) {
|
||||
case 0:
|
||||
case 1:
|
||||
case 2:
|
||||
return Returnable.ReturnType.NUMBER;
|
||||
case 3:
|
||||
return Returnable.ReturnType.STRING;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
return switch(position) {
|
||||
case 0, 1, 2 -> Returnable.ReturnType.NUMBER;
|
||||
case 3 -> Returnable.ReturnType.STRING;
|
||||
default -> null;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,21 +7,21 @@ import com.dfsek.terra.addons.terrascript.parser.lang.Returnable;
|
||||
import com.dfsek.terra.addons.terrascript.parser.lang.functions.FunctionBuilder;
|
||||
import com.dfsek.terra.addons.terrascript.script.functions.PullFunction;
|
||||
import com.dfsek.terra.addons.terrascript.tokenizer.Position;
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.Platform;
|
||||
|
||||
|
||||
public class PullFunctionBuilder implements FunctionBuilder<PullFunction> {
|
||||
private final TerraPlugin main;
|
||||
private final Platform platform;
|
||||
|
||||
public PullFunctionBuilder(TerraPlugin 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
|
||||
@@ -31,15 +31,10 @@ public class PullFunctionBuilder implements FunctionBuilder<PullFunction> {
|
||||
|
||||
@Override
|
||||
public Returnable.ReturnType getArgument(int position) {
|
||||
switch(position) {
|
||||
case 0:
|
||||
case 1:
|
||||
case 2:
|
||||
return Returnable.ReturnType.NUMBER;
|
||||
case 3:
|
||||
return Returnable.ReturnType.STRING;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
return switch(position) {
|
||||
case 0, 1, 2 -> Returnable.ReturnType.NUMBER;
|
||||
case 3 -> Returnable.ReturnType.STRING;
|
||||
default -> null;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,15 +28,10 @@ public class SetMarkFunctionBuilder implements FunctionBuilder<SetMarkFunction>
|
||||
|
||||
@Override
|
||||
public Returnable.ReturnType getArgument(int position) {
|
||||
switch(position) {
|
||||
case 0:
|
||||
case 1:
|
||||
case 2:
|
||||
return Returnable.ReturnType.NUMBER;
|
||||
case 3:
|
||||
return Returnable.ReturnType.STRING;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
return switch(position) {
|
||||
case 0, 1, 2 -> Returnable.ReturnType.NUMBER;
|
||||
case 3 -> Returnable.ReturnType.STRING;
|
||||
default -> null;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,14 +7,14 @@ import com.dfsek.terra.addons.terrascript.parser.lang.Returnable;
|
||||
import com.dfsek.terra.addons.terrascript.parser.lang.functions.FunctionBuilder;
|
||||
import com.dfsek.terra.addons.terrascript.script.functions.StateFunction;
|
||||
import com.dfsek.terra.addons.terrascript.tokenizer.Position;
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.Platform;
|
||||
|
||||
|
||||
public class StateFunctionBuilder implements FunctionBuilder<StateFunction> {
|
||||
private final TerraPlugin main;
|
||||
private final Platform platform;
|
||||
|
||||
public StateFunctionBuilder(TerraPlugin 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
|
||||
@@ -32,15 +32,10 @@ public class StateFunctionBuilder implements FunctionBuilder<StateFunction> {
|
||||
|
||||
@Override
|
||||
public Returnable.ReturnType getArgument(int position) {
|
||||
switch(position) {
|
||||
case 0:
|
||||
case 1:
|
||||
case 2:
|
||||
return Returnable.ReturnType.NUMBER;
|
||||
case 3:
|
||||
return Returnable.ReturnType.STRING;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
return switch(position) {
|
||||
case 0, 1, 2 -> Returnable.ReturnType.NUMBER;
|
||||
case 3 -> Returnable.ReturnType.STRING;
|
||||
default -> null;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,18 +8,18 @@ import com.dfsek.terra.addons.terrascript.parser.lang.Returnable;
|
||||
import com.dfsek.terra.addons.terrascript.parser.lang.functions.FunctionBuilder;
|
||||
import com.dfsek.terra.addons.terrascript.script.functions.StructureFunction;
|
||||
import com.dfsek.terra.addons.terrascript.tokenizer.Position;
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.Platform;
|
||||
import com.dfsek.terra.api.registry.Registry;
|
||||
import com.dfsek.terra.api.structure.Structure;
|
||||
|
||||
|
||||
public class StructureFunctionBuilder implements FunctionBuilder<StructureFunction> {
|
||||
private final Registry<Structure> registry;
|
||||
private final TerraPlugin main;
|
||||
private final Platform platform;
|
||||
|
||||
public StructureFunctionBuilder(Registry<Structure> registry, TerraPlugin 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
|
||||
@@ -40,13 +40,9 @@ public class StructureFunctionBuilder implements FunctionBuilder<StructureFuncti
|
||||
|
||||
@Override
|
||||
public Returnable.ReturnType getArgument(int position) {
|
||||
switch(position) {
|
||||
case 0:
|
||||
case 1:
|
||||
case 2:
|
||||
return Returnable.ReturnType.NUMBER;
|
||||
default:
|
||||
return Returnable.ReturnType.STRING;
|
||||
}
|
||||
return switch(position) {
|
||||
case 0, 1, 2 -> Returnable.ReturnType.NUMBER;
|
||||
default -> Returnable.ReturnType.STRING;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,12 +23,12 @@ public class UnaryBooleanFunctionBuilder implements FunctionBuilder<Function<Voi
|
||||
|
||||
@Override
|
||||
public Function<Void> build(List<Returnable<?>> argumentList, Position position) {
|
||||
return new Function<Void>() {
|
||||
return new Function<>() {
|
||||
@Override
|
||||
public ReturnType returnType() {
|
||||
return ReturnType.VOID;
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public Void apply(ImplementationArguments implementationArguments, Map<String, Variable<?>> variableMap) {
|
||||
@@ -36,7 +36,7 @@ public class UnaryBooleanFunctionBuilder implements FunctionBuilder<Function<Voi
|
||||
(TerraImplementationArguments) implementationArguments);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Position getPosition() {
|
||||
return position;
|
||||
|
||||
@@ -21,18 +21,18 @@ public class UnaryNumberFunctionBuilder implements FunctionBuilder<Function<Numb
|
||||
|
||||
@Override
|
||||
public Function<Number> build(List<Returnable<?>> argumentList, Position position) {
|
||||
return new Function<Number>() {
|
||||
return new Function<>() {
|
||||
@Override
|
||||
public ReturnType returnType() {
|
||||
return ReturnType.NUMBER;
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public Number apply(ImplementationArguments implementationArguments, Map<String, Variable<?>> variableMap) {
|
||||
return function.apply(((Returnable<Number>) argumentList.get(0)).apply(implementationArguments, variableMap));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Position getPosition() {
|
||||
return position;
|
||||
|
||||
@@ -21,19 +21,19 @@ public class UnaryStringFunctionBuilder implements FunctionBuilder<Function<Void
|
||||
|
||||
@Override
|
||||
public Function<Void> build(List<Returnable<?>> argumentList, Position position) {
|
||||
return new Function<Void>() {
|
||||
return new Function<>() {
|
||||
@Override
|
||||
public ReturnType returnType() {
|
||||
return ReturnType.VOID;
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public Void apply(ImplementationArguments implementationArguments, Map<String, Variable<?>> variableMap) {
|
||||
function.accept(((Returnable<String>) argumentList.get(0)).apply(implementationArguments, variableMap));
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Position getPosition() {
|
||||
return position;
|
||||
|
||||
@@ -23,17 +23,17 @@ public class ZeroArgFunctionBuilder<T> implements FunctionBuilder<Function<T>> {
|
||||
|
||||
@Override
|
||||
public Function<T> build(List<Returnable<?>> argumentList, Position position) {
|
||||
return new Function<T>() {
|
||||
return new Function<>() {
|
||||
@Override
|
||||
public ReturnType returnType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public T apply(ImplementationArguments implementationArguments, Map<String, Variable<?>> variableMap) {
|
||||
return function.apply((TerraImplementationArguments) implementationArguments);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Position getPosition() {
|
||||
return position;
|
||||
|
||||
@@ -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.TerraPlugin;
|
||||
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 TerraPlugin main;
|
||||
private final Platform platform;
|
||||
private final Returnable<Number> x, y, z;
|
||||
private final Position position;
|
||||
|
||||
|
||||
public BiomeFunction(TerraPlugin 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.TerraPlugin;
|
||||
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 TerraPlugin 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, TerraPlugin 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, TerraPlugin 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
|
||||
|
||||
@@ -10,7 +10,7 @@ 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.TerraPlugin;
|
||||
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;
|
||||
@@ -19,12 +19,12 @@ import com.dfsek.terra.api.world.generator.SamplerCache;
|
||||
|
||||
|
||||
public class CheckFunction implements Function<String> {
|
||||
private final TerraPlugin main;
|
||||
private final Platform platform;
|
||||
private final Returnable<Number> x, y, z;
|
||||
private final Position position;
|
||||
|
||||
public CheckFunction(TerraPlugin 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;
|
||||
|
||||
@@ -11,7 +11,7 @@ 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.TerraPlugin;
|
||||
import com.dfsek.terra.api.Platform;
|
||||
import com.dfsek.terra.api.entity.EntityType;
|
||||
import com.dfsek.terra.api.util.RotationUtil;
|
||||
import com.dfsek.terra.api.util.vector.Vector2;
|
||||
@@ -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 TerraPlugin main;
|
||||
private final Platform platform;
|
||||
|
||||
public EntityFunction(Returnable<Number> x, Returnable<Number> y, Returnable<Number> z, Returnable<String> data, TerraPlugin 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;
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ import com.dfsek.terra.addons.terrascript.parser.lang.variables.Variable;
|
||||
import com.dfsek.terra.addons.terrascript.script.StructureScript;
|
||||
import com.dfsek.terra.addons.terrascript.script.TerraImplementationArguments;
|
||||
import com.dfsek.terra.addons.terrascript.tokenizer.Position;
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.Platform;
|
||||
import com.dfsek.terra.api.registry.Registry;
|
||||
import com.dfsek.terra.api.structure.LootTable;
|
||||
import com.dfsek.terra.api.util.RotationUtil;
|
||||
@@ -29,18 +29,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 TerraPlugin 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, TerraPlugin 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;
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ public class LootFunction implements Function<Void> {
|
||||
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;
|
||||
|
||||
@@ -13,7 +13,7 @@ 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.TerraPlugin;
|
||||
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;
|
||||
@@ -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, TerraPlugin 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;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user