mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-06-18 14:50:56 +00:00
Reformat
This commit is contained in:
+2
-2
@@ -1,9 +1,9 @@
|
||||
package com.dfsek.terra.addons.biome.pipeline.v2.api.biome;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import com.dfsek.terra.api.world.biome.Biome;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
|
||||
public final class DelegatedPipelineBiome implements PipelineBiome {
|
||||
private final Biome biome;
|
||||
|
||||
+5
-5
@@ -7,17 +7,17 @@
|
||||
|
||||
package com.dfsek.terra.addons.biome.pipeline.v2.stage.mutators;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import com.dfsek.terra.addons.biome.pipeline.v2.api.Stage;
|
||||
import com.dfsek.terra.addons.biome.pipeline.v2.api.biome.PipelineBiome;
|
||||
import com.dfsek.terra.addons.biome.pipeline.v2.pipeline.BiomeChunkImpl;
|
||||
import com.dfsek.terra.api.noise.NoiseSampler;
|
||||
import com.dfsek.terra.api.util.collection.ProbabilityCollection;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
|
||||
public class ReplaceListStage implements Stage {
|
||||
private final Map<PipelineBiome, ProbabilityCollection<PipelineBiome>> replace;
|
||||
|
||||
+2
-2
@@ -6,6 +6,8 @@ import cloud.commandframework.arguments.standard.EnumArgument;
|
||||
import cloud.commandframework.arguments.standard.LongArgument;
|
||||
import cloud.commandframework.context.CommandContext;
|
||||
|
||||
import java.util.random.RandomGenerator;
|
||||
import java.util.random.RandomGeneratorFactory;
|
||||
|
||||
import com.dfsek.terra.addons.manifest.api.AddonInitializer;
|
||||
import com.dfsek.terra.api.Platform;
|
||||
@@ -21,8 +23,6 @@ import com.dfsek.terra.api.structure.Structure;
|
||||
import com.dfsek.terra.api.util.Rotation;
|
||||
import com.dfsek.terra.api.util.reflection.TypeKey;
|
||||
|
||||
import java.util.random.RandomGenerator;
|
||||
import java.util.random.RandomGeneratorFactory;
|
||||
|
||||
public class StructureCommandAddon implements AddonInitializer {
|
||||
@Inject
|
||||
|
||||
+2
-2
@@ -26,8 +26,8 @@ public class PaddedGridDistributor implements Distributor {
|
||||
int cellZ = Math.floorDiv(z, cellWidth);
|
||||
|
||||
RandomGenerator random = RandomGeneratorFactory.<RandomGenerator.SplittableGenerator>of("Xoroshiro128PlusPlus").create(
|
||||
(MathUtil.murmur64(MathUtil.squash(cellX, cellZ)) ^ seed) + salt);
|
||||
|
||||
(MathUtil.murmur64(MathUtil.squash(cellX, cellZ)) ^ seed) + salt);
|
||||
|
||||
int pointX = random.nextInt(width) + cellX * cellWidth;
|
||||
int pointZ = random.nextInt(width) + cellZ * cellWidth;
|
||||
|
||||
|
||||
+3
-3
@@ -87,9 +87,9 @@ public class TerraFlora implements Structure {
|
||||
location.getZ(), world.getSeed());
|
||||
if(doRotation) {
|
||||
Direction oneFace = new ArrayList<>(faces).get(
|
||||
RandomGeneratorFactory.<RandomGenerator.SplittableGenerator>of("Xoroshiro128PlusPlus")
|
||||
.create(location.getX() ^ location.getZ())
|
||||
.nextInt(faces.size())); // Get RandomGenerator face.
|
||||
RandomGeneratorFactory.<RandomGenerator.SplittableGenerator>of("Xoroshiro128PlusPlus")
|
||||
.create(location.getX() ^ location.getZ())
|
||||
.nextInt(faces.size())); // Get RandomGenerator face.
|
||||
}
|
||||
world.setBlockState(location.mutable().add(0, i + c, 0).immutable(), data, physics);
|
||||
}
|
||||
|
||||
+2
-2
@@ -40,9 +40,9 @@ public class GaussianRandomLocator implements Locator {
|
||||
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);
|
||||
|
||||
|
||||
|
||||
+2
-2
@@ -36,9 +36,9 @@ public class RandomLocator implements Locator {
|
||||
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();
|
||||
|
||||
+4
-3
@@ -1,11 +1,11 @@
|
||||
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.MaterialSet;
|
||||
import com.dfsek.terra.api.world.WritableWorld;
|
||||
|
||||
import java.util.random.RandomGenerator;
|
||||
|
||||
|
||||
public class VanillaOreUtils {
|
||||
private static boolean shouldExpose(RandomGenerator random, double exposedChance) {
|
||||
@@ -14,7 +14,8 @@ public class VanillaOreUtils {
|
||||
return random.nextFloat() < exposedChance;
|
||||
}
|
||||
|
||||
public static boolean shouldPlace(MaterialSet replaceable, BlockType type, Double exposedChance, RandomGenerator random, WritableWorld world,
|
||||
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;
|
||||
|
||||
+1
-1
@@ -57,7 +57,7 @@ public class Pool {
|
||||
* @return List<ItemStack> - The list of items fetched.
|
||||
*/
|
||||
public List<ItemStack> getItems(RandomGenerator r) {
|
||||
|
||||
|
||||
int rolls = r.nextInt(max - min + 1) + min;
|
||||
List<ItemStack> items = new ArrayList<>();
|
||||
for(int i = 0; i < rolls; i++) {
|
||||
|
||||
+31
-31
@@ -53,37 +53,37 @@ public class FeatureGenerationStage implements GenerationStage, StringIdentifiab
|
||||
int tx = cx + chunkX;
|
||||
int tz = cz + chunkZ;
|
||||
world.getBiomeProvider()
|
||||
.getColumn(tx, tz, world)
|
||||
.forRanges(resolution, (min, max, biome) -> {
|
||||
for(int subChunkX = 0; subChunkX < resolution; subChunkX++) {
|
||||
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)
|
||||
.getFeatures()
|
||||
.getOrDefault(this, Collections.emptyList())
|
||||
.forEach(feature -> {
|
||||
platform.getProfiler().push(feature.getID());
|
||||
if(feature.getDistributor().matches(x, z, seed)) {
|
||||
feature.getLocator()
|
||||
.getSuitableCoordinates(column.clamp(min, max))
|
||||
.forEach(y -> feature.getStructure(world, x, y, z)
|
||||
.generate(Vector3Int.of(x, y, z),
|
||||
world,
|
||||
RandomGeneratorFactory.<RandomGenerator.SplittableGenerator>of(
|
||||
"Xoroshiro128PlusPlus")
|
||||
.create(coordinateSeed * 31 + y),
|
||||
Rotation.NONE)
|
||||
);
|
||||
}
|
||||
platform.getProfiler().pop(feature.getID());
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
.getColumn(tx, tz, world)
|
||||
.forRanges(resolution, (min, max, biome) -> {
|
||||
for(int subChunkX = 0; subChunkX < resolution; subChunkX++) {
|
||||
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)
|
||||
.getFeatures()
|
||||
.getOrDefault(this, Collections.emptyList())
|
||||
.forEach(feature -> {
|
||||
platform.getProfiler().push(feature.getID());
|
||||
if(feature.getDistributor().matches(x, z, seed)) {
|
||||
feature.getLocator()
|
||||
.getSuitableCoordinates(column.clamp(min, max))
|
||||
.forEach(y -> feature.getStructure(world, x, y, z)
|
||||
.generate(Vector3Int.of(x, y, z),
|
||||
world,
|
||||
RandomGeneratorFactory.<RandomGenerator.SplittableGenerator>of(
|
||||
"Xoroshiro128PlusPlus")
|
||||
.create(coordinateSeed * 31 + y),
|
||||
Rotation.NONE)
|
||||
);
|
||||
}
|
||||
platform.getProfiler().pop(feature.getID());
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
platform.getProfiler().pop(profile);
|
||||
|
||||
+2
-2
@@ -1,7 +1,5 @@
|
||||
package com.dfsek.terra.addons.structure.mutator;
|
||||
|
||||
import java.util.random.RandomGenerator;
|
||||
|
||||
import com.dfsek.terra.api.registry.key.Keyed;
|
||||
import com.dfsek.terra.api.registry.key.RegistryKey;
|
||||
import com.dfsek.terra.api.structure.Structure;
|
||||
@@ -11,6 +9,8 @@ import com.dfsek.terra.api.world.WritableWorld;
|
||||
import com.dfsek.terra.api.world.util.ReadInterceptor;
|
||||
import com.dfsek.terra.api.world.util.WriteInterceptor;
|
||||
|
||||
import java.util.random.RandomGenerator;
|
||||
|
||||
|
||||
public class MutatedStructure implements Structure, Keyed<MutatedStructure> {
|
||||
private final RegistryKey key;
|
||||
|
||||
+1
-1
@@ -137,7 +137,7 @@ public class StructureScript implements Structure, Keyed<StructureScript> {
|
||||
platform.getProfiler().pop(profile);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
public boolean generate(Vector3Int location, WritableWorld world, RandomGenerator random, Rotation rotation, int recursions) {
|
||||
platform.getProfiler().push(profile);
|
||||
boolean result = applyBlock(new TerraImplementationArguments(location, rotation, random, world, recursions));
|
||||
|
||||
+2
-2
@@ -26,7 +26,7 @@ public class TerraImplementationArguments implements ImplementationArguments {
|
||||
private final int recursions;
|
||||
private final Vector3Int origin;
|
||||
private boolean waterlog = false;
|
||||
|
||||
|
||||
public TerraImplementationArguments(Vector3Int origin, Rotation rotation, RandomGenerator random, WritableWorld world, int recursions) {
|
||||
this.rotation = rotation;
|
||||
this.random = random;
|
||||
@@ -38,7 +38,7 @@ public class TerraImplementationArguments implements ImplementationArguments {
|
||||
public int getRecursions() {
|
||||
return recursions;
|
||||
}
|
||||
|
||||
|
||||
public RandomGenerator getRandom() {
|
||||
return random;
|
||||
}
|
||||
|
||||
+32
-32
@@ -10,6 +10,9 @@ package com.dfsek.terra.addons.terrascript.script.functions;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.random.RandomGenerator;
|
||||
import java.util.random.RandomGeneratorFactory;
|
||||
|
||||
import com.dfsek.terra.addons.terrascript.parser.lang.ImplementationArguments;
|
||||
import com.dfsek.terra.addons.terrascript.parser.lang.Returnable;
|
||||
import com.dfsek.terra.addons.terrascript.parser.lang.Scope;
|
||||
@@ -28,9 +31,6 @@ import com.dfsek.terra.api.util.RotationUtil;
|
||||
import com.dfsek.terra.api.util.vector.Vector2;
|
||||
import com.dfsek.terra.api.util.vector.Vector3;
|
||||
|
||||
import java.util.random.RandomGenerator;
|
||||
import java.util.random.RandomGeneratorFactory;
|
||||
|
||||
|
||||
public class LootFunction implements Function<Void> {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(LootFunction.class);
|
||||
@@ -65,35 +65,35 @@ public class LootFunction implements Function<Void> {
|
||||
|
||||
|
||||
registry.get(RegistryKey.parse(id))
|
||||
.ifPresentOrElse(table -> {
|
||||
Vector3 apply = Vector3.of((int) Math.round(xz.getX()),
|
||||
y.apply(implementationArguments, scope)
|
||||
.intValue(),
|
||||
(int) Math.round(xz.getZ())).mutable().add(arguments.getOrigin()).immutable();
|
||||
|
||||
try {
|
||||
BlockEntity data = arguments.getWorld().getBlockEntity(apply);
|
||||
if(!(data instanceof Container container)) {
|
||||
LOGGER.error("Failed to place loot at {}; block {} is not a container",
|
||||
apply, data);
|
||||
return;
|
||||
}
|
||||
|
||||
LootPopulateEvent event = new LootPopulateEvent(container, table,
|
||||
arguments.getWorld().getPack(), script);
|
||||
platform.getEventManager().callEvent(event);
|
||||
if(event.isCancelled()) return;
|
||||
|
||||
event.getTable().fillInventory(container.getInventory(),
|
||||
RandomGeneratorFactory.<RandomGenerator.SplittableGenerator>of(
|
||||
"Xoroshiro128PlusPlus").create(apply.hashCode()));
|
||||
data.update(false);
|
||||
} catch(Exception e) {
|
||||
LOGGER.error("Could not apply loot at {}", apply, e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
},
|
||||
() -> LOGGER.error("No such loot table {}", id));
|
||||
.ifPresentOrElse(table -> {
|
||||
Vector3 apply = Vector3.of((int) Math.round(xz.getX()),
|
||||
y.apply(implementationArguments, scope)
|
||||
.intValue(),
|
||||
(int) Math.round(xz.getZ())).mutable().add(arguments.getOrigin()).immutable();
|
||||
|
||||
try {
|
||||
BlockEntity data = arguments.getWorld().getBlockEntity(apply);
|
||||
if(!(data instanceof Container container)) {
|
||||
LOGGER.error("Failed to place loot at {}; block {} is not a container",
|
||||
apply, data);
|
||||
return;
|
||||
}
|
||||
|
||||
LootPopulateEvent event = new LootPopulateEvent(container, table,
|
||||
arguments.getWorld().getPack(), script);
|
||||
platform.getEventManager().callEvent(event);
|
||||
if(event.isCancelled()) return;
|
||||
|
||||
event.getTable().fillInventory(container.getInventory(),
|
||||
RandomGeneratorFactory.<RandomGenerator.SplittableGenerator>of(
|
||||
"Xoroshiro128PlusPlus").create(apply.hashCode()));
|
||||
data.update(false);
|
||||
} catch(Exception e) {
|
||||
LOGGER.error("Could not apply loot at {}", apply, e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
},
|
||||
() -> LOGGER.error("No such loot table {}", id));
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user