mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-06-24 21:42:21 +00:00
Invert exposed ore logic (#433)
* Invert exposed ore logic * Bump ore addon version
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
version = version("1.1.0")
|
version = version("1.1.1")
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
|
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
|
||||||
|
|||||||
+12
-19
@@ -8,31 +8,24 @@ import com.dfsek.terra.api.world.WritableWorld;
|
|||||||
|
|
||||||
|
|
||||||
public class VanillaOreUtils {
|
public class VanillaOreUtils {
|
||||||
protected static boolean shouldNotDiscard(Random random, double chance) {
|
private static boolean shouldExpose(Random random, double exposedChance) {
|
||||||
if(chance <= 0.0F) {
|
if(exposedChance >= 1.0F) return true;
|
||||||
return true;
|
if(exposedChance <= 0.0F) return false;
|
||||||
} else if(chance >= 1.0F) {
|
return random.nextFloat() < exposedChance;
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
return random.nextFloat() >= chance;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean shouldPlace(MaterialSet replaceable, BlockType type, Double exposed, Random random, WritableWorld world, int x,
|
public static boolean shouldPlace(MaterialSet replaceable, BlockType type, Double exposedChance, Random random, WritableWorld world,
|
||||||
|
int x,
|
||||||
int y, int z) {
|
int y, int z) {
|
||||||
if(!replaceable.contains(type)) {
|
if(!replaceable.contains(type)) return false;
|
||||||
return false;
|
if(shouldExpose(random, exposedChance)) return true; // Exposed blocks can be placed regardless of adjacency to air
|
||||||
} else if(shouldNotDiscard(random, exposed)) {
|
// Adjacency is checked after determining not exposed rather than vice-versa, assuming block checks are more expensive
|
||||||
return true;
|
boolean adjacentAir = world.getBlockState(x, y, z - 1).isAir() ||
|
||||||
} else {
|
|
||||||
return !(world.getBlockState(x, y, z - 1).isAir() ||
|
|
||||||
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, 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.getBlockState(x + 1, y, z).isAir());
|
world.getBlockState(x + 1, y, z).isAir();
|
||||||
|
return !adjacentAir; // Exposed check did not pass earlier so only blocks not adjacent air should place
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user