mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-04-16 21:30:08 +00:00
remove more random
This commit is contained in:
@@ -54,8 +54,7 @@ public class StructureCommandAddon implements MonadAddonInitializer {
|
||||
structure.generate(
|
||||
sender.position().toInt(),
|
||||
sender.world(),
|
||||
context.get("rotation"), sender.world().getSeed()
|
||||
);
|
||||
context.get("rotation"));
|
||||
})
|
||||
.permission("terra.structures.generate")
|
||||
);
|
||||
|
||||
@@ -14,7 +14,7 @@ import java.util.function.Supplier;
|
||||
import com.dfsek.terra.addons.feature.distributor.config.AndDistributorTemplate;
|
||||
import com.dfsek.terra.addons.feature.distributor.config.NoDistributorTemplate;
|
||||
import com.dfsek.terra.addons.feature.distributor.config.OrDistributorTemplate;
|
||||
import com.dfsek.terra.addons.feature.distributor.config.PaddedGridDistributorTemplate;
|
||||
import com.dfsek.terra.addons.feature.distributor.config.PaddedGridSamplerDistributorTemplate;
|
||||
import com.dfsek.terra.addons.feature.distributor.config.PointSetDistributorTemplate;
|
||||
import com.dfsek.terra.addons.feature.distributor.config.SamplerDistributorTemplate;
|
||||
import com.dfsek.terra.addons.feature.distributor.config.XorDistributorTemplate;
|
||||
@@ -25,11 +25,8 @@ import com.dfsek.terra.addons.manifest.api.MonadAddonInitializer;
|
||||
import com.dfsek.terra.addons.manifest.api.monad.Do;
|
||||
import com.dfsek.terra.addons.manifest.api.monad.Get;
|
||||
import com.dfsek.terra.addons.manifest.api.monad.Init;
|
||||
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.structure.feature.Distributor;
|
||||
import com.dfsek.terra.api.util.function.monad.Monad;
|
||||
@@ -54,7 +51,7 @@ public class DistributorAddon implements MonadAddonInitializer {
|
||||
|
||||
distributorRegistry.register(base.key("SAMPLER"), SamplerDistributorTemplate::new);
|
||||
distributorRegistry.register(base.key("POINTS"), PointSetDistributorTemplate::new);
|
||||
distributorRegistry.register(base.key("PADDED_GRID"), PaddedGridDistributorTemplate::new);
|
||||
distributorRegistry.register(base.key("PADDED_GRID_SAMPLER"), PaddedGridSamplerDistributorTemplate::new);
|
||||
distributorRegistry.register(base.key("AND"), AndDistributorTemplate::new);
|
||||
distributorRegistry.register(base.key("OR"), OrDistributorTemplate::new);
|
||||
distributorRegistry.register(base.key("XOR"), XorDistributorTemplate::new);
|
||||
|
||||
@@ -3,23 +3,24 @@ package com.dfsek.terra.addons.feature.distributor.config;
|
||||
import com.dfsek.tectonic.api.config.template.annotations.Value;
|
||||
import com.dfsek.tectonic.api.config.template.object.ObjectTemplate;
|
||||
|
||||
import com.dfsek.terra.addons.feature.distributor.distributors.PaddedGridDistributor;
|
||||
import com.dfsek.terra.addons.feature.distributor.distributors.PaddedGridSamplerDistributor;
|
||||
import com.dfsek.terra.api.config.meta.Meta;
|
||||
import com.dfsek.terra.api.noise.NoiseSampler;
|
||||
import com.dfsek.terra.api.structure.feature.Distributor;
|
||||
|
||||
|
||||
public class PaddedGridDistributorTemplate implements ObjectTemplate<Distributor> {
|
||||
public class PaddedGridSamplerDistributorTemplate implements ObjectTemplate<Distributor> {
|
||||
@Value("width")
|
||||
private @Meta int width;
|
||||
|
||||
@Value("padding")
|
||||
private @Meta int padding;
|
||||
|
||||
@Value("salt")
|
||||
private @Meta int salt;
|
||||
@Value("sampler")
|
||||
private @Meta NoiseSampler noise;
|
||||
|
||||
@Override
|
||||
public Distributor get() {
|
||||
return new PaddedGridDistributor(width, padding, salt);
|
||||
return new PaddedGridSamplerDistributor(noise, width, padding);
|
||||
}
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
package com.dfsek.terra.addons.feature.distributor.distributors;
|
||||
|
||||
import net.jafama.FastMath;
|
||||
|
||||
import java.util.random.RandomGenerator;
|
||||
import java.util.random.RandomGeneratorFactory;
|
||||
|
||||
import com.dfsek.terra.api.structure.feature.Distributor;
|
||||
import com.dfsek.terra.api.util.MathUtil;
|
||||
|
||||
|
||||
public class PaddedGridDistributor implements Distributor {
|
||||
private final int width;
|
||||
|
||||
private final int cellWidth;
|
||||
|
||||
private final int salt;
|
||||
|
||||
public PaddedGridDistributor(int width, int padding, int salt) {
|
||||
this.width = width;
|
||||
this.salt = salt;
|
||||
this.cellWidth = width + padding;
|
||||
}
|
||||
|
||||
private static long murmur64(long h) {
|
||||
h ^= h >>> 33;
|
||||
h *= 0xff51afd7ed558ccdL;
|
||||
h ^= h >>> 33;
|
||||
h *= 0xc4ceb9fe1a85ec53L;
|
||||
h ^= h >>> 33;
|
||||
return h;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(int x, int z, long seed) {
|
||||
int cellX = FastMath.floorDiv(x, cellWidth);
|
||||
int cellZ = FastMath.floorDiv(z, cellWidth);
|
||||
|
||||
RandomGenerator random = RandomGeneratorFactory.<RandomGenerator.SplittableGenerator>of("Xoroshiro128PlusPlus").create(
|
||||
(murmur64(MathUtil.squash(cellX, cellZ)) ^ seed) + salt);
|
||||
|
||||
int pointX = random.nextInt(width) + cellX * cellWidth;
|
||||
int pointZ = random.nextInt(width) + cellZ * cellWidth;
|
||||
|
||||
return x == pointX && z == pointZ;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.dfsek.terra.addons.feature.distributor.distributors;
|
||||
|
||||
import com.dfsek.terra.api.noise.NoiseSampler;
|
||||
|
||||
import net.jafama.FastMath;
|
||||
|
||||
import java.util.random.RandomGenerator;
|
||||
import java.util.random.RandomGeneratorFactory;
|
||||
|
||||
import com.dfsek.terra.api.structure.feature.Distributor;
|
||||
import com.dfsek.terra.api.util.MathUtil;
|
||||
|
||||
|
||||
public class PaddedGridSamplerDistributor implements Distributor {
|
||||
private final NoiseSampler sampler;
|
||||
private final int width;
|
||||
|
||||
private final int cellWidth;
|
||||
|
||||
public PaddedGridSamplerDistributor(NoiseSampler sampler, int width, int padding) {
|
||||
this.sampler = sampler;
|
||||
this.width = width;
|
||||
this.cellWidth = width + padding;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(int x, int z, long seed) {
|
||||
int cellX = FastMath.floorDiv(x, cellWidth);
|
||||
int cellZ = FastMath.floorDiv(z, cellWidth);
|
||||
|
||||
int pointX = (int) (FastMath.round(MathUtil.lerp(MathUtil.inverseLerp(sampler.noise(x, z, seed), -1, 1), 0, width)) + cellX * cellWidth);
|
||||
int pointZ = (int) (FastMath.round(MathUtil.lerp(MathUtil.inverseLerp(sampler.noise(x, z, seed + 1), -1, 1), 0, width)) + cellZ * cellWidth);
|
||||
|
||||
return x == pointX && z == pointZ;
|
||||
}
|
||||
}
|
||||
@@ -74,7 +74,7 @@ public class TerraFlora implements Structure {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean generate(Vector3Int location, WritableWorld world, Rotation rotation, Long seed) {
|
||||
public boolean generate(Vector3Int location, WritableWorld world, Rotation rotation) {
|
||||
boolean doRotation = testRotation.size() > 0;
|
||||
int size = layers.size();
|
||||
int c = ceiling ? -1 : 1;
|
||||
@@ -86,7 +86,7 @@ public class TerraFlora implements Structure {
|
||||
for(int i = 0; FastMath.abs(i) < size; i += c) { // Down if ceiling, up if floor
|
||||
int lvl = (FastMath.abs(i));
|
||||
BlockState data = getStateCollection((ceiling ? lvl : size - lvl - 1)).get(distribution, location.getX(), location.getY(),
|
||||
location.getZ(), seed);
|
||||
location.getZ(), world.getSeed());
|
||||
|
||||
world.setBlockState(location.mutable().add(0, i + c, 0).immutable(), data, physics);
|
||||
}
|
||||
|
||||
@@ -13,10 +13,8 @@ import java.util.function.Supplier;
|
||||
|
||||
import com.dfsek.terra.addons.feature.locator.config.AdjacentPatternLocatorTemplate;
|
||||
import com.dfsek.terra.addons.feature.locator.config.AndLocatorTemplate;
|
||||
import com.dfsek.terra.addons.feature.locator.config.GaussianRandomLocatorTemplate;
|
||||
import com.dfsek.terra.addons.feature.locator.config.OrLocatorTemplate;
|
||||
import com.dfsek.terra.addons.feature.locator.config.PatternLocatorTemplate;
|
||||
import com.dfsek.terra.addons.feature.locator.config.RandomLocatorTemplate;
|
||||
import com.dfsek.terra.addons.feature.locator.config.Sampler3DLocatorTemplate;
|
||||
import com.dfsek.terra.addons.feature.locator.config.SamplerLocatorTemplate;
|
||||
import com.dfsek.terra.addons.feature.locator.config.SurfaceLocatorTemplate;
|
||||
@@ -35,11 +33,8 @@ import com.dfsek.terra.addons.manifest.api.MonadAddonInitializer;
|
||||
import com.dfsek.terra.addons.manifest.api.monad.Do;
|
||||
import com.dfsek.terra.addons.manifest.api.monad.Get;
|
||||
import com.dfsek.terra.addons.manifest.api.monad.Init;
|
||||
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.structure.feature.Locator;
|
||||
import com.dfsek.terra.api.util.function.monad.Monad;
|
||||
@@ -66,9 +61,6 @@ public class LocatorAddon implements MonadAddonInitializer {
|
||||
locatorRegistry.register(base.key("SURFACE"), SurfaceLocatorTemplate::new);
|
||||
locatorRegistry.register(base.key("TOP"), TopLocatorTemplate::new);
|
||||
|
||||
locatorRegistry.register(base.key("RANDOM"), RandomLocatorTemplate::new);
|
||||
locatorRegistry.register(base.key("GAUSSIAN_RANDOM"), GaussianRandomLocatorTemplate::new);
|
||||
|
||||
locatorRegistry.register(base.key("PATTERN"), PatternLocatorTemplate::new);
|
||||
locatorRegistry.register(base.key("ADJACENT_PATTERN"), AdjacentPatternLocatorTemplate::new);
|
||||
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
/*
|
||||
* 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.feature.locator.config;
|
||||
|
||||
import com.dfsek.tectonic.api.config.template.annotations.Default;
|
||||
import com.dfsek.tectonic.api.config.template.annotations.Value;
|
||||
import com.dfsek.tectonic.api.config.template.object.ObjectTemplate;
|
||||
|
||||
import com.dfsek.terra.addons.feature.locator.locators.GaussianRandomLocator;
|
||||
import com.dfsek.terra.api.config.meta.Meta;
|
||||
import com.dfsek.terra.api.structure.feature.Locator;
|
||||
import com.dfsek.terra.api.util.Range;
|
||||
|
||||
|
||||
@SuppressWarnings("FieldMayBeFinal")
|
||||
public class GaussianRandomLocatorTemplate implements ObjectTemplate<Locator> {
|
||||
@Value("height")
|
||||
private @Meta Range height;
|
||||
|
||||
@Value("amount")
|
||||
private @Meta Range amount;
|
||||
|
||||
@Value("standard-deviation")
|
||||
private @Meta double standardDeviation;
|
||||
|
||||
@Value("salt")
|
||||
@Default
|
||||
private @Meta int salt = 0;
|
||||
|
||||
@Override
|
||||
public Locator get() {
|
||||
return new GaussianRandomLocator(height, amount, standardDeviation, salt);
|
||||
}
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
/*
|
||||
* 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.feature.locator.config;
|
||||
|
||||
import com.dfsek.tectonic.api.config.template.annotations.Default;
|
||||
import com.dfsek.tectonic.api.config.template.annotations.Value;
|
||||
import com.dfsek.tectonic.api.config.template.object.ObjectTemplate;
|
||||
|
||||
import com.dfsek.terra.addons.feature.locator.locators.RandomLocator;
|
||||
import com.dfsek.terra.api.config.meta.Meta;
|
||||
import com.dfsek.terra.api.structure.feature.Locator;
|
||||
import com.dfsek.terra.api.util.Range;
|
||||
|
||||
|
||||
@SuppressWarnings("FieldMayBeFinal")
|
||||
public class RandomLocatorTemplate implements ObjectTemplate<Locator> {
|
||||
@Value("height")
|
||||
private @Meta Range height;
|
||||
|
||||
@Value("amount")
|
||||
private @Meta Range amount;
|
||||
|
||||
@Value("salt")
|
||||
@Default
|
||||
private @Meta int salt = 0;
|
||||
|
||||
@Override
|
||||
public Locator get() {
|
||||
return new RandomLocator(height, amount, salt);
|
||||
}
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
/*
|
||||
* 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.feature.locator.locators;
|
||||
|
||||
import java.util.random.RandomGenerator;
|
||||
import java.util.random.RandomGeneratorFactory;
|
||||
|
||||
import com.dfsek.terra.api.structure.feature.BinaryColumn;
|
||||
import com.dfsek.terra.api.structure.feature.Locator;
|
||||
import com.dfsek.terra.api.util.Range;
|
||||
import com.dfsek.terra.api.world.chunk.generation.util.Column;
|
||||
import com.dfsek.terra.api.world.chunk.generation.util.Column.BinaryColumnBuilder;
|
||||
|
||||
|
||||
public class GaussianRandomLocator implements Locator {
|
||||
private final double mean;
|
||||
|
||||
private final Range points;
|
||||
|
||||
private final double standardDeviation;
|
||||
|
||||
private final int salt;
|
||||
|
||||
|
||||
public GaussianRandomLocator(Range height, Range points, double standardDeviation, int salt) {
|
||||
this.mean = (height.getMax() + height.getMin()) / 2.0;
|
||||
this.points = points;
|
||||
this.standardDeviation = standardDeviation;
|
||||
this.salt = salt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BinaryColumn getSuitableCoordinates(Column<?> column) {
|
||||
long seed = column.getWorld().getSeed();
|
||||
seed = 31 * seed + column.getX();
|
||||
seed = 31 * seed + column.getZ();
|
||||
seed += salt;
|
||||
|
||||
RandomGenerator r = RandomGeneratorFactory.<RandomGenerator.SplittableGenerator>of("Xoroshiro128PlusPlus").create(seed);
|
||||
|
||||
int size = points.get(r);
|
||||
|
||||
|
||||
BinaryColumnBuilder results = column.newBinaryColumn();
|
||||
for(int i = 0; i < size; i++) {
|
||||
int h = (int) r.nextGaussian(mean, standardDeviation);
|
||||
if(h >= column.getMaxY() || h < column.getMinY()) continue;
|
||||
results.set(h);
|
||||
}
|
||||
|
||||
return results.build();
|
||||
}
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
/*
|
||||
* 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.feature.locator.locators;
|
||||
|
||||
import java.util.random.RandomGenerator;
|
||||
import java.util.random.RandomGeneratorFactory;
|
||||
|
||||
import com.dfsek.terra.api.structure.feature.BinaryColumn;
|
||||
import com.dfsek.terra.api.structure.feature.Locator;
|
||||
import com.dfsek.terra.api.util.Range;
|
||||
import com.dfsek.terra.api.world.chunk.generation.util.Column;
|
||||
import com.dfsek.terra.api.world.chunk.generation.util.Column.BinaryColumnBuilder;
|
||||
|
||||
|
||||
public class RandomLocator implements Locator {
|
||||
private final Range height;
|
||||
|
||||
private final Range points;
|
||||
|
||||
private final int salt;
|
||||
|
||||
public RandomLocator(Range height, Range points, int salt) {
|
||||
this.height = height;
|
||||
this.points = points;
|
||||
this.salt = salt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BinaryColumn getSuitableCoordinates(Column<?> column) {
|
||||
long seed = column.getWorld().getSeed();
|
||||
seed = 31 * seed + column.getX();
|
||||
seed = 31 * seed + column.getZ();
|
||||
seed += salt;
|
||||
|
||||
RandomGenerator r = RandomGeneratorFactory.<RandomGenerator.SplittableGenerator>of("Xoroshiro128PlusPlus").create(seed);
|
||||
|
||||
int size = points.get(r);
|
||||
|
||||
BinaryColumnBuilder results = column.newBinaryColumn();
|
||||
for(int i = 0; i < size; i++) {
|
||||
int h = height.get(r);
|
||||
if(h >= column.getMaxY() || h < column.getMinY()) continue;
|
||||
results.set(h);
|
||||
}
|
||||
|
||||
return results.build();
|
||||
}
|
||||
}
|
||||
@@ -47,26 +47,26 @@ public class VanillaOre implements Structure {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean generate(Vector3Int location, WritableWorld world, Rotation rotation, Long seed){
|
||||
public boolean generate(Vector3Int location, WritableWorld world, Rotation rotation){
|
||||
int centerX = location.getX();
|
||||
int centerZ = location.getZ();
|
||||
int centerY = location.getY();
|
||||
|
||||
|
||||
double f = sampler.noise(centerX, centerY, centerZ, seed) * (float) Math.PI;
|
||||
double f = sampler.noise(centerX, centerY, centerZ, world.getSeed()) * (float) Math.PI;
|
||||
|
||||
double d1 = centerX + 8 + FastMath.sin(f) * size / 8.0F;
|
||||
double d2 = centerX + 8 - FastMath.sin(f) * size / 8.0F;
|
||||
double d3 = centerZ + 8 + FastMath.cos(f) * size / 8.0F;
|
||||
double d4 = centerZ + 8 - FastMath.cos(f) * size / 8.0F;
|
||||
|
||||
double d5 = centerY + (Math.round(sampler.noise(centerX, centerY, centerZ, seed + 1) + 1)) - 2D;
|
||||
double d6 = centerY + (Math.round(sampler.noise(centerX, centerY, centerZ, seed + 2) + 1)) - 2D;
|
||||
double d5 = centerY + (Math.round(sampler.noise(centerX, centerY, centerZ, world.getSeed() + 1) + 1)) - 2D;
|
||||
double d6 = centerY + (Math.round(sampler.noise(centerX, centerY, centerZ, world.getSeed() + 2) + 1)) - 2D;
|
||||
|
||||
for(int i = 0; i < size; i++) {
|
||||
float iFactor = (float) i / (float) size;
|
||||
|
||||
double d10 = MathUtil.inverseLerp(sampler.noise(centerX, centerY, centerZ, seed + 2 + (i * 2 - 1)), -1, 1) * size / 16.0D;
|
||||
double d10 = MathUtil.inverseLerp(sampler.noise(centerX, centerY, centerZ, world.getSeed() + 2 + (i * 2 - 1)), -1, 1) * size / 16.0D;
|
||||
double d11 = (FastMath.sin(Math.PI * iFactor) + 1.0) * d10 + 1.0;
|
||||
double d12 = (FastMath.sin(Math.PI * iFactor) + 1.0) * d10 + 1.0;
|
||||
|
||||
@@ -90,7 +90,7 @@ public class VanillaOre implements Structure {
|
||||
if(y >= world.getMaxHeight() || y < world.getMinHeight()) continue;
|
||||
BlockType block = world.getBlockState(x, y, z).getBlockType();
|
||||
if((d13 * d13 + d14 * d14 + d15 * d15 < 1.0D) && getReplaceable().contains(block)) {
|
||||
if(exposed > MathUtil.inverseLerp(sampler.noise(centerX, centerY, centerZ, seed + 2 + (i * 2)), -1, 1) || !(world.getBlockState(x, y, z - 1).isAir() ||
|
||||
if(exposed > MathUtil.inverseLerp(sampler.noise(centerX, centerY, centerZ, world.getSeed() + 2 + (i * 2)), -1, 1) || !(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() ||
|
||||
|
||||
@@ -59,7 +59,6 @@ public class FeatureGenerationStage implements GenerationStage, StringIdentifiab
|
||||
for(int subChunkZ = 0; subChunkZ < resolution; subChunkZ++) {
|
||||
int x = subChunkX + tx;
|
||||
int z = subChunkZ + tz;
|
||||
long coordinateSeed = (seed * 31 + x) * 31 + z;
|
||||
Column<WritableWorld> column = world.column(x, z);
|
||||
biome.getContext()
|
||||
.get(biomeFeaturesKey)
|
||||
@@ -73,8 +72,7 @@ public class FeatureGenerationStage implements GenerationStage, StringIdentifiab
|
||||
.forEach(y -> feature.getStructure(world, x, y, z)
|
||||
.generate(Vector3Int.of(x, y, z),
|
||||
world,
|
||||
Rotation.NONE,
|
||||
coordinateSeed * 31 + y)
|
||||
Rotation.NONE)
|
||||
);
|
||||
}
|
||||
platform.getProfiler().pop(feature.getID());
|
||||
|
||||
@@ -17,7 +17,7 @@ public class SingletonStructure implements Structure {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean generate(Vector3Int location, WritableWorld world, Rotation rotation, Long seed) {
|
||||
public boolean generate(Vector3Int location, WritableWorld world, Rotation rotation) {
|
||||
world.setBlockState(location, blockState);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -32,12 +32,12 @@ public class MutatedStructure implements Structure, Keyed<MutatedStructure> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean generate(Vector3Int location, WritableWorld world, Rotation rotation, Long seed) {
|
||||
public boolean generate(Vector3Int location, WritableWorld world, Rotation rotation) {
|
||||
return base.generate(location,
|
||||
world
|
||||
.buffer()
|
||||
.read(readInterceptor)
|
||||
.write(writeInterceptor)
|
||||
.build(), rotation, seed);
|
||||
.build(), rotation);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ public class SpongeStructure implements Structure, Keyed<SpongeStructure> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean generate(Vector3Int location, WritableWorld world, Rotation rotation, Long seed) {
|
||||
public boolean generate(Vector3Int location, WritableWorld world, Rotation rotation) {
|
||||
int bX = location.getX();
|
||||
int bY = location.getY();
|
||||
int bZ = location.getZ();
|
||||
|
||||
@@ -128,7 +128,7 @@ public class StructureScript implements Structure, Keyed<StructureScript> {
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("try")
|
||||
public boolean generate(Vector3Int location, WritableWorld world, Rotation rotation, Long seed) {
|
||||
public boolean generate(Vector3Int location, WritableWorld world, Rotation rotation) {
|
||||
platform.getProfiler().push(profile);
|
||||
boolean result = applyBlock(new TerraImplementationArguments(location, rotation, world, 0));
|
||||
platform.getProfiler().pop(profile);
|
||||
|
||||
@@ -85,9 +85,7 @@ public class LootFunction implements Function<Void> {
|
||||
platform.getEventManager().callEvent(event);
|
||||
if(event.isCancelled()) return;
|
||||
|
||||
event.getTable().fillInventory(container.getInventory(),
|
||||
RandomGeneratorFactory.<RandomGenerator.SplittableGenerator>of(
|
||||
"Xoroshiro128PlusPlus").create(apply.hashCode()));
|
||||
event.getTable().fillInventory(container.getInventory());
|
||||
data.update(false);
|
||||
} catch(Exception e) {
|
||||
LOGGER.error("Could not apply loot at {}", apply, e);
|
||||
|
||||
@@ -80,7 +80,7 @@ public class StructureFunction implements Function<Boolean> {
|
||||
.buffer(FastMath.roundToInt(xz.getX()),
|
||||
y.apply(implementationArguments, scope).intValue(),
|
||||
FastMath.roundToInt(xz.getZ())),
|
||||
arguments.getRotation(), arguments.getWorld().getSeed());
|
||||
arguments.getRotation());
|
||||
}).orElseGet(() -> {
|
||||
LOGGER.error("No such structure {}", app);
|
||||
return false;
|
||||
|
||||
@@ -22,9 +22,8 @@ public interface LootTable {
|
||||
* Fills an Inventory with loot.
|
||||
*
|
||||
* @param i The Inventory to fill.
|
||||
* @param r The The RandomGenerator instance to use.
|
||||
*/
|
||||
void fillInventory(Inventory i, RandomGenerator r);
|
||||
void fillInventory(Inventory i);
|
||||
|
||||
/**
|
||||
* Fetches a list of ItemStacks from the loot table using the given RandomGenerator instance.
|
||||
|
||||
@@ -16,5 +16,5 @@ import com.dfsek.terra.api.world.WritableWorld;
|
||||
|
||||
|
||||
public interface Structure {
|
||||
boolean generate(Vector3Int location, WritableWorld world, Rotation rotation, Long Seed);
|
||||
boolean generate(Vector3Int location, WritableWorld world, Rotation rotation);
|
||||
}
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2020-2021 Polyhedral Development
|
||||
*
|
||||
* The Terra API is licensed under the terms of the MIT License. For more details,
|
||||
* reference the LICENSE file in the common/api directory.
|
||||
*/
|
||||
|
||||
package com.dfsek.terra.api.util;
|
||||
|
||||
import java.util.random.RandomGenerator;
|
||||
import java.util.random.RandomGeneratorFactory;
|
||||
|
||||
import com.dfsek.terra.api.world.chunk.Chunk;
|
||||
|
||||
|
||||
public final class PopulationUtil {
|
||||
public static RandomGenerator getRandom(Chunk c) {
|
||||
return getRandom(c, 0);
|
||||
}
|
||||
|
||||
public static RandomGenerator getRandom(Chunk c, long salt) {
|
||||
return RandomGeneratorFactory.<RandomGenerator.SplittableGenerator>of("Xoroshiro128PlusPlus").create(
|
||||
getCarverChunkSeed(c.getX(), c.getZ(), c.getWorld().getSeed() + salt));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the carver seed for a chunk.
|
||||
*
|
||||
* @param chunkX Chunk's X coordinate
|
||||
* @param chunkZ Chunk's Z coordinate
|
||||
* @param seed World seed
|
||||
*
|
||||
* @return long - The carver seed.
|
||||
*/
|
||||
public static long getCarverChunkSeed(int chunkX, int chunkZ, long seed) {
|
||||
RandomGenerator r = RandomGeneratorFactory.<RandomGenerator.SplittableGenerator>of("Xoroshiro128PlusPlus").create(seed);
|
||||
return chunkX * r.nextLong() ^ chunkZ * r.nextLong() ^ seed;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user