mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-02-16 02:20:57 +00:00
rename MaterialSet
This commit is contained in:
@@ -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.MaterialSet;
|
||||
import com.dfsek.terra.api.util.collection.BlockStateSet;
|
||||
|
||||
|
||||
@SuppressWarnings({ "FieldMayBeFinal", "unused" })
|
||||
@@ -27,7 +27,7 @@ public class FloraTemplate implements AbstractableTemplate {
|
||||
private String id;
|
||||
@Value("rotatable")
|
||||
@Default
|
||||
private @Meta MaterialSet rotatable = MaterialSet.empty();
|
||||
private @Meta BlockStateSet rotatable = BlockStateSet.empty();
|
||||
|
||||
@Value("physics")
|
||||
@Default
|
||||
@@ -63,7 +63,7 @@ public class FloraTemplate implements AbstractableTemplate {
|
||||
return ceiling;
|
||||
}
|
||||
|
||||
public MaterialSet getRotatable() {
|
||||
public BlockStateSet getRotatable() {
|
||||
return rotatable;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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.MaterialSet;
|
||||
import com.dfsek.terra.api.util.collection.BlockStateSet;
|
||||
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 MaterialSet testRotation;
|
||||
private final BlockStateSet testRotation;
|
||||
|
||||
private final Sampler distribution;
|
||||
|
||||
private final String id;
|
||||
|
||||
public TerraFlora(List<BlockLayer> layers, boolean physics, boolean ceiling,
|
||||
MaterialSet testRotation,
|
||||
BlockStateSet testRotation,
|
||||
Sampler distribution, String id) {
|
||||
this.physics = physics;
|
||||
this.testRotation = testRotation;
|
||||
|
||||
@@ -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.Pattern;
|
||||
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;
|
||||
|
||||
|
||||
public class BlockSetMatchPatternTemplate implements ObjectTemplate<Pattern> {
|
||||
@Value("blocks")
|
||||
private @Meta MaterialSet blocks;
|
||||
private @Meta BlockStateSet blocks;
|
||||
|
||||
@Value("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.config.AbstractableTemplate;
|
||||
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" })
|
||||
@@ -36,7 +36,7 @@ public class OreTemplate implements AbstractableTemplate {
|
||||
private @Meta Map<@Meta BlockType, @Meta BlockState> materials = new HashMap<>();
|
||||
|
||||
@Value("replace")
|
||||
private @Meta MaterialSet replaceable;
|
||||
private @Meta BlockStateSet replaceable;
|
||||
|
||||
@Value("physics")
|
||||
@Default
|
||||
@@ -62,7 +62,7 @@ public class OreTemplate implements AbstractableTemplate {
|
||||
return material;
|
||||
}
|
||||
|
||||
public MaterialSet getReplaceable() {
|
||||
public BlockStateSet getReplaceable() {
|
||||
return replaceable;
|
||||
}
|
||||
|
||||
|
||||
@@ -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.MaterialSet;
|
||||
import com.dfsek.terra.api.util.collection.BlockStateSet;
|
||||
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 MaterialSet replaceable;
|
||||
protected final BlockStateSet replaceable;
|
||||
protected final boolean applyGravity;
|
||||
protected final double exposed;
|
||||
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) {
|
||||
this.material = material;
|
||||
this.size = size;
|
||||
@@ -171,7 +171,7 @@ public class VanillaOre implements Structure {
|
||||
return materials.getOrDefault(replace, material);
|
||||
}
|
||||
|
||||
public MaterialSet getReplaceable() {
|
||||
public BlockStateSet getReplaceable() {
|
||||
return replaceable;
|
||||
}
|
||||
|
||||
|
||||
@@ -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.MaterialSet;
|
||||
import com.dfsek.terra.api.util.collection.BlockStateSet;
|
||||
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, MaterialSet replaceable, boolean applyGravity, double exposed,
|
||||
public VanillaScatteredOre(BlockState material, double size, BlockStateSet replaceable, boolean applyGravity, double exposed,
|
||||
Map<BlockType, BlockState> materials, int spread) {
|
||||
super(material, size, replaceable, applyGravity, exposed, materials);
|
||||
|
||||
|
||||
@@ -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.MaterialSet;
|
||||
import com.dfsek.terra.api.util.collection.BlockStateSet;
|
||||
import com.dfsek.terra.api.world.WritableWorld;
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ public class VanillaOreUtils {
|
||||
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,
|
||||
int x,
|
||||
int y, int z) {
|
||||
|
||||
@@ -21,35 +21,35 @@ import com.dfsek.terra.api.block.BlockType;
|
||||
import com.dfsek.terra.api.block.state.BlockState;
|
||||
|
||||
|
||||
public class MaterialSet extends HashSet<BlockType> {
|
||||
public class BlockStateSet extends HashSet<BlockType> {
|
||||
@Serial
|
||||
private static final long serialVersionUID = 3056512763631017301L;
|
||||
|
||||
public static MaterialSet singleton(BlockType material) {
|
||||
public static BlockStateSet singleton(BlockType material) {
|
||||
return new Singleton(material);
|
||||
}
|
||||
|
||||
public static MaterialSet get(BlockType... materials) {
|
||||
MaterialSet set = new MaterialSet();
|
||||
public static BlockStateSet get(BlockType... materials) {
|
||||
BlockStateSet set = new BlockStateSet();
|
||||
set.addAll(Arrays.asList(materials));
|
||||
return set;
|
||||
}
|
||||
|
||||
public static MaterialSet get(BlockState... materials) {
|
||||
MaterialSet set = new MaterialSet();
|
||||
public static BlockStateSet get(BlockState... materials) {
|
||||
BlockStateSet set = new BlockStateSet();
|
||||
Arrays.stream(materials).forEach(set::add);
|
||||
return set;
|
||||
}
|
||||
|
||||
public static MaterialSet empty() {
|
||||
return new MaterialSet();
|
||||
public static BlockStateSet empty() {
|
||||
return new BlockStateSet();
|
||||
}
|
||||
|
||||
private void add(BlockState data) {
|
||||
add(data.getBlockType());
|
||||
}
|
||||
|
||||
private static final class Singleton extends MaterialSet {
|
||||
private static final class Singleton extends BlockStateSet {
|
||||
private final BlockType element;
|
||||
|
||||
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.state.BlockState;
|
||||
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.range.Range;
|
||||
import com.dfsek.terra.config.loaders.ExpressionParserOptionsTemplate;
|
||||
@@ -53,7 +53,7 @@ public class GenericLoaders implements LoaderRegistrar {
|
||||
registry.registerLoader(ProbabilityCollection.class, new ProbabilityCollectionLoader())
|
||||
.registerLoader(Range.class, new RangeLoader())
|
||||
.registerLoader(Version.class, new VersionLoader())
|
||||
.registerLoader(MaterialSet.class, new MaterialSetLoader())
|
||||
.registerLoader(BlockStateSet.class, new MaterialSetLoader())
|
||||
.registerLoader(VersionRange.class, new VersionRangeLoader())
|
||||
.registerLoader(LinkedHashMap.class, new LinkedHashMapLoader())
|
||||
.registerLoader(ParseOptions.class, ExpressionParserOptionsTemplate::new);
|
||||
|
||||
@@ -27,21 +27,21 @@ import java.lang.reflect.AnnotatedType;
|
||||
import java.util.List;
|
||||
|
||||
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")
|
||||
public class MaterialSetLoader implements TypeLoader<MaterialSet> {
|
||||
public class MaterialSetLoader implements TypeLoader<BlockStateSet> {
|
||||
@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 {
|
||||
List<String> stringData = (List<String>) o;
|
||||
|
||||
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) {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user