mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-04-08 08:46:13 +00:00
build ore addon
This commit is contained in:
@@ -1,28 +0,0 @@
|
||||
package com.dfsek.terra.api.util;
|
||||
|
||||
import com.dfsek.terra.api.world.Chunk;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public final class PopulationUtil {
|
||||
public static FastRandom getRandom(Chunk c) {
|
||||
return getRandom(c, 0);
|
||||
}
|
||||
|
||||
public static FastRandom getRandom(Chunk c, long salt) {
|
||||
return new FastRandom(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) {
|
||||
Random r = new FastRandom(seed);
|
||||
return chunkX * r.nextLong() ^ chunkZ * r.nextLong() ^ seed;
|
||||
}
|
||||
}
|
||||
@@ -2,33 +2,34 @@ package com.dfsek.terra.api.util.collections;
|
||||
|
||||
import com.dfsek.terra.api.block.state.BlockState;
|
||||
import com.dfsek.terra.api.block.BlockType;
|
||||
import com.dfsek.terra.api.util.MaterialSet;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
|
||||
public class MaterialSet extends HashSet<BlockType> {
|
||||
public class MaterialSetImpl extends HashSet<BlockType> implements MaterialSet {
|
||||
private static final long serialVersionUID = 3056512763631017301L;
|
||||
|
||||
public static MaterialSet singleton(BlockType material) {
|
||||
MaterialSet set = new MaterialSet();
|
||||
public static MaterialSetImpl singleton(BlockType material) {
|
||||
MaterialSetImpl set = new MaterialSetImpl();
|
||||
set.add(material);
|
||||
return set;
|
||||
}
|
||||
|
||||
public static MaterialSet get(BlockType... materials) {
|
||||
MaterialSet set = new MaterialSet();
|
||||
public static MaterialSetImpl get(BlockType... materials) {
|
||||
MaterialSetImpl set = new MaterialSetImpl();
|
||||
set.addAll(Arrays.asList(materials));
|
||||
return set;
|
||||
}
|
||||
|
||||
public static MaterialSet get(BlockState... materials) {
|
||||
MaterialSet set = new MaterialSet();
|
||||
public static MaterialSetImpl get(BlockState... materials) {
|
||||
MaterialSetImpl set = new MaterialSetImpl();
|
||||
Arrays.stream(materials).forEach(set::add);
|
||||
return set;
|
||||
}
|
||||
|
||||
public static MaterialSet empty() {
|
||||
return new MaterialSet();
|
||||
public static MaterialSetImpl empty() {
|
||||
return new MaterialSetImpl();
|
||||
}
|
||||
|
||||
private void add(BlockState data) {
|
||||
@@ -7,7 +7,7 @@ import com.dfsek.terra.api.block.BlockType;
|
||||
import com.dfsek.terra.api.tectonic.LoaderRegistrar;
|
||||
import com.dfsek.terra.api.util.ProbabilityCollection;
|
||||
import com.dfsek.terra.api.util.Range;
|
||||
import com.dfsek.terra.api.util.collections.MaterialSet;
|
||||
import com.dfsek.terra.api.util.collections.MaterialSetImpl;
|
||||
import com.dfsek.terra.api.world.biome.generation.pipeline.BiomeSource;
|
||||
import com.dfsek.terra.config.loaders.LinkedHashMapLoader;
|
||||
import com.dfsek.terra.config.loaders.MaterialSetLoader;
|
||||
@@ -27,7 +27,7 @@ public class GenericLoaders implements LoaderRegistrar {
|
||||
public void register(TypeRegistry registry) {
|
||||
registry.registerLoader(ProbabilityCollection.class, new ProbabilityCollectionLoader())
|
||||
.registerLoader(Range.class, new RangeLoader())
|
||||
.registerLoader(MaterialSet.class, new MaterialSetLoader())
|
||||
.registerLoader(MaterialSetImpl.class, new MaterialSetLoader())
|
||||
.registerLoader(LinkedHashMap.class, new LinkedHashMapLoader())
|
||||
.registerLoader(BiomeSource.Type.class, (t, object, cf) -> BiomeSource.Type.valueOf((String) object));
|
||||
|
||||
|
||||
@@ -4,17 +4,17 @@ import com.dfsek.tectonic.exception.LoadException;
|
||||
import com.dfsek.tectonic.loading.ConfigLoader;
|
||||
import com.dfsek.tectonic.loading.TypeLoader;
|
||||
import com.dfsek.terra.api.block.BlockType;
|
||||
import com.dfsek.terra.api.util.collections.MaterialSet;
|
||||
import com.dfsek.terra.api.util.collections.MaterialSetImpl;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.List;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public class MaterialSetLoader implements TypeLoader<MaterialSet> {
|
||||
public class MaterialSetLoader implements TypeLoader<MaterialSetImpl> {
|
||||
@Override
|
||||
public MaterialSet load(Type type, Object o, ConfigLoader configLoader) throws LoadException {
|
||||
public MaterialSetImpl load(Type type, Object o, ConfigLoader configLoader) throws LoadException {
|
||||
List<String> stringData = (List<String>) o;
|
||||
MaterialSet set = new MaterialSet();
|
||||
MaterialSetImpl set = new MaterialSetImpl();
|
||||
|
||||
for(String string : stringData) {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user