add ore exposed option

This commit is contained in:
dfsek
2021-12-28 17:04:47 -07:00
parent ddebb8fec1
commit ecc4504f00
3 changed files with 20 additions and 3 deletions

View File

@@ -18,6 +18,6 @@ public class OreFactory implements ConfigFactory<OreTemplate, Structure> {
@Override
public VanillaOre build(OreTemplate config, Platform platform) {
BlockState m = config.getMaterial();
return new VanillaOre(m, config.getSize(), config.getReplaceable(), config.doPhysics(), config.getMaterialOverrides());
return new VanillaOre(m, config.getSize(), config.getReplaceable(), config.doPhysics(), config.isExposed(), config.getMaterialOverrides());
}
}

View File

@@ -44,6 +44,10 @@ public class OreTemplate implements AbstractableTemplate {
@Value("size")
private @Meta double size;
@Value("exposed")
@Default
private @Meta boolean exposed = true;
public boolean doPhysics() {
return physics;
}
@@ -67,4 +71,8 @@ public class OreTemplate implements AbstractableTemplate {
public Map<BlockType, BlockState> getMaterialOverrides() {
return materials;
}
public boolean isExposed() {
return exposed;
}
}

View File

@@ -29,14 +29,16 @@ public class VanillaOre implements Structure {
private final double size;
private final MaterialSet replaceable;
private final boolean applyGravity;
private final boolean exposed;
private final Map<BlockType, BlockState> materials;
public VanillaOre(BlockState material, double size, MaterialSet replaceable, boolean applyGravity,
Map<BlockType, BlockState> materials) {
boolean exposed, Map<BlockType, BlockState> materials) {
this.material = material;
this.size = size;
this.replaceable = replaceable;
this.applyGravity = applyGravity;
this.exposed = exposed;
this.materials = materials;
}
@@ -84,7 +86,14 @@ 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)) {
world.setBlockState(x, y, z, getMaterial(block), isApplyGravity());
if(exposed || !(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() ||
world.getBlockState(x - 1, y, z).isAir() ||
world.getBlockState(x + 1, y, z).isAir())) {
world.setBlockState(x, y, z, getMaterial(block), isApplyGravity());
}
}
}
}