Compare commits

...

47 Commits

Author SHA1 Message Date
dfsek e6300df185 implement a bunch of function utils 2026-01-03 15:53:13 -07:00
dfsek 65eb66c3ca add curry and uncurry functions 2026-01-03 04:13:21 -07:00
dfsek aa3fe18339 rename palette-block-shortcut to shortcut-block-palette 2026-01-02 22:26:33 -07:00
dfsek 6a6a3928cd rename structure-block-shortcut to shortcut-block-structure 2026-01-02 22:25:23 -07:00
dfsek ac1258d233 rename library-image to api-image 2026-01-02 22:24:42 -07:00
dfsek b6d42fdcc1 rename biome-query-api to api-biome-query 2026-01-02 22:22:14 -07:00
dfsek a9251fa228 rename api-addon-loader addon-loader-api 2026-01-02 22:20:44 -07:00
dfsek 38a1571941 fix RegistryTest 2026-01-02 22:19:05 -07:00
dfsek b9af66848a rename manifest-addon-loader to addon-loader-manifest 2026-01-02 22:15:14 -07:00
dfsek e9d30b8794 rename Lazy to Memo 2026-01-02 21:13:24 -07:00
dfsek 53dafa4a2c rename IntToBooleanFunction to IntPredicate 2026-01-02 20:04:26 -07:00
dfsek df46c617f2 move Construct to FunctionUtils 2026-01-02 20:04:00 -07:00
dfsek e706ef89fc implement faster map on Lazy 2026-01-02 17:23:03 -07:00
dfsek a66c2a0749 Implement Monad Lazy 2026-01-02 17:12:30 -07:00
dfsek a5fe4d7928 Add annotations 2026-01-02 17:12:20 -07:00
dfsek 966bcab370 add more linkedlist methods 2026-01-02 03:04:19 -07:00
dfsek eae5a60cf9 remove useless methods from Pair 2026-01-01 22:31:44 -07:00
dfsek 9357b18964 refactor some static methods to generic versions in BiFunctor 2026-01-01 22:30:10 -07:00
dfsek 86bb4d5a1a implement Bifunctor Pair 2026-01-01 20:15:05 -07:00
dfsek 47bdd66fe7 Make Pair a record 2026-01-01 20:10:15 -07:00
dfsek eb6b3704d0 add linkedlist 2026-01-01 20:09:06 -07:00
dfsek 8eb5a70d4d fallback to base loader if shortcut doesnt exist 2025-12-30 12:01:40 -07:00
dfsek 5dc9f419ac only apply shortcut if loaded config is a string 2025-12-30 11:58:48 -07:00
dfsek 2215ea8336 tinker with cloud 2025-12-30 01:43:13 -07:00
dfsek 998b6478f3 add more api helpers 2025-12-30 01:27:41 -07:00
dfsek efa4bf5bb4 Generify shortcut configs to work on any type 2025-12-30 00:23:44 -07:00
dfsek 2ad05cbbb6 back ShortcutHolder with generic TypeLoader 2025-12-29 23:21:31 -07:00
dfsek 1bbedf51b5 fix refactor in mixin 2025-12-29 22:48:10 -07:00
dfsek bdcd93f164 refactor some stuff to use new errors 2025-12-29 22:47:59 -07:00
dfsek c4a366112e refactor createBlockState to use new error API 2025-12-29 22:33:07 -07:00
dfsek cb08401536 start working on error handling stuff 2025-12-29 22:18:44 -07:00
dfsek 9a16336f53 convert a bunch of stuff to new APIs 2025-12-29 21:11:11 -07:00
dfsek 16705057e0 update most things to use new maybe and either 2025-12-29 18:59:57 -07:00
dfsek d52cd0d7cf finish maybe 2025-12-29 18:23:42 -07:00
dfsek 7d3382e623 more either stuff 2025-12-29 18:18:14 -07:00
dfsek 87e437f889 finish either 2025-12-29 18:06:16 -07:00
dfsek 292be6bcec add bifunctor 2025-12-29 17:08:40 -07:00
dfsek f03f39f1d7 implement Monad (Maybe a) 2025-12-29 17:05:18 -07:00
dfsek 8bfff6b010 redo maybe 2025-12-29 16:58:37 -07:00
dfsek e5d30183ef fix functional utils 2025-12-29 16:57:29 -07:00
dfsek 3777fda641 Add 2-argument higher-order type and move kinds to their own package
I don't think that we will have higher-order types with more than 2 parameters, so I only made K and K2
2025-12-29 16:07:36 -07:00
dfsek f684c60039 experimenting with kinds and higher order types, not done yet 2025-12-29 16:02:18 -07:00
dfsek ef088dd3f7 add basic functional types again 2025-12-28 23:59:46 -07:00
dfsek 4f672dfb7b make either not bad 2025-12-28 22:27:08 -07:00
dfsek b851b2f881 start addon impl 2025-12-28 22:03:03 -07:00
dfsek 9c64353111 rename MaterialSetLoader 2025-12-28 20:54:16 -07:00
dfsek c537605880 rename MaterialSet 2025-12-28 20:53:51 -07:00
263 changed files with 1672 additions and 717 deletions
@@ -15,7 +15,7 @@ public class ApiAddon implements BaseAddon {
}
@Override
public Version getVersion() {
public Version version() {
return version;
}
@@ -33,7 +33,7 @@ public class ApiAddonLoader implements BootstrapBaseAddon<BaseAddon> {
}
@Override
public Version getVersion() {
public Version version() {
return VERSION;
}
}
@@ -66,12 +66,12 @@ public class ManifestAddon implements BaseAddon {
}
@Override
public Map<String, VersionRange> getDependencies() {
public Map<String, VersionRange> dependencies() {
return manifest.getDependencies();
}
@Override
public Version getVersion() {
public Version version() {
return manifest.getVersion();
}
}
@@ -132,7 +132,7 @@ public class ManifestAddonLoader implements BootstrapBaseAddon<ManifestAddon> {
}
@Override
public Version getVersion() {
public Version version() {
return VERSION;
}
}
@@ -0,0 +1,5 @@
version = version("1.0.0")
dependencies {
compileOnlyApi(project(":common:addons:addon-loader-manifest"))
}
@@ -1,7 +1,7 @@
schema-version: 1
contributors:
- Terra contributors
id: biome-query-api
id: api-biome-query
version: @VERSION@
entrypoints:
- "com.dfsek.terra.addons.biome.query.BiomeQueryAPIAddon"
+7
View File
@@ -0,0 +1,7 @@
version = version("1.1.0")
dependencies {
compileOnlyApi(project(":common:addons:addon-loader-manifest"))
}
@@ -17,7 +17,7 @@ import com.dfsek.terra.addons.image.image.Image;
import com.dfsek.terra.addons.image.image.SuppliedImage;
import com.dfsek.terra.api.config.ConfigPack;
import com.dfsek.terra.api.properties.Properties;
import com.dfsek.terra.api.util.generic.Lazy;
import com.dfsek.terra.api.util.generic.Memo;
import static com.dfsek.terra.api.util.cache.CacheUtils.CACHE_EXECUTOR;
@@ -41,7 +41,7 @@ record ImageCache(LoadingCache<String, Image> cache) implements Properties {
return new SuppliedImage(() -> images.cache.get(path));
} else {
// If images do not time out, image can be lazily loaded once instead of performing cache lookups for each image operation
Lazy<Image> lazyImage = Lazy.lazy(() -> images.cache.get(path));
Memo<Image> lazyImage = Memo.lazy(() -> images.cache.get(path));
return new SuppliedImage(lazyImage::value);
}
}
@@ -1,7 +1,7 @@
schema-version: 1
contributors:
- Terra contributors
id: library-image
id: api-image
version: @VERSION@
entrypoints:
- "com.dfsek.terra.addons.image.ImageLibraryAddon"
@@ -1,6 +1,6 @@
version = version("1.0.0")
dependencies {
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
compileOnlyApi(project(":common:addons:biome-query-api"))
compileOnlyApi(project(":common:addons:addon-loader-manifest"))
compileOnlyApi(project(":common:addons:api-biome-query"))
}
@@ -9,6 +9,7 @@ import com.dfsek.terra.addons.biome.extrusion.api.Extrusion;
import com.dfsek.terra.addons.biome.extrusion.utils.ExtrusionPipeline;
import com.dfsek.terra.addons.biome.extrusion.utils.ExtrusionPipelineFactory;
import com.dfsek.terra.api.util.Column;
import com.dfsek.terra.api.util.generic.data.types.Maybe;
import com.dfsek.terra.api.world.biome.Biome;
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
@@ -39,11 +40,11 @@ public class BiomeExtrusionProvider implements BiomeProvider {
public Column<Biome> getColumn(int x, int z, long seed, int min, int max) {
return delegate.getBaseBiome(x, z, seed)
.map(base -> (Column<Biome>) new BaseBiomeColumn(this, base, min, max, x, z, seed))
.orElseGet(() -> BiomeProvider.super.getColumn(x, z, seed, min, max));
.get(() -> BiomeProvider.super.getColumn(x, z, seed, min, max));
}
@Override
public Optional<Biome> getBaseBiome(int x, int z, long seed) {
public Maybe<Biome> getBaseBiome(int x, int z, long seed) {
return delegate.getBaseBiome(x, z, seed);
}
@@ -27,6 +27,6 @@ public class ReplaceableBiomeLoader implements TypeLoader<ReplaceableBiome> {
return biomeRegistry
.getByID((String) c)
.map(ReplaceableBiome::of)
.orElseThrow(() -> new LoadException("No such biome: " + c, depthTracker));
.collectThrow(left -> new LoadException("No such biome: " + c + ": " + left, depthTracker));
}
}
@@ -11,4 +11,4 @@ website:
docs: https://terra.polydev.org
license: MIT License
depends:
biome-query-api: "1.+"
api-biome-query: "1.+"
+1 -1
View File
@@ -1,5 +1,5 @@
# biome-provider-image-v2
Implements and registers the `IMAGE` biome provider, which
utilizes various config types provided by the `library-image` addon to
utilizes various config types provided by the `api-image` addon to
distribute biomes based on images.
@@ -1,8 +1,8 @@
version = version("2.0.0")
dependencies {
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
compileOnlyApi(project(":common:addons:library-image"))
compileOnlyApi(project(":common:addons:addon-loader-manifest"))
compileOnlyApi(project(":common:addons:api-image"))
}
@@ -11,6 +11,7 @@ import java.util.Optional;
import com.dfsek.terra.addons.image.colorsampler.ColorSampler;
import com.dfsek.terra.addons.image.converter.ColorConverter;
import com.dfsek.terra.api.util.generic.data.types.Maybe;
import com.dfsek.terra.api.world.biome.Biome;
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
@@ -40,8 +41,8 @@ public class ImageBiomeProvider implements BiomeProvider {
}
@Override
public Optional<Biome> getBaseBiome(int x, int z, long seed) {
return Optional.of(getBiome(x, z));
public Maybe<Biome> getBaseBiome(int x, int z, long seed) {
return Maybe.just(getBiome(x, z));
}
@Override
@@ -11,4 +11,4 @@ website:
docs: https://terra.polydev.org
license: MIT License
depends:
library-image: "1.+"
api-image: "1.+"
@@ -1,5 +1,5 @@
version = version("2.0.0")
dependencies {
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
compileOnlyApi(project(":common:addons:addon-loader-manifest"))
}
@@ -8,6 +8,9 @@
package com.dfsek.terra.addons.biome.pipeline;
import com.dfsek.seismic.type.sampler.Sampler;
import com.dfsek.terra.api.util.generic.data.types.Maybe;
import com.github.benmanes.caffeine.cache.Caffeine;
import com.github.benmanes.caffeine.cache.LoadingCache;
@@ -106,8 +109,8 @@ public class PipelineBiomeProvider implements BiomeProvider {
}
@Override
public Optional<Biome> getBaseBiome(int x, int z, long seed) {
return Optional.of(getBiome(x, z, seed));
public Maybe<Biome> getBaseBiome(int x, int z, long seed) {
return Maybe.just(getBiome(x, z, seed));
}
@Override
@@ -7,6 +7,7 @@ import com.dfsek.tectonic.api.loader.type.TypeLoader;
import org.jetbrains.annotations.NotNull;
import java.lang.reflect.AnnotatedType;
import java.util.function.Function;
import com.dfsek.terra.addons.biome.pipeline.api.biome.PipelineBiome;
import com.dfsek.terra.api.registry.Registry;
@@ -27,6 +28,6 @@ public class PipelineBiomeLoader implements TypeLoader<PipelineBiome> {
return biomeRegistry
.getByID((String) c)
.map(PipelineBiome::from)
.orElseGet(() -> PipelineBiome.placeholder((String) c));
.collect(left -> PipelineBiome.placeholder((String) c), Function.identity());
}
}
@@ -1,5 +1,5 @@
version = version("1.0.0")
dependencies {
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
compileOnlyApi(project(":common:addons:addon-loader-manifest"))
}
@@ -8,18 +8,13 @@
package com.dfsek.terra.addons.biome.single;
import java.util.Collections;
import java.util.Optional;
import com.dfsek.terra.api.util.generic.data.types.Maybe;
import com.dfsek.terra.api.world.biome.Biome;
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
public class SingleBiomeProvider implements BiomeProvider {
private final Biome biome;
public SingleBiomeProvider(Biome biome) {
this.biome = biome;
}
public record SingleBiomeProvider(Biome biome) implements BiomeProvider {
@Override
public Biome getBiome(int x, int y, int z, long seed) {
@@ -27,8 +22,8 @@ public class SingleBiomeProvider implements BiomeProvider {
}
@Override
public Optional<Biome> getBaseBiome(int x, int z, long seed) {
return Optional.of(biome);
public Maybe<Biome> getBaseBiome(int x, int z, long seed) {
return Maybe.just(biome);
}
@Override
@@ -1,5 +0,0 @@
version = version("1.0.0")
dependencies {
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
}
@@ -1,5 +1,5 @@
version = version("1.2.1")
dependencies {
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
compileOnlyApi(project(":common:addons:addon-loader-manifest"))
}
@@ -30,7 +30,7 @@ public class ElevationInterpolator {
gens[x + 1 + smooth][z + 1 + smooth] =
provider
.getBaseBiome(bx, bz, seed)
.orElseGet(() -> provider.getBiome(bx, 0, bz, seed)) // kind of a hack
.get(() -> provider.getBiome(bx, 0, bz, seed)) // kind of a hack
.getContext()
.get(noisePropertiesKey);
}
@@ -1,5 +1,5 @@
version = version("1.0.0")
dependencies {
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
compileOnlyApi(project(":common:addons:addon-loader-manifest"))
}
@@ -39,7 +39,7 @@ public class AddonsCommandAddon implements AddonInitializer {
.append(" - ")
.append(addon.getID())
.append('@')
.append(addon.getVersion().getFormatted())
.append(addon.version().getFormatted())
.append('\n'));
context.sender().sendMessage(addons.toString());
})
@@ -52,10 +52,10 @@ public class AddonsCommandAddon implements AddonInitializer {
BaseAddon addon = context.get("addon");
StringBuilder addonInfo = new StringBuilder("Addon ").append(addon.getID()).append('\n');
addonInfo.append("Version: ").append(addon.getVersion().getFormatted()).append('\n');
addonInfo.append("Version: ").append(addon.version().getFormatted()).append('\n');
addonInfo.append("Dependencies:\n");
addon.getDependencies().forEach((id, versions) -> addonInfo
addon.dependencies().forEach((id, versions) -> addonInfo
.append(" - ")
.append(id)
.append('@')
@@ -1,5 +1,5 @@
version = version("1.0.0")
dependencies {
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
compileOnlyApi(project(":common:addons:addon-loader-manifest"))
}
@@ -2,10 +2,13 @@ package com.dfsek.terra.addons.commands.locate;
import com.dfsek.seismic.type.vector.Vector2Int;
import com.dfsek.seismic.type.vector.Vector3Int;
import com.dfsek.terra.api.util.generic.either.Either;
import com.dfsek.terra.api.util.generic.data.types.Either;
import com.dfsek.terra.api.util.generic.data.types.Maybe;
import com.dfsek.terra.api.world.biome.Biome;
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
import com.dfsek.terra.api.world.info.WorldProperties;
import org.jetbrains.annotations.NotNull;
import java.util.Optional;
@@ -13,6 +16,8 @@ import java.util.function.Function;
import java.util.function.Predicate;
import java.util.stream.IntStream;
import java.util.stream.Stream;
import static com.dfsek.terra.api.util.function.FunctionUtils.*;
public class BiomeLocator {
@@ -27,9 +32,10 @@ public class BiomeLocator {
* @param step The search step/increment. Higher values are faster but less accurate.
* @param filter The condition to match the biome.
* @param search3D If true, searches the entire vertical column at each step. If false, only checks originY.
*
* @return An Optional containing the location of the found biome, or empty if not found.
*/
public static Optional<Either<Vector3Int, Vector2Int>> search(
public static Maybe<Either<Vector3Int, Vector2Int>> search(
@NotNull BiomeProvider provider,
@NotNull WorldProperties properties,
int originX,
@@ -44,64 +50,63 @@ public class BiomeLocator {
int maxHeight = properties.getMaxHeight();
// 1. Check the exact center first
Optional<Either<Vector3Int, Vector2Int>> centerResult = check(provider, seed, originX, originZ, step, filter, search3D, minHeight, maxHeight);
if (centerResult.isPresent()) {
return centerResult;
}
return
check(provider, seed, originX, originZ, step, filter, search3D, minHeight, maxHeight)
// 2. Begin Parallel Square Spiral Search
// We iterate rings sequentially to guarantee finding the *nearest* result.
// However, we process all points within a specific ring in parallel.
for (int r = step; r <= radius; r += step) {
final int currentRadius = r;
final int minX = -currentRadius;
final int maxX = currentRadius;
final int minZ = -currentRadius;
final int maxZ = currentRadius;
// 2. Begin Parallel Square Spiral Search
// We iterate rings sequentially to guarantee finding the *nearest* result.
// However, we process all points within a specific ring in parallel.
.or(() -> {
for(int r = step; r <= radius; r += step) {
final int currentRadius = r;
final int minX = -currentRadius;
final int maxX = currentRadius;
final int minZ = -currentRadius;
final int maxZ = currentRadius;
Stream<int[]> northSide = IntStream.iterate(minX, n -> n < maxX, n -> n + step)
.mapToObj(x -> new int[]{x, minZ}); // Fixed Z (min), varying X
Stream<int[]> northSide = IntStream.iterate(minX, n -> n < maxX, n -> n + step)
.mapToObj(x -> new int[]{ x, minZ }); // Fixed Z (min), varying X
Stream<int[]> eastSide = IntStream.iterate(minZ, n -> n < maxZ, n -> n + step)
.mapToObj(z -> new int[]{maxX, z}); // Fixed X (max), varying Z
Stream<int[]> eastSide = IntStream.iterate(minZ, n -> n < maxZ, n -> n + step)
.mapToObj(z -> new int[]{ maxX, z }); // Fixed X (max), varying Z
Stream<int[]> southSide = IntStream.iterate(maxX, n -> n > minX, n -> n - step)
.mapToObj(x -> new int[]{x, maxZ}); // Fixed Z (max), varying X
Stream<int[]> southSide = IntStream.iterate(maxX, n -> n > minX, n -> n - step)
.mapToObj(x -> new int[]{ x, maxZ }); // Fixed Z (max), varying X
Stream<int[]> westSide = IntStream.iterate(maxZ, n -> n > minZ, n -> n - step)
.mapToObj(z -> new int[]{minX, z}); // Fixed X (min), varying Z
Stream<int[]> westSide = IntStream.iterate(maxZ, n -> n > minZ, n -> n - step)
.mapToObj(z -> new int[]{ minX, z }); // Fixed X (min), varying Z
Optional<Either<Vector3Int, Vector2Int>> ringResult = Stream.of(northSide, eastSide, southSide, westSide)
.flatMap(Function.identity())
.parallel()
.map(coords -> check(
provider,
seed,
originX + coords[0],
originZ + coords[1],
step,
filter,
search3D,
minHeight,
maxHeight
))
.filter(Optional::isPresent)
.map(Optional::get)
.findFirst(); // findFirst() respects encounter order (North -> East -> South -> West)
Optional<Either<Vector3Int, Vector2Int>> ringResult = Stream.of(northSide, eastSide, southSide, westSide)
.flatMap(identity())
.parallel()
.map(coords -> check(
provider,
seed,
originX + coords[0],
originZ + coords[1],
step,
filter,
search3D,
minHeight,
maxHeight
))
.flatMap(Maybe::toStream)
.findFirst(); // findFirst() respects encounter order (North -> East -> South -> West)
if (ringResult.isPresent()) {
return ringResult;
}
}
if(ringResult.isPresent()) {
return fromOptional(ringResult);
}
}
return nothing();
});
return Optional.empty();
}
/**
* Helper to check a specific coordinate column or point.
* This logic is executed inside the worker threads.
*/
private static Optional<Either<Vector3Int, Vector2Int>> check(
private static Maybe<Either<Vector3Int, Vector2Int>> check(
BiomeProvider provider,
long seed,
int x,
@@ -112,20 +117,20 @@ public class BiomeLocator {
int minHeight,
int maxHeight
) {
if (search3D) {
if(search3D) {
// Iterate from bottom to top of the world using the step
for (int y = minHeight; y < maxHeight; y += step) {
if (filter.test(provider.getBiome(x, y, z, seed))) {
return Optional.of(Either.left(Vector3Int.of(x, y, z)));
for(int y = minHeight; y < maxHeight; y += step) {
if(filter.test(provider.getBiome(x, y, z, seed))) {
return just(left(Vector3Int.of(x, y, z)));
}
}
return Optional.empty();
return nothing();
} else {
// 2D Mode: Check only the base biome
// We use a flatMap approach here to be safe with Optionals inside the stream
return provider.getBaseBiome(x, z, seed)
.filter(filter)
.map(b -> Either.right(Vector2Int.of(x, z)));
.map(b -> right(Vector2Int.of(x, z)));
}
}
}
@@ -3,14 +3,15 @@ package com.dfsek.terra.addons.commands.locate;
import com.dfsek.seismic.type.vector.Vector2Int;
import com.dfsek.seismic.type.vector.Vector3Int;
import com.dfsek.terra.api.util.generic.data.types.Maybe;
import org.incendo.cloud.CommandManager;
import org.incendo.cloud.component.DefaultValue;
import org.incendo.cloud.context.CommandContext;
import org.incendo.cloud.description.Description;
import org.incendo.cloud.parser.standard.IntegerParser;
import java.util.Optional;
import com.dfsek.terra.addons.manifest.api.AddonInitializer;
import com.dfsek.terra.api.Platform;
import com.dfsek.terra.api.addon.BaseAddon;
@@ -21,11 +22,13 @@ import com.dfsek.terra.api.event.events.platform.CommandRegistrationEvent;
import com.dfsek.terra.api.event.functional.FunctionalEventHandler;
import com.dfsek.terra.api.inject.annotations.Inject;
import com.dfsek.terra.api.registry.Registry;
import com.dfsek.terra.api.util.generic.either.Either;
import com.dfsek.terra.api.util.generic.data.types.Either;
import com.dfsek.terra.api.util.reflection.TypeKey;
import com.dfsek.terra.api.world.World;
import com.dfsek.terra.api.world.biome.Biome;
import static com.dfsek.terra.api.util.generic.data.types.Either.collapse;
public class LocateCommandAddon implements AddonInitializer {
@Inject
@@ -35,7 +38,7 @@ public class LocateCommandAddon implements AddonInitializer {
private BaseAddon addon;
private static Registry<Biome> getBiomeRegistry(CommandContext<CommandSender> sender) {
return sender.sender().getEntity().orElseThrow().world().getPack().getRegistry(Biome.class);
return sender.sender().entity().orThrow().world().getPack().getRegistry(Biome.class);
}
@Override
@@ -63,7 +66,7 @@ public class LocateCommandAddon implements AddonInitializer {
.handler(context -> {
// 1. Gather Context & Arguments
Biome targetBiome = context.get("biome");
Entity sender = context.sender().getEntity().orElseThrow(
Entity sender = context.sender().entity().orThrow(
() -> new Error("Only entities can run this command."));
World world = sender.world();
@@ -83,7 +86,7 @@ public class LocateCommandAddon implements AddonInitializer {
context.sender().sendMessage(
"Searching for " + targetBiome.getID() + " within " + radius + " blocks" + modeMsg + "...");
Optional<Either<Vector3Int, Vector2Int>> result;
Maybe<Either<Vector3Int, Vector2Int>> result;
// 3. Execute Search Loop
while(true) {
@@ -100,7 +103,7 @@ public class LocateCommandAddon implements AddonInitializer {
// Exit Conditions:
// 1. Found a result
if(result.isPresent()) {
if(result.isJust()) {
break;
}
// 2. Not in auto mode (only run once)
@@ -118,22 +121,11 @@ public class LocateCommandAddon implements AddonInitializer {
}
// 4. Handle Result
if(result.isPresent()) {
Either<Vector3Int, Vector2Int> location = result.get();
String coords;
if(location.hasLeft()) { // 3D Result
Vector3Int vec = location.getLeft().get();
coords = String.format("%d, %d, %d", vec.getX(), vec.getY(), vec.getZ());
} else { // 2D Result
Vector2Int vec = location.getRight().get();
coords = String.format("%d, ~, %d", vec.getX(), vec.getZ());
}
context.sender().sendMessage("Found " + targetBiome.getID() + " at [" + coords + "]");
} else {
context.sender().sendMessage("Could not find " + targetBiome.getID() + " within " + radius + " blocks.");
}
context.sender().sendMessage(collapse(result.map(location -> location.collect(
left -> String.format("%d, %d, %d", left.getX(), left.getY(), left.getZ()),
right -> String.format("%d, ~, %d", right.getX(), right.getZ())))
.map(coords -> "Found " + targetBiome.getID() + " at [" + coords + "]")
.toEither("Could not find " + targetBiome.getID() + " within " + radius + " blocks.")));
})
.permission("terra.locate.biome")
);
+1 -1
View File
@@ -1,5 +1,5 @@
version = version("1.0.0")
dependencies {
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
compileOnlyApi(project(":common:addons:addon-loader-manifest"))
}
@@ -1,5 +1,5 @@
version = version("1.0.0")
dependencies {
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
compileOnlyApi(project(":common:addons:addon-loader-manifest"))
}
@@ -1,5 +1,5 @@
version = version("1.0.0")
dependencies {
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
compileOnlyApi(project(":common:addons:addon-loader-manifest"))
}
@@ -34,7 +34,7 @@ public class StructureCommandAddon implements AddonInitializer {
private BaseAddon addon;
private static Registry<Structure> getStructureRegistry(CommandContext<CommandSender> sender) {
return sender.sender().getEntity().orElseThrow().world().getPack().getRegistry(Structure.class);
return sender.sender().entity().orThrow().world().getPack().getRegistry(Structure.class);
}
@Override
@@ -55,7 +55,7 @@ public class StructureCommandAddon implements AddonInitializer {
.optional("rotation", EnumParser.enumParser(Rotation.class), DefaultValue.constant(Rotation.NONE))
.handler(context -> {
Structure structure = context.get("structure");
Entity sender = context.sender().getEntity().orElseThrow();
Entity sender = context.sender().entity().orThrow();
structure.generate(
sender.position().toInt(),
sender.world(),
+1 -1
View File
@@ -1,5 +1,5 @@
version = version("1.0.0")
dependencies {
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
compileOnlyApi(project(":common:addons:addon-loader-manifest"))
}
@@ -1,5 +1,5 @@
version = version("1.0.1")
dependencies {
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
compileOnlyApi(project(":common:addons:addon-loader-manifest"))
}
@@ -1,5 +1,5 @@
version = version("1.0.0")
dependencies {
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
compileOnlyApi(project(":common:addons:addon-loader-manifest"))
}
+1 -1
View File
@@ -1,5 +1,5 @@
version = version("1.0.1")
dependencies {
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
compileOnlyApi(project(":common:addons:addon-loader-manifest"))
}
@@ -17,7 +17,7 @@ import java.util.List;
import com.dfsek.terra.addons.flora.flora.gen.BlockLayer;
import com.dfsek.terra.api.config.AbstractableTemplate;
import com.dfsek.terra.api.config.meta.Meta;
import com.dfsek.terra.api.util.collection.MaterialSet;
import com.dfsek.terra.api.util.collection.BlockStateSet;
@SuppressWarnings({ "FieldMayBeFinal", "unused" })
@@ -27,7 +27,7 @@ public class FloraTemplate implements AbstractableTemplate {
private String id;
@Value("rotatable")
@Default
private @Meta MaterialSet rotatable = MaterialSet.empty();
private @Meta BlockStateSet rotatable = BlockStateSet.empty();
@Value("physics")
@Default
@@ -63,7 +63,7 @@ public class FloraTemplate implements AbstractableTemplate {
return ceiling;
}
public MaterialSet getRotatable() {
public BlockStateSet getRotatable() {
return rotatable;
}
}
@@ -20,7 +20,7 @@ import java.util.random.RandomGeneratorFactory;
import com.dfsek.terra.api.block.state.BlockState;
import com.dfsek.terra.api.block.state.properties.enums.Direction;
import com.dfsek.terra.api.structure.Structure;
import com.dfsek.terra.api.util.collection.MaterialSet;
import com.dfsek.terra.api.util.collection.BlockStateSet;
import com.dfsek.terra.api.util.collection.ProbabilityCollection;
import com.dfsek.terra.api.world.WritableWorld;
@@ -30,14 +30,14 @@ public class TerraFlora implements Structure {
private final boolean physics;
private final boolean ceiling;
private final MaterialSet testRotation;
private final BlockStateSet testRotation;
private final Sampler distribution;
private final String id;
public TerraFlora(List<BlockLayer> layers, boolean physics, boolean ceiling,
MaterialSet testRotation,
BlockStateSet testRotation,
Sampler distribution, String id) {
this.physics = physics;
this.testRotation = testRotation;
@@ -55,7 +55,7 @@ public class TerraFlora implements Structure {
private void test(EnumSet<Direction> faces, Direction f, Vector3Int b, WritableWorld world) {
if(testRotation.contains(
world.getBlockState(b.getX() + f.getModX(), b.getY() + f.getModY(), b.getZ() + f.getModZ()).getBlockType()))
world.getBlockState(b.getX() + f.getModX(), b.getY() + f.getModY(), b.getZ() + f.getModZ()).blockType()))
faces.add(f);
}
@@ -1,5 +1,5 @@
version = version("1.1.1")
dependencies {
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
compileOnlyApi(project(":common:addons:addon-loader-manifest"))
}

Some files were not shown because too many files have changed in this diff Show More