mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-05-20 08:40:26 +00:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 2e3ce78521 |
@@ -44,6 +44,7 @@ You must put an x in all the boxes that it applies to. (Like this: [x])
|
||||
<!-- There is an included `.editorconfig` file in the base of the repo. Please use a plugin for your IDE of choice that follows those settings. -->
|
||||
- [ ] I have read the [`CONTRIBUTING.md`](https://github.com/PolyhedralDev/Terra/blob/master/CONTRIBUTING.md)
|
||||
document in the root of the git repository.
|
||||
- [ ] LLM-based tools were not used to create this PR. (ChatGPT, Claude, etc)
|
||||
|
||||
#### Types of changes
|
||||
|
||||
@@ -98,7 +99,7 @@ You must put an x in all the boxes that it applies to. (Like this: [x])
|
||||
- [ ] I am not the original author of this code, but it is in public domain or
|
||||
released under [GPLv3](https://www.gnu.org/licenses/gpl-3.0.en.html) or a compatible license.
|
||||
<!--
|
||||
Please provide reliable evidence of this.
|
||||
Please provide reliable evidence of this. LLM-generated code does not satisfy this requirement.
|
||||
NOTE: for compatible licenses, you must make sure to add the included license somewhere in the program, if so required.
|
||||
(And even if it's not required, it's still nice to do it. Also add attribution somewhere.)
|
||||
-->
|
||||
|
||||
+5
-2
@@ -258,6 +258,9 @@ as [GitHub Pull Requests](https://guides.github.com/activities/forking/#making-a
|
||||
see instead** and why.
|
||||
- **Explain why this enhancement would be useful** to most Terra users and isn't
|
||||
something that can or should be implemented as an addon.
|
||||
- **Do not use LLM/"AI" tools to create your pull request.** Your pr should be written
|
||||
by you. Using an LLM to automate small, tedious tasks (regex and other fiddly things like it)
|
||||
is acceptable, but submitting a low-effort, completely LLM-generated PR will result in a ban.
|
||||
|
||||
## Styleguides
|
||||
|
||||
@@ -381,7 +384,7 @@ compatibilities are welcome and encouraged, in the form of addons.**
|
||||
|
||||
### Platform-Agnostic Design
|
||||
|
||||
Terra must, at all times, remain platform agnostic. This means it must be able
|
||||
Terra must, at all times, remain platform-agnostic. This means it must be able
|
||||
to run on theoretically any voxel based platform. Including non-minecraft games
|
||||
like Terasology.
|
||||
|
||||
@@ -391,7 +394,7 @@ it'll be running on.
|
||||
Examples:
|
||||
|
||||
- Don't assume the world height is 256.
|
||||
- Don't assume that a specific block, item, or entity exists. (Eg. don't assume
|
||||
- Don't assume that a specific block, item, or entity exists. (E.g. don't assume
|
||||
there exists a block called `minecraft:grass_block`)
|
||||
|
||||
### Data-Driven
|
||||
|
||||
+1
-1
@@ -15,7 +15,7 @@ public class ApiAddon implements BaseAddon {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Version version() {
|
||||
public Version getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
+1
-1
@@ -33,7 +33,7 @@ public class ApiAddonLoader implements BootstrapBaseAddon<BaseAddon> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Version version() {
|
||||
public Version getVersion() {
|
||||
return VERSION;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
version = version("1.0.0")
|
||||
|
||||
dependencies {
|
||||
compileOnlyApi(project(":common:addons:addon-loader-manifest"))
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
version = version("1.1.0")
|
||||
|
||||
dependencies {
|
||||
compileOnlyApi(project(":common:addons:addon-loader-manifest"))
|
||||
|
||||
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
version = version("1.0.0")
|
||||
|
||||
dependencies {
|
||||
compileOnlyApi(project(":common:addons:addon-loader-manifest"))
|
||||
compileOnlyApi(project(":common:addons:api-biome-query"))
|
||||
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
|
||||
compileOnlyApi(project(":common:addons:biome-query-api"))
|
||||
}
|
||||
|
||||
+2
-3
@@ -9,7 +9,6 @@ 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;
|
||||
|
||||
@@ -40,11 +39,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))
|
||||
.get(() -> BiomeProvider.super.getColumn(x, z, seed, min, max));
|
||||
.orElseGet(() -> BiomeProvider.super.getColumn(x, z, seed, min, max));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Maybe<Biome> getBaseBiome(int x, int z, long seed) {
|
||||
public Optional<Biome> getBaseBiome(int x, int z, long seed) {
|
||||
return delegate.getBaseBiome(x, z, seed);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -27,6 +27,6 @@ public class ReplaceableBiomeLoader implements TypeLoader<ReplaceableBiome> {
|
||||
return biomeRegistry
|
||||
.getByID((String) c)
|
||||
.map(ReplaceableBiome::of)
|
||||
.collectThrow(left -> new LoadException("No such biome: " + c + ": " + left, depthTracker));
|
||||
.orElseThrow(() -> new LoadException("No such biome: " + c, depthTracker));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,4 +11,4 @@ website:
|
||||
docs: https://terra.polydev.org
|
||||
license: MIT License
|
||||
depends:
|
||||
api-biome-query: "1.+"
|
||||
biome-query-api: "1.+"
|
||||
@@ -1,5 +1,5 @@
|
||||
# biome-provider-image-v2
|
||||
|
||||
Implements and registers the `IMAGE` biome provider, which
|
||||
utilizes various config types provided by the `api-image` addon to
|
||||
utilizes various config types provided by the `library-image` addon to
|
||||
distribute biomes based on images.
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
version = version("2.0.0")
|
||||
|
||||
dependencies {
|
||||
compileOnlyApi(project(":common:addons:addon-loader-manifest"))
|
||||
compileOnlyApi(project(":common:addons:api-image"))
|
||||
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
|
||||
compileOnlyApi(project(":common:addons:library-image"))
|
||||
|
||||
|
||||
}
|
||||
|
||||
+2
-3
@@ -11,7 +11,6 @@ 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;
|
||||
|
||||
@@ -41,8 +40,8 @@ public class ImageBiomeProvider implements BiomeProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Maybe<Biome> getBaseBiome(int x, int z, long seed) {
|
||||
return Maybe.just(getBiome(x, z));
|
||||
public Optional<Biome> getBaseBiome(int x, int z, long seed) {
|
||||
return Optional.of(getBiome(x, z));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -11,4 +11,4 @@ website:
|
||||
docs: https://terra.polydev.org
|
||||
license: MIT License
|
||||
depends:
|
||||
api-image: "1.+"
|
||||
library-image: "1.+"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
version = version("2.0.0")
|
||||
|
||||
dependencies {
|
||||
compileOnlyApi(project(":common:addons:addon-loader-manifest"))
|
||||
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
|
||||
}
|
||||
+2
-5
@@ -8,9 +8,6 @@
|
||||
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;
|
||||
|
||||
@@ -109,8 +106,8 @@ public class PipelineBiomeProvider implements BiomeProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Maybe<Biome> getBaseBiome(int x, int z, long seed) {
|
||||
return Maybe.just(getBiome(x, z, seed));
|
||||
public Optional<Biome> getBaseBiome(int x, int z, long seed) {
|
||||
return Optional.of(getBiome(x, z, seed));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+1
-2
@@ -7,7 +7,6 @@ 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;
|
||||
@@ -28,6 +27,6 @@ public class PipelineBiomeLoader implements TypeLoader<PipelineBiome> {
|
||||
return biomeRegistry
|
||||
.getByID((String) c)
|
||||
.map(PipelineBiome::from)
|
||||
.collect(left -> PipelineBiome.placeholder((String) c), Function.identity());
|
||||
.orElseGet(() -> PipelineBiome.placeholder((String) c));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
version = version("1.0.0")
|
||||
|
||||
dependencies {
|
||||
compileOnlyApi(project(":common:addons:addon-loader-manifest"))
|
||||
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
|
||||
}
|
||||
|
||||
+9
-4
@@ -8,13 +8,18 @@
|
||||
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 record SingleBiomeProvider(Biome biome) implements BiomeProvider {
|
||||
public class SingleBiomeProvider implements BiomeProvider {
|
||||
private final Biome biome;
|
||||
|
||||
public SingleBiomeProvider(Biome biome) {
|
||||
this.biome = biome;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Biome getBiome(int x, int y, int z, long seed) {
|
||||
@@ -22,8 +27,8 @@ public record SingleBiomeProvider(Biome biome) implements BiomeProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Maybe<Biome> getBaseBiome(int x, int z, long seed) {
|
||||
return Maybe.just(biome);
|
||||
public Optional<Biome> getBaseBiome(int x, int z, long seed) {
|
||||
return Optional.of(biome);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
version = version("1.0.0")
|
||||
|
||||
dependencies {
|
||||
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
|
||||
}
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
schema-version: 1
|
||||
contributors:
|
||||
- Terra contributors
|
||||
id: api-biome-query
|
||||
id: biome-query-api
|
||||
version: @VERSION@
|
||||
entrypoints:
|
||||
- "com.dfsek.terra.addons.biome.query.BiomeQueryAPIAddon"
|
||||
@@ -1,5 +1,5 @@
|
||||
version = version("1.2.1")
|
||||
|
||||
dependencies {
|
||||
compileOnlyApi(project(":common:addons:addon-loader-manifest"))
|
||||
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
|
||||
}
|
||||
|
||||
+1
-1
@@ -30,7 +30,7 @@ public class ElevationInterpolator {
|
||||
gens[x + 1 + smooth][z + 1 + smooth] =
|
||||
provider
|
||||
.getBaseBiome(bx, bz, seed)
|
||||
.get(() -> provider.getBiome(bx, 0, bz, seed)) // kind of a hack
|
||||
.orElseGet(() -> 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:addon-loader-manifest"))
|
||||
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
|
||||
}
|
||||
|
||||
+3
-3
@@ -39,7 +39,7 @@ public class AddonsCommandAddon implements AddonInitializer {
|
||||
.append(" - ")
|
||||
.append(addon.getID())
|
||||
.append('@')
|
||||
.append(addon.version().getFormatted())
|
||||
.append(addon.getVersion().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.version().getFormatted()).append('\n');
|
||||
addonInfo.append("Version: ").append(addon.getVersion().getFormatted()).append('\n');
|
||||
|
||||
addonInfo.append("Dependencies:\n");
|
||||
addon.dependencies().forEach((id, versions) -> addonInfo
|
||||
addon.getDependencies().forEach((id, versions) -> addonInfo
|
||||
.append(" - ")
|
||||
.append(id)
|
||||
.append('@')
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
version = version("1.0.0")
|
||||
|
||||
dependencies {
|
||||
compileOnlyApi(project(":common:addons:addon-loader-manifest"))
|
||||
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
|
||||
}
|
||||
|
||||
+52
-57
@@ -2,13 +2,10 @@ 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.Either;
|
||||
import com.dfsek.terra.api.util.generic.data.types.Maybe;
|
||||
import com.dfsek.terra.api.util.generic.either.Either;
|
||||
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;
|
||||
@@ -16,8 +13,6 @@ 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 {
|
||||
|
||||
@@ -32,10 +27,9 @@ 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 Maybe<Either<Vector3Int, Vector2Int>> search(
|
||||
public static Optional<Either<Vector3Int, Vector2Int>> search(
|
||||
@NotNull BiomeProvider provider,
|
||||
@NotNull WorldProperties properties,
|
||||
int originX,
|
||||
@@ -50,63 +44,64 @@ public class BiomeLocator {
|
||||
int maxHeight = properties.getMaxHeight();
|
||||
|
||||
// 1. Check the exact center first
|
||||
return
|
||||
check(provider, seed, originX, originZ, step, filter, search3D, minHeight, maxHeight)
|
||||
Optional<Either<Vector3Int, Vector2Int>> centerResult = check(provider, seed, originX, originZ, step, filter, search3D, minHeight, maxHeight);
|
||||
if (centerResult.isPresent()) {
|
||||
return centerResult;
|
||||
}
|
||||
|
||||
// 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;
|
||||
// 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;
|
||||
|
||||
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(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)
|
||||
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)
|
||||
|
||||
if(ringResult.isPresent()) {
|
||||
return fromOptional(ringResult);
|
||||
}
|
||||
}
|
||||
return nothing();
|
||||
});
|
||||
if (ringResult.isPresent()) {
|
||||
return ringResult;
|
||||
}
|
||||
}
|
||||
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper to check a specific coordinate column or point.
|
||||
* This logic is executed inside the worker threads.
|
||||
*/
|
||||
private static Maybe<Either<Vector3Int, Vector2Int>> check(
|
||||
private static Optional<Either<Vector3Int, Vector2Int>> check(
|
||||
BiomeProvider provider,
|
||||
long seed,
|
||||
int x,
|
||||
@@ -117,20 +112,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 just(left(Vector3Int.of(x, y, z)));
|
||||
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)));
|
||||
}
|
||||
}
|
||||
return nothing();
|
||||
return Optional.empty();
|
||||
} 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 -> right(Vector2Int.of(x, z)));
|
||||
.map(b -> Either.right(Vector2Int.of(x, z)));
|
||||
}
|
||||
}
|
||||
}
|
||||
+23
-15
@@ -3,15 +3,14 @@ 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;
|
||||
@@ -22,13 +21,11 @@ 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.data.types.Either;
|
||||
import com.dfsek.terra.api.util.generic.either.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
|
||||
@@ -38,7 +35,7 @@ public class LocateCommandAddon implements AddonInitializer {
|
||||
private BaseAddon addon;
|
||||
|
||||
private static Registry<Biome> getBiomeRegistry(CommandContext<CommandSender> sender) {
|
||||
return sender.sender().entity().orThrow().world().getPack().getRegistry(Biome.class);
|
||||
return sender.sender().getEntity().orElseThrow().world().getPack().getRegistry(Biome.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -66,7 +63,7 @@ public class LocateCommandAddon implements AddonInitializer {
|
||||
.handler(context -> {
|
||||
// 1. Gather Context & Arguments
|
||||
Biome targetBiome = context.get("biome");
|
||||
Entity sender = context.sender().entity().orThrow(
|
||||
Entity sender = context.sender().getEntity().orElseThrow(
|
||||
() -> new Error("Only entities can run this command."));
|
||||
World world = sender.world();
|
||||
|
||||
@@ -86,7 +83,7 @@ public class LocateCommandAddon implements AddonInitializer {
|
||||
context.sender().sendMessage(
|
||||
"Searching for " + targetBiome.getID() + " within " + radius + " blocks" + modeMsg + "...");
|
||||
|
||||
Maybe<Either<Vector3Int, Vector2Int>> result;
|
||||
Optional<Either<Vector3Int, Vector2Int>> result;
|
||||
|
||||
// 3. Execute Search Loop
|
||||
while(true) {
|
||||
@@ -103,7 +100,7 @@ public class LocateCommandAddon implements AddonInitializer {
|
||||
|
||||
// Exit Conditions:
|
||||
// 1. Found a result
|
||||
if(result.isJust()) {
|
||||
if(result.isPresent()) {
|
||||
break;
|
||||
}
|
||||
// 2. Not in auto mode (only run once)
|
||||
@@ -121,11 +118,22 @@ public class LocateCommandAddon implements AddonInitializer {
|
||||
}
|
||||
|
||||
// 4. Handle Result
|
||||
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.")));
|
||||
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.");
|
||||
}
|
||||
})
|
||||
.permission("terra.locate.biome")
|
||||
);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
version = version("1.0.0")
|
||||
|
||||
dependencies {
|
||||
compileOnlyApi(project(":common:addons:addon-loader-manifest"))
|
||||
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
version = version("1.0.0")
|
||||
|
||||
dependencies {
|
||||
compileOnlyApi(project(":common:addons:addon-loader-manifest"))
|
||||
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
version = version("1.0.0")
|
||||
|
||||
dependencies {
|
||||
compileOnlyApi(project(":common:addons:addon-loader-manifest"))
|
||||
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
|
||||
}
|
||||
|
||||
+2
-2
@@ -34,7 +34,7 @@ public class StructureCommandAddon implements AddonInitializer {
|
||||
private BaseAddon addon;
|
||||
|
||||
private static Registry<Structure> getStructureRegistry(CommandContext<CommandSender> sender) {
|
||||
return sender.sender().entity().orThrow().world().getPack().getRegistry(Structure.class);
|
||||
return sender.sender().getEntity().orElseThrow().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().entity().orThrow();
|
||||
Entity sender = context.sender().getEntity().orElseThrow();
|
||||
structure.generate(
|
||||
sender.position().toInt(),
|
||||
sender.world(),
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
version = version("1.0.0")
|
||||
|
||||
dependencies {
|
||||
compileOnlyApi(project(":common:addons:addon-loader-manifest"))
|
||||
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
version = version("1.0.1")
|
||||
|
||||
dependencies {
|
||||
compileOnlyApi(project(":common:addons:addon-loader-manifest"))
|
||||
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
version = version("1.0.0")
|
||||
|
||||
dependencies {
|
||||
compileOnlyApi(project(":common:addons:addon-loader-manifest"))
|
||||
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
version = version("1.0.1")
|
||||
|
||||
dependencies {
|
||||
compileOnlyApi(project(":common:addons:addon-loader-manifest"))
|
||||
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
|
||||
}
|
||||
|
||||
+3
-3
@@ -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.BlockStateSet;
|
||||
import com.dfsek.terra.api.util.collection.MaterialSet;
|
||||
|
||||
|
||||
@SuppressWarnings({ "FieldMayBeFinal", "unused" })
|
||||
@@ -27,7 +27,7 @@ public class FloraTemplate implements AbstractableTemplate {
|
||||
private String id;
|
||||
@Value("rotatable")
|
||||
@Default
|
||||
private @Meta BlockStateSet rotatable = BlockStateSet.empty();
|
||||
private @Meta MaterialSet rotatable = MaterialSet.empty();
|
||||
|
||||
@Value("physics")
|
||||
@Default
|
||||
@@ -63,7 +63,7 @@ public class FloraTemplate implements AbstractableTemplate {
|
||||
return ceiling;
|
||||
}
|
||||
|
||||
public BlockStateSet getRotatable() {
|
||||
public MaterialSet getRotatable() {
|
||||
return rotatable;
|
||||
}
|
||||
}
|
||||
|
||||
+4
-4
@@ -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.BlockStateSet;
|
||||
import com.dfsek.terra.api.util.collection.MaterialSet;
|
||||
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 BlockStateSet testRotation;
|
||||
private final MaterialSet testRotation;
|
||||
|
||||
private final Sampler distribution;
|
||||
|
||||
private final String id;
|
||||
|
||||
public TerraFlora(List<BlockLayer> layers, boolean physics, boolean ceiling,
|
||||
BlockStateSet testRotation,
|
||||
MaterialSet 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()).blockType()))
|
||||
world.getBlockState(b.getX() + f.getModX(), b.getY() + f.getModY(), b.getZ() + f.getModZ()).getBlockType()))
|
||||
faces.add(f);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
version = version("1.1.1")
|
||||
|
||||
dependencies {
|
||||
compileOnlyApi(project(":common:addons:addon-loader-manifest"))
|
||||
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
|
||||
}
|
||||
+1
-1
@@ -24,6 +24,6 @@ public class AirMatchPatternTemplate implements ObjectTemplate<Pattern> {
|
||||
|
||||
@Override
|
||||
public Pattern get() {
|
||||
return new MatchPattern(offset, BlockState::air);
|
||||
return new MatchPattern(offset, BlockState::isAir);
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -13,19 +13,19 @@ import com.dfsek.tectonic.api.config.template.object.ObjectTemplate;
|
||||
import com.dfsek.terra.addons.feature.locator.patterns.MatchPattern;
|
||||
import com.dfsek.terra.addons.feature.locator.patterns.Pattern;
|
||||
import com.dfsek.terra.api.config.meta.Meta;
|
||||
import com.dfsek.terra.api.util.collection.BlockStateSet;
|
||||
import com.dfsek.terra.api.util.collection.MaterialSet;
|
||||
import com.dfsek.terra.api.util.range.Range;
|
||||
|
||||
|
||||
public class BlockSetMatchPatternTemplate implements ObjectTemplate<Pattern> {
|
||||
@Value("blocks")
|
||||
private @Meta BlockStateSet blocks;
|
||||
private @Meta MaterialSet blocks;
|
||||
|
||||
@Value("offset")
|
||||
private @Meta Range offset;
|
||||
|
||||
@Override
|
||||
public Pattern get() {
|
||||
return new MatchPattern(offset, blockState -> blocks.contains(blockState.blockType()));
|
||||
return new MatchPattern(offset, blockState -> blocks.contains(blockState.getBlockType()));
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -21,6 +21,6 @@ public class SolidMatchPatternTemplate implements ObjectTemplate<Pattern> {
|
||||
|
||||
@Override
|
||||
public Pattern get() {
|
||||
return new MatchPattern(offset, blockState -> blockState.blockType().solid());
|
||||
return new MatchPattern(offset, blockState -> blockState.getBlockType().isSolid());
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -28,7 +28,7 @@ public class SurfaceLocator implements Locator {
|
||||
int min = Math.max(search.getMin(), column.getMinY());
|
||||
if(min >= max) return builder.build();
|
||||
for(int y = min; y < max; y++) {
|
||||
if(column.getBlock(y).air() && !column.getBlock(y - 1).air()) {
|
||||
if(column.getBlock(y).isAir() && !column.getBlock(y - 1).isAir()) {
|
||||
builder.set(y);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -23,7 +23,7 @@ public class TopLocator implements Locator {
|
||||
@Override
|
||||
public BinaryColumn getSuitableCoordinates(Column<?> column) {
|
||||
for(int y = search.getMax(); y >= search.getMin(); y--) {
|
||||
if(column.getBlock(y).air() && !column.getBlock(y - 1).air()) {
|
||||
if(column.getBlock(y).isAir() && !column.getBlock(y - 1).isAir()) {
|
||||
return new BinaryColumn(y, y + 1, yi -> true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
version = version("1.2.0")
|
||||
|
||||
dependencies {
|
||||
compileOnlyApi(project(":common:addons:addon-loader-manifest"))
|
||||
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
|
||||
api("com.dfsek", "paralithic", Versions.Libraries.paralithic)
|
||||
}
|
||||
|
||||
+6
-6
@@ -8,8 +8,8 @@ import org.jetbrains.annotations.ApiStatus.Experimental;
|
||||
|
||||
import com.dfsek.terra.api.util.cache.DoubleSeededVector2Key;
|
||||
import com.dfsek.terra.api.util.cache.DoubleSeededVector3Key;
|
||||
import com.dfsek.terra.api.util.generic.data.types.Pair;
|
||||
import com.dfsek.terra.api.util.generic.data.types.Pair.Mutable;
|
||||
import com.dfsek.terra.api.util.generic.pair.Pair;
|
||||
import com.dfsek.terra.api.util.generic.pair.Pair.Mutable;
|
||||
|
||||
import static com.dfsek.terra.api.util.cache.CacheUtils.CACHE_EXECUTOR;
|
||||
|
||||
@@ -63,16 +63,16 @@ public class CacheSampler implements Sampler {
|
||||
@Override
|
||||
public double getSample(long seed, double x, double y) {
|
||||
Mutable<DoubleSeededVector2Key, LoadingCache<DoubleSeededVector2Key, Double>> cachePair = cache2D.get();
|
||||
DoubleSeededVector2Key mutableKey = cachePair.left();
|
||||
DoubleSeededVector2Key mutableKey = cachePair.getLeft();
|
||||
mutableKey.set(x, y, seed);
|
||||
return cachePair.right().get(mutableKey);
|
||||
return cachePair.getRight().get(mutableKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getSample(long seed, double x, double y, double z) {
|
||||
Mutable<DoubleSeededVector3Key, LoadingCache<DoubleSeededVector3Key, Double>> cachePair = cache3D.get();
|
||||
DoubleSeededVector3Key mutableKey = cachePair.left();
|
||||
DoubleSeededVector3Key mutableKey = cachePair.getLeft();
|
||||
mutableKey.set(x, y, z, seed);
|
||||
return cachePair.right().get(mutableKey);
|
||||
return cachePair.getRight().get(mutableKey);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
version = version("1.0.0")
|
||||
|
||||
dependencies {
|
||||
compileOnlyApi(project(":common:addons:addon-loader-manifest"))
|
||||
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
|
||||
api("com.dfsek", "paralithic", Versions.Libraries.paralithic)
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
version = version("1.1.1")
|
||||
|
||||
dependencies {
|
||||
compileOnlyApi(project(":common:addons:addon-loader-manifest"))
|
||||
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ import com.dfsek.terra.api.block.BlockType;
|
||||
import com.dfsek.terra.api.block.state.BlockState;
|
||||
import com.dfsek.terra.api.config.AbstractableTemplate;
|
||||
import com.dfsek.terra.api.config.meta.Meta;
|
||||
import com.dfsek.terra.api.util.collection.BlockStateSet;
|
||||
import com.dfsek.terra.api.util.collection.MaterialSet;
|
||||
|
||||
|
||||
@SuppressWarnings({ "unused", "FieldMayBeFinal" })
|
||||
@@ -36,7 +36,7 @@ public class OreTemplate implements AbstractableTemplate {
|
||||
private @Meta Map<@Meta BlockType, @Meta BlockState> materials = new HashMap<>();
|
||||
|
||||
@Value("replace")
|
||||
private @Meta BlockStateSet replaceable;
|
||||
private @Meta MaterialSet replaceable;
|
||||
|
||||
@Value("physics")
|
||||
@Default
|
||||
@@ -62,7 +62,7 @@ public class OreTemplate implements AbstractableTemplate {
|
||||
return material;
|
||||
}
|
||||
|
||||
public BlockStateSet getReplaceable() {
|
||||
public MaterialSet getReplaceable() {
|
||||
return replaceable;
|
||||
}
|
||||
|
||||
|
||||
+5
-5
@@ -20,7 +20,7 @@ import java.util.random.RandomGenerator;
|
||||
import com.dfsek.terra.api.block.BlockType;
|
||||
import com.dfsek.terra.api.block.state.BlockState;
|
||||
import com.dfsek.terra.api.structure.Structure;
|
||||
import com.dfsek.terra.api.util.collection.BlockStateSet;
|
||||
import com.dfsek.terra.api.util.collection.MaterialSet;
|
||||
import com.dfsek.terra.api.world.WritableWorld;
|
||||
|
||||
import static com.dfsek.terra.addons.ore.utils.VanillaOreUtils.shouldPlace;
|
||||
@@ -31,12 +31,12 @@ public class VanillaOre implements Structure {
|
||||
protected final BlockState material;
|
||||
|
||||
protected final double size;
|
||||
protected final BlockStateSet replaceable;
|
||||
protected final MaterialSet replaceable;
|
||||
protected final boolean applyGravity;
|
||||
protected final double exposed;
|
||||
protected final Map<BlockType, BlockState> materials;
|
||||
|
||||
public VanillaOre(BlockState material, double size, BlockStateSet replaceable, boolean applyGravity,
|
||||
public VanillaOre(BlockState material, double size, MaterialSet replaceable, boolean applyGravity,
|
||||
double exposed, Map<BlockType, BlockState> materials) {
|
||||
this.material = material;
|
||||
this.size = size;
|
||||
@@ -149,7 +149,7 @@ public class VanillaOre implements Structure {
|
||||
if(!visited.get(index)) { // Skip blocks that have already been visited
|
||||
|
||||
visited.set(index);
|
||||
BlockType block = world.getBlockState(xi, yi, zi).blockType();
|
||||
BlockType block = world.getBlockState(xi, yi, zi).getBlockType();
|
||||
if(shouldPlace(getReplaceable(), block, exposed, random, world, xi, yi, zi)) {
|
||||
world.setBlockState(xi, yi, zi, getMaterial(block), isApplyGravity());
|
||||
++blockCount;
|
||||
@@ -171,7 +171,7 @@ public class VanillaOre implements Structure {
|
||||
return materials.getOrDefault(replace, material);
|
||||
}
|
||||
|
||||
public BlockStateSet getReplaceable() {
|
||||
public MaterialSet getReplaceable() {
|
||||
return replaceable;
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -8,7 +8,7 @@ import java.util.random.RandomGenerator;
|
||||
|
||||
import com.dfsek.terra.api.block.BlockType;
|
||||
import com.dfsek.terra.api.block.state.BlockState;
|
||||
import com.dfsek.terra.api.util.collection.BlockStateSet;
|
||||
import com.dfsek.terra.api.util.collection.MaterialSet;
|
||||
import com.dfsek.terra.api.world.WritableWorld;
|
||||
|
||||
import static com.dfsek.terra.addons.ore.utils.VanillaOreUtils.shouldPlace;
|
||||
@@ -17,7 +17,7 @@ import static com.dfsek.terra.addons.ore.utils.VanillaOreUtils.shouldPlace;
|
||||
public class VanillaScatteredOre extends VanillaOre {
|
||||
protected final int spread;
|
||||
|
||||
public VanillaScatteredOre(BlockState material, double size, BlockStateSet replaceable, boolean applyGravity, double exposed,
|
||||
public VanillaScatteredOre(BlockState material, double size, MaterialSet replaceable, boolean applyGravity, double exposed,
|
||||
Map<BlockType, BlockState> materials, int spread) {
|
||||
super(material, size, replaceable, applyGravity, exposed, materials);
|
||||
|
||||
@@ -31,7 +31,7 @@ public class VanillaScatteredOre extends VanillaOre {
|
||||
|
||||
for(int j = 0; j < i; ++j) {
|
||||
this.setPos(mutable, random, location, Math.min(j, spread));
|
||||
BlockType block = world.getBlockState(mutable).blockType();
|
||||
BlockType block = world.getBlockState(mutable).getBlockType();
|
||||
if(shouldPlace(getReplaceable(), block, exposed, random, world, mutable.getX(), mutable.getY(), mutable.getZ())) {
|
||||
world.setBlockState(mutable, getMaterial(block), isApplyGravity());
|
||||
}
|
||||
|
||||
+8
-8
@@ -3,7 +3,7 @@ package com.dfsek.terra.addons.ore.utils;
|
||||
import java.util.random.RandomGenerator;
|
||||
|
||||
import com.dfsek.terra.api.block.BlockType;
|
||||
import com.dfsek.terra.api.util.collection.BlockStateSet;
|
||||
import com.dfsek.terra.api.util.collection.MaterialSet;
|
||||
import com.dfsek.terra.api.world.WritableWorld;
|
||||
|
||||
|
||||
@@ -14,19 +14,19 @@ public class VanillaOreUtils {
|
||||
return random.nextFloat() < exposedChance;
|
||||
}
|
||||
|
||||
public static boolean shouldPlace(BlockStateSet replaceable, BlockType type, Double exposedChance, RandomGenerator random,
|
||||
public static boolean shouldPlace(MaterialSet replaceable, BlockType type, Double exposedChance, RandomGenerator random,
|
||||
WritableWorld world,
|
||||
int x,
|
||||
int y, int z) {
|
||||
if(!replaceable.contains(type)) return false;
|
||||
if(shouldExpose(random, exposedChance)) return true; // Exposed blocks can be placed regardless of adjacency to air
|
||||
// Adjacency is checked after determining not exposed rather than vice-versa, assuming block checks are more expensive
|
||||
boolean adjacentAir = world.getBlockState(x, y, z - 1).air() ||
|
||||
world.getBlockState(x, y, z + 1).air() ||
|
||||
world.getBlockState(x, y - 1, z).air() ||
|
||||
world.getBlockState(x, y + 1, z).air() ||
|
||||
world.getBlockState(x - 1, y, z).air() ||
|
||||
world.getBlockState(x + 1, y, z).air();
|
||||
boolean adjacentAir = world.getBlockState(x, y, z - 1).isAir() ||
|
||||
world.getBlockState(x, y, z + 1).isAir() ||
|
||||
world.getBlockState(x, y - 1, z).isAir() ||
|
||||
world.getBlockState(x, y + 1, z).isAir() ||
|
||||
world.getBlockState(x - 1, y, z).isAir() ||
|
||||
world.getBlockState(x + 1, y, z).isAir();
|
||||
return !adjacentAir; // Exposed check did not pass earlier so only blocks not adjacent air should place
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
version = version("1.0.0")
|
||||
|
||||
dependencies {
|
||||
compileOnlyApi(project(":common:addons:addon-loader-manifest"))
|
||||
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
|
||||
}
|
||||
|
||||
@@ -2,5 +2,5 @@ version = version("1.0.1")
|
||||
|
||||
dependencies {
|
||||
api("com.googlecode.json-simple:json-simple:1.1.1")
|
||||
compileOnlyApi(project(":common:addons:addon-loader-manifest"))
|
||||
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
version = version("1.1.0")
|
||||
|
||||
dependencies {
|
||||
compileOnlyApi(project(":common:addons:addon-loader-manifest"))
|
||||
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
version = version("1.0.0")
|
||||
|
||||
dependencies {
|
||||
compileOnlyApi(project(":common:addons:addon-loader-manifest"))
|
||||
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
|
||||
}
|
||||
|
||||
@@ -2,5 +2,5 @@ version = version("1.0.0")
|
||||
|
||||
dependencies {
|
||||
implementation("com.dfsek.tectonic:yaml:${Versions.Libraries.tectonic}")
|
||||
compileOnlyApi(project(":common:addons:addon-loader-manifest"))
|
||||
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
|
||||
}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
version = version("1.1.0")
|
||||
|
||||
dependencies {
|
||||
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
|
||||
|
||||
|
||||
}
|
||||
+2
-2
@@ -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.Memo;
|
||||
import com.dfsek.terra.api.util.generic.Lazy;
|
||||
|
||||
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
|
||||
Memo<Image> lazyImage = Memo.lazy(() -> images.cache.get(path));
|
||||
Lazy<Image> lazyImage = Lazy.lazy(() -> images.cache.get(path));
|
||||
return new SuppliedImage(lazyImage::value);
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user