mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-06-21 08:11:06 +00:00
rename MaterialSet
This commit is contained in:
+3
-3
@@ -17,7 +17,7 @@ import java.util.List;
|
|||||||
import com.dfsek.terra.addons.flora.flora.gen.BlockLayer;
|
import com.dfsek.terra.addons.flora.flora.gen.BlockLayer;
|
||||||
import com.dfsek.terra.api.config.AbstractableTemplate;
|
import com.dfsek.terra.api.config.AbstractableTemplate;
|
||||||
import com.dfsek.terra.api.config.meta.Meta;
|
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" })
|
@SuppressWarnings({ "FieldMayBeFinal", "unused" })
|
||||||
@@ -27,7 +27,7 @@ public class FloraTemplate implements AbstractableTemplate {
|
|||||||
private String id;
|
private String id;
|
||||||
@Value("rotatable")
|
@Value("rotatable")
|
||||||
@Default
|
@Default
|
||||||
private @Meta MaterialSet rotatable = MaterialSet.empty();
|
private @Meta BlockStateSet rotatable = BlockStateSet.empty();
|
||||||
|
|
||||||
@Value("physics")
|
@Value("physics")
|
||||||
@Default
|
@Default
|
||||||
@@ -63,7 +63,7 @@ public class FloraTemplate implements AbstractableTemplate {
|
|||||||
return ceiling;
|
return ceiling;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MaterialSet getRotatable() {
|
public BlockStateSet getRotatable() {
|
||||||
return rotatable;
|
return rotatable;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -20,7 +20,7 @@ import java.util.random.RandomGeneratorFactory;
|
|||||||
import com.dfsek.terra.api.block.state.BlockState;
|
import com.dfsek.terra.api.block.state.BlockState;
|
||||||
import com.dfsek.terra.api.block.state.properties.enums.Direction;
|
import com.dfsek.terra.api.block.state.properties.enums.Direction;
|
||||||
import com.dfsek.terra.api.structure.Structure;
|
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.util.collection.ProbabilityCollection;
|
||||||
import com.dfsek.terra.api.world.WritableWorld;
|
import com.dfsek.terra.api.world.WritableWorld;
|
||||||
|
|
||||||
@@ -30,14 +30,14 @@ public class TerraFlora implements Structure {
|
|||||||
private final boolean physics;
|
private final boolean physics;
|
||||||
private final boolean ceiling;
|
private final boolean ceiling;
|
||||||
|
|
||||||
private final MaterialSet testRotation;
|
private final BlockStateSet testRotation;
|
||||||
|
|
||||||
private final Sampler distribution;
|
private final Sampler distribution;
|
||||||
|
|
||||||
private final String id;
|
private final String id;
|
||||||
|
|
||||||
public TerraFlora(List<BlockLayer> layers, boolean physics, boolean ceiling,
|
public TerraFlora(List<BlockLayer> layers, boolean physics, boolean ceiling,
|
||||||
MaterialSet testRotation,
|
BlockStateSet testRotation,
|
||||||
Sampler distribution, String id) {
|
Sampler distribution, String id) {
|
||||||
this.physics = physics;
|
this.physics = physics;
|
||||||
this.testRotation = testRotation;
|
this.testRotation = testRotation;
|
||||||
|
|||||||
+2
-2
@@ -13,13 +13,13 @@ 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.MatchPattern;
|
||||||
import com.dfsek.terra.addons.feature.locator.patterns.Pattern;
|
import com.dfsek.terra.addons.feature.locator.patterns.Pattern;
|
||||||
import com.dfsek.terra.api.config.meta.Meta;
|
import com.dfsek.terra.api.config.meta.Meta;
|
||||||
import com.dfsek.terra.api.util.collection.MaterialSet;
|
import com.dfsek.terra.api.util.collection.BlockStateSet;
|
||||||
import com.dfsek.terra.api.util.range.Range;
|
import com.dfsek.terra.api.util.range.Range;
|
||||||
|
|
||||||
|
|
||||||
public class BlockSetMatchPatternTemplate implements ObjectTemplate<Pattern> {
|
public class BlockSetMatchPatternTemplate implements ObjectTemplate<Pattern> {
|
||||||
@Value("blocks")
|
@Value("blocks")
|
||||||
private @Meta MaterialSet blocks;
|
private @Meta BlockStateSet blocks;
|
||||||
|
|
||||||
@Value("offset")
|
@Value("offset")
|
||||||
private @Meta Range offset;
|
private @Meta Range offset;
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ import com.dfsek.terra.api.block.BlockType;
|
|||||||
import com.dfsek.terra.api.block.state.BlockState;
|
import com.dfsek.terra.api.block.state.BlockState;
|
||||||
import com.dfsek.terra.api.config.AbstractableTemplate;
|
import com.dfsek.terra.api.config.AbstractableTemplate;
|
||||||
import com.dfsek.terra.api.config.meta.Meta;
|
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({ "unused", "FieldMayBeFinal" })
|
@SuppressWarnings({ "unused", "FieldMayBeFinal" })
|
||||||
@@ -36,7 +36,7 @@ public class OreTemplate implements AbstractableTemplate {
|
|||||||
private @Meta Map<@Meta BlockType, @Meta BlockState> materials = new HashMap<>();
|
private @Meta Map<@Meta BlockType, @Meta BlockState> materials = new HashMap<>();
|
||||||
|
|
||||||
@Value("replace")
|
@Value("replace")
|
||||||
private @Meta MaterialSet replaceable;
|
private @Meta BlockStateSet replaceable;
|
||||||
|
|
||||||
@Value("physics")
|
@Value("physics")
|
||||||
@Default
|
@Default
|
||||||
@@ -62,7 +62,7 @@ public class OreTemplate implements AbstractableTemplate {
|
|||||||
return material;
|
return material;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MaterialSet getReplaceable() {
|
public BlockStateSet getReplaceable() {
|
||||||
return replaceable;
|
return replaceable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+4
-4
@@ -20,7 +20,7 @@ import java.util.random.RandomGenerator;
|
|||||||
import com.dfsek.terra.api.block.BlockType;
|
import com.dfsek.terra.api.block.BlockType;
|
||||||
import com.dfsek.terra.api.block.state.BlockState;
|
import com.dfsek.terra.api.block.state.BlockState;
|
||||||
import com.dfsek.terra.api.structure.Structure;
|
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.world.WritableWorld;
|
import com.dfsek.terra.api.world.WritableWorld;
|
||||||
|
|
||||||
import static com.dfsek.terra.addons.ore.utils.VanillaOreUtils.shouldPlace;
|
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 BlockState material;
|
||||||
|
|
||||||
protected final double size;
|
protected final double size;
|
||||||
protected final MaterialSet replaceable;
|
protected final BlockStateSet replaceable;
|
||||||
protected final boolean applyGravity;
|
protected final boolean applyGravity;
|
||||||
protected final double exposed;
|
protected final double exposed;
|
||||||
protected final Map<BlockType, BlockState> materials;
|
protected final Map<BlockType, BlockState> materials;
|
||||||
|
|
||||||
public VanillaOre(BlockState material, double size, MaterialSet replaceable, boolean applyGravity,
|
public VanillaOre(BlockState material, double size, BlockStateSet replaceable, boolean applyGravity,
|
||||||
double exposed, Map<BlockType, BlockState> materials) {
|
double exposed, Map<BlockType, BlockState> materials) {
|
||||||
this.material = material;
|
this.material = material;
|
||||||
this.size = size;
|
this.size = size;
|
||||||
@@ -171,7 +171,7 @@ public class VanillaOre implements Structure {
|
|||||||
return materials.getOrDefault(replace, material);
|
return materials.getOrDefault(replace, material);
|
||||||
}
|
}
|
||||||
|
|
||||||
public MaterialSet getReplaceable() {
|
public BlockStateSet getReplaceable() {
|
||||||
return replaceable;
|
return replaceable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -8,7 +8,7 @@ import java.util.random.RandomGenerator;
|
|||||||
|
|
||||||
import com.dfsek.terra.api.block.BlockType;
|
import com.dfsek.terra.api.block.BlockType;
|
||||||
import com.dfsek.terra.api.block.state.BlockState;
|
import com.dfsek.terra.api.block.state.BlockState;
|
||||||
import com.dfsek.terra.api.util.collection.MaterialSet;
|
import com.dfsek.terra.api.util.collection.BlockStateSet;
|
||||||
import com.dfsek.terra.api.world.WritableWorld;
|
import com.dfsek.terra.api.world.WritableWorld;
|
||||||
|
|
||||||
import static com.dfsek.terra.addons.ore.utils.VanillaOreUtils.shouldPlace;
|
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 {
|
public class VanillaScatteredOre extends VanillaOre {
|
||||||
protected final int spread;
|
protected final int spread;
|
||||||
|
|
||||||
public VanillaScatteredOre(BlockState material, double size, MaterialSet replaceable, boolean applyGravity, double exposed,
|
public VanillaScatteredOre(BlockState material, double size, BlockStateSet replaceable, boolean applyGravity, double exposed,
|
||||||
Map<BlockType, BlockState> materials, int spread) {
|
Map<BlockType, BlockState> materials, int spread) {
|
||||||
super(material, size, replaceable, applyGravity, exposed, materials);
|
super(material, size, replaceable, applyGravity, exposed, materials);
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -3,7 +3,7 @@ package com.dfsek.terra.addons.ore.utils;
|
|||||||
import java.util.random.RandomGenerator;
|
import java.util.random.RandomGenerator;
|
||||||
|
|
||||||
import com.dfsek.terra.api.block.BlockType;
|
import com.dfsek.terra.api.block.BlockType;
|
||||||
import com.dfsek.terra.api.util.collection.MaterialSet;
|
import com.dfsek.terra.api.util.collection.BlockStateSet;
|
||||||
import com.dfsek.terra.api.world.WritableWorld;
|
import com.dfsek.terra.api.world.WritableWorld;
|
||||||
|
|
||||||
|
|
||||||
@@ -14,7 +14,7 @@ public class VanillaOreUtils {
|
|||||||
return random.nextFloat() < exposedChance;
|
return random.nextFloat() < exposedChance;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean shouldPlace(MaterialSet replaceable, BlockType type, Double exposedChance, RandomGenerator random,
|
public static boolean shouldPlace(BlockStateSet replaceable, BlockType type, Double exposedChance, RandomGenerator random,
|
||||||
WritableWorld world,
|
WritableWorld world,
|
||||||
int x,
|
int x,
|
||||||
int y, int z) {
|
int y, int z) {
|
||||||
|
|||||||
+9
-9
@@ -21,35 +21,35 @@ import com.dfsek.terra.api.block.BlockType;
|
|||||||
import com.dfsek.terra.api.block.state.BlockState;
|
import com.dfsek.terra.api.block.state.BlockState;
|
||||||
|
|
||||||
|
|
||||||
public class MaterialSet extends HashSet<BlockType> {
|
public class BlockStateSet extends HashSet<BlockType> {
|
||||||
@Serial
|
@Serial
|
||||||
private static final long serialVersionUID = 3056512763631017301L;
|
private static final long serialVersionUID = 3056512763631017301L;
|
||||||
|
|
||||||
public static MaterialSet singleton(BlockType material) {
|
public static BlockStateSet singleton(BlockType material) {
|
||||||
return new Singleton(material);
|
return new Singleton(material);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static MaterialSet get(BlockType... materials) {
|
public static BlockStateSet get(BlockType... materials) {
|
||||||
MaterialSet set = new MaterialSet();
|
BlockStateSet set = new BlockStateSet();
|
||||||
set.addAll(Arrays.asList(materials));
|
set.addAll(Arrays.asList(materials));
|
||||||
return set;
|
return set;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static MaterialSet get(BlockState... materials) {
|
public static BlockStateSet get(BlockState... materials) {
|
||||||
MaterialSet set = new MaterialSet();
|
BlockStateSet set = new BlockStateSet();
|
||||||
Arrays.stream(materials).forEach(set::add);
|
Arrays.stream(materials).forEach(set::add);
|
||||||
return set;
|
return set;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static MaterialSet empty() {
|
public static BlockStateSet empty() {
|
||||||
return new MaterialSet();
|
return new BlockStateSet();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void add(BlockState data) {
|
private void add(BlockState data) {
|
||||||
add(data.getBlockType());
|
add(data.getBlockType());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final class Singleton extends MaterialSet {
|
private static final class Singleton extends BlockStateSet {
|
||||||
private final BlockType element;
|
private final BlockType element;
|
||||||
|
|
||||||
Singleton(BlockType e) {
|
Singleton(BlockType e) {
|
||||||
@@ -29,7 +29,7 @@ import com.dfsek.terra.api.addon.BaseAddon;
|
|||||||
import com.dfsek.terra.api.block.BlockType;
|
import com.dfsek.terra.api.block.BlockType;
|
||||||
import com.dfsek.terra.api.block.state.BlockState;
|
import com.dfsek.terra.api.block.state.BlockState;
|
||||||
import com.dfsek.terra.api.tectonic.LoaderRegistrar;
|
import com.dfsek.terra.api.tectonic.LoaderRegistrar;
|
||||||
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.util.collection.ProbabilityCollection;
|
||||||
import com.dfsek.terra.api.util.range.Range;
|
import com.dfsek.terra.api.util.range.Range;
|
||||||
import com.dfsek.terra.config.loaders.ExpressionParserOptionsTemplate;
|
import com.dfsek.terra.config.loaders.ExpressionParserOptionsTemplate;
|
||||||
@@ -53,7 +53,7 @@ public class GenericLoaders implements LoaderRegistrar {
|
|||||||
registry.registerLoader(ProbabilityCollection.class, new ProbabilityCollectionLoader())
|
registry.registerLoader(ProbabilityCollection.class, new ProbabilityCollectionLoader())
|
||||||
.registerLoader(Range.class, new RangeLoader())
|
.registerLoader(Range.class, new RangeLoader())
|
||||||
.registerLoader(Version.class, new VersionLoader())
|
.registerLoader(Version.class, new VersionLoader())
|
||||||
.registerLoader(MaterialSet.class, new MaterialSetLoader())
|
.registerLoader(BlockStateSet.class, new MaterialSetLoader())
|
||||||
.registerLoader(VersionRange.class, new VersionRangeLoader())
|
.registerLoader(VersionRange.class, new VersionRangeLoader())
|
||||||
.registerLoader(LinkedHashMap.class, new LinkedHashMapLoader())
|
.registerLoader(LinkedHashMap.class, new LinkedHashMapLoader())
|
||||||
.registerLoader(ParseOptions.class, ExpressionParserOptionsTemplate::new);
|
.registerLoader(ParseOptions.class, ExpressionParserOptionsTemplate::new);
|
||||||
|
|||||||
+5
-5
@@ -27,21 +27,21 @@ import java.lang.reflect.AnnotatedType;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import com.dfsek.terra.api.block.BlockType;
|
import com.dfsek.terra.api.block.BlockType;
|
||||||
import com.dfsek.terra.api.util.collection.MaterialSet;
|
import com.dfsek.terra.api.util.collection.BlockStateSet;
|
||||||
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public class MaterialSetLoader implements TypeLoader<MaterialSet> {
|
public class MaterialSetLoader implements TypeLoader<BlockStateSet> {
|
||||||
@Override
|
@Override
|
||||||
public MaterialSet load(@NotNull AnnotatedType type, @NotNull Object o, @NotNull ConfigLoader configLoader, DepthTracker depthTracker)
|
public BlockStateSet load(@NotNull AnnotatedType type, @NotNull Object o, @NotNull ConfigLoader configLoader, DepthTracker depthTracker)
|
||||||
throws LoadException {
|
throws LoadException {
|
||||||
List<String> stringData = (List<String>) o;
|
List<String> stringData = (List<String>) o;
|
||||||
|
|
||||||
if(stringData.size() == 1) {
|
if(stringData.size() == 1) {
|
||||||
return MaterialSet.singleton(configLoader.loadType(BlockType.class, stringData.get(0), depthTracker));
|
return BlockStateSet.singleton(configLoader.loadType(BlockType.class, stringData.get(0), depthTracker));
|
||||||
}
|
}
|
||||||
|
|
||||||
MaterialSet set = new MaterialSet();
|
BlockStateSet set = new BlockStateSet();
|
||||||
|
|
||||||
for(String string : stringData) {
|
for(String string : stringData) {
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user