diff --git a/common/addons/biome-provider-single/LICENSE b/common/addons/biome-provider-single/LICENSE new file mode 100644 index 000000000..64c1cd516 --- /dev/null +++ b/common/addons/biome-provider-single/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2020-2021 Polyhedral Development + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/common/addons/biome-provider-single/README.md b/common/addons/biome-provider-single/README.md new file mode 100644 index 000000000..3bea8cbb5 --- /dev/null +++ b/common/addons/biome-provider-single/README.md @@ -0,0 +1,4 @@ +# biome-provider-single + +Registers and configures the `SINGLE` biome provider, a biome provider which +accepts a single biome to generate continuously. \ No newline at end of file diff --git a/common/addons/biome-provider-single/build.gradle.kts b/common/addons/biome-provider-single/build.gradle.kts new file mode 100644 index 000000000..147905b20 --- /dev/null +++ b/common/addons/biome-provider-single/build.gradle.kts @@ -0,0 +1,3 @@ +dependencies { + "shadedApi"(project(":common:addons:manifest-addon-loader")) +} diff --git a/common/addons/biome-provider-single/src/main/java/com/dfsek/terra/addons/biome/single/SingleBiomeProvider.java b/common/addons/biome-provider-single/src/main/java/com/dfsek/terra/addons/biome/single/SingleBiomeProvider.java new file mode 100644 index 000000000..8daf6c4c7 --- /dev/null +++ b/common/addons/biome-provider-single/src/main/java/com/dfsek/terra/addons/biome/single/SingleBiomeProvider.java @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2020-2021 Polyhedral Development + * + * The Terra Core Addons are licensed under the terms of the MIT License. For more details, + * reference the LICENSE file in this module's root directory. + */ + +package com.dfsek.terra.addons.biome.single; + +import com.dfsek.terra.api.world.biome.TerraBiome; +import com.dfsek.terra.api.world.biome.generation.BiomeProvider; + + +public class SingleBiomeProvider implements BiomeProvider { + private final TerraBiome biome; + + public SingleBiomeProvider(TerraBiome biome) { + this.biome = biome; + } + + @Override + public TerraBiome getBiome(int x, int z, long seed) { + return biome; + } +} diff --git a/common/addons/biome-provider-single/src/main/java/com/dfsek/terra/addons/biome/single/SingleBiomeProviderAddon.java b/common/addons/biome-provider-single/src/main/java/com/dfsek/terra/addons/biome/single/SingleBiomeProviderAddon.java new file mode 100644 index 000000000..b39ca9519 --- /dev/null +++ b/common/addons/biome-provider-single/src/main/java/com/dfsek/terra/addons/biome/single/SingleBiomeProviderAddon.java @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2020-2021 Polyhedral Development + * + * The Terra Core Addons are licensed under the terms of the MIT License. For more details, + * reference the LICENSE file in this module's root directory. + */ + +package com.dfsek.terra.addons.biome.single; + +import com.dfsek.tectonic.loading.object.ObjectTemplate; + +import java.util.function.Supplier; + +import com.dfsek.terra.addons.manifest.api.AddonInitializer; +import com.dfsek.terra.api.Platform; +import com.dfsek.terra.api.addon.BaseAddon; +import com.dfsek.terra.api.event.events.config.pack.ConfigPackPreLoadEvent; +import com.dfsek.terra.api.event.functional.FunctionalEventHandler; +import com.dfsek.terra.api.inject.annotations.Inject; +import com.dfsek.terra.api.registry.CheckedRegistry; +import com.dfsek.terra.api.util.reflection.TypeKey; +import com.dfsek.terra.api.world.biome.generation.BiomeProvider; + + +public class SingleBiomeProviderAddon implements AddonInitializer { + public static final TypeKey>> PROVIDER_REGISTRY_KEY = new TypeKey<>() { + }; + + @Inject + private Platform platform; + + @Inject + private BaseAddon addon; + + @Override + public void initialize() { + platform.getEventManager() + .getHandler(FunctionalEventHandler.class) + .register(addon, ConfigPackPreLoadEvent.class) + .then(event -> { + CheckedRegistry>> providerRegistry = event.getPack().getOrCreateRegistry( + PROVIDER_REGISTRY_KEY); + providerRegistry.register("SINGLE", SingleBiomeProviderTemplate::new); + }) + .failThrough(); + } +} diff --git a/common/addons/biome-provider-single/src/main/java/com/dfsek/terra/addons/biome/single/SingleBiomeProviderTemplate.java b/common/addons/biome-provider-single/src/main/java/com/dfsek/terra/addons/biome/single/SingleBiomeProviderTemplate.java new file mode 100644 index 000000000..671dd7a3f --- /dev/null +++ b/common/addons/biome-provider-single/src/main/java/com/dfsek/terra/addons/biome/single/SingleBiomeProviderTemplate.java @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2020-2021 Polyhedral Development + * + * The Terra Core Addons are licensed under the terms of the MIT License. For more details, + * reference the LICENSE file in this module's root directory. + */ + +package com.dfsek.terra.addons.biome.single; + +import com.dfsek.tectonic.annotations.Value; +import com.dfsek.tectonic.loading.object.ObjectTemplate; + +import com.dfsek.terra.api.config.meta.Meta; +import com.dfsek.terra.api.world.biome.TerraBiome; +import com.dfsek.terra.api.world.biome.generation.BiomeProvider; + + +public class SingleBiomeProviderTemplate implements ObjectTemplate { + @Value("biome") + private @Meta TerraBiome biome; + + @Override + public BiomeProvider get() { + return new SingleBiomeProvider(biome); + } +} diff --git a/common/addons/biome-provider-single/src/main/resources/terra.addon.yml b/common/addons/biome-provider-single/src/main/resources/terra.addon.yml new file mode 100644 index 000000000..71f0cbb08 --- /dev/null +++ b/common/addons/biome-provider-single/src/main/resources/terra.addon.yml @@ -0,0 +1,12 @@ +schema-version: 1 +contributors: + - Terra contributors +id: biome-provider-single +version: 0.1.0 +entrypoints: + - "com.dfsek.terra.addons.biome.single.SingleBiomeProviderAddon" +website: + issues: https://github.com/PolyhedralDev/Terra-biome-provider-single/issues + source: https://github.com/PolyhedralDev/Terra-biome-provider-single + docs: https://github.com/PolyhedralDev/Terra/wiki +license: GNU LGPL v3.0 \ No newline at end of file