make exposed value a double

This commit is contained in:
dfsek 2021-12-28 21:55:10 -07:00
parent fb7c827e15
commit ffedfcc781
2 changed files with 7 additions and 5 deletions

View File

@ -8,6 +8,7 @@
package com.dfsek.terra.addons.ore;
import com.dfsek.tectonic.api.config.template.annotations.Default;
import com.dfsek.tectonic.api.config.template.annotations.Description;
import com.dfsek.tectonic.api.config.template.annotations.Final;
import com.dfsek.tectonic.api.config.template.annotations.Value;
@ -46,7 +47,8 @@ public class OreTemplate implements AbstractableTemplate {
@Value("exposed")
@Default
private @Meta boolean exposed = true;
@Description("The chance that ore blocks bordering air will be exposed. 0 = 0%, 1 = 100%")
private @Meta double exposed = 1;
public boolean doPhysics() {
return physics;
@ -72,7 +74,7 @@ public class OreTemplate implements AbstractableTemplate {
return materials;
}
public boolean isExposed() {
public double isExposed() {
return exposed;
}
}

View File

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