NBative Structure fixes.

- This fixes the native structures that are in iris from generating with pillaric problems
This commit is contained in:
Brian Neumann-Fopiano committed 2026-09-10 02:15:20 -04:00
1 parent 62e61970f8
commit e33e6a632a
10 files changed
+444 -35

No files matched your search

@@ -273,10 +273,33 @@ public final class ModdedEntitySpawner {
if (type == null) {
return true;
}
if (irisEntity.getSurface().isFluid()) {
return isFluidAreaClearForSpawn(blockX, blockY, blockZ, type.getWidth(), type.getHeight(),
position -> ModdedWorldManager.matchesSurface(irisEntity.getSurface(), level.getBlockState(position)));
}
return isAreaClearForSpawn(blockX, blockY, blockZ, type.getWidth(), type.getHeight(),
position -> level.getBlockState(position).is(Blocks.AIR));
}
static boolean isFluidAreaClearForSpawn(int blockX, int blockY, int blockZ,
float width, float height, Predicate<BlockPos> matchesFluid) {
int startX = (int) Math.floor(blockX + 0.5 - width / 2D);
int endX = (int) Math.floor(Math.nextDown(blockX + 0.5 + width / 2D));
int endY = (int) Math.floor(Math.nextDown(blockY + 0.5 + height));
int startZ = (int) Math.floor(blockZ + 0.5 - width / 2D);
int endZ = (int) Math.floor(Math.nextDown(blockZ + 0.5 + width / 2D));
for (int x = startX; x <= endX; x++) {
for (int y = blockY; y <= endY; y++) {
for (int z = startZ; z <= endZ; z++) {
if (!matchesFluid.test(new BlockPos(x, y, z))) {
return false;
}
}
}
}
return true;
}
static boolean isAreaClearForSpawn(int blockX, int blockY, int blockZ, float width, float height, Predicate<BlockPos> isAir) {
int radius = (int) (width / 2F);
int endY = blockY + (int) height;
@@ -604,9 +604,11 @@ public final class ModdedWorldManager implements EngineWorldManager {
worldZ = (chunkZ << 4) + RNG.r.i(16);
int surfaceY = level.getHeight(Heightmap.Types.WORLD_SURFACE, worldX, worldZ) - 1;
int solidY = level.getHeight(Heightmap.Types.OCEAN_FLOOR, worldX, worldZ) - 1;
worldY = group == IrisSpawnGroup.NORMAL
? surfaceY + 1
: RNG.r.i(solidY + 1, surfaceY);
Integer selectedY = IrisEntitySpawn.selectSurfaceSpawnY(group, irisEntity.getSurface(), solidY, surfaceY, RNG.r);
if (selectedY == null) {
continue;
}
worldY = selectedY;
}
if (worldY <= level.getMinY() || worldY >= level.getMaxY()) {
continue;
@@ -653,6 +655,11 @@ public final class ModdedWorldManager implements EngineWorldManager {
if (!lightAllowed(spawner, level, worldX, worldY, worldZ)) {
continue;
}
if (irisEntity.getSurface().isFluid()
&& (!surfaceMatches(irisEntity.getSurface(), level, worldX, worldY, worldZ)
|| !ModdedEntitySpawner.isAreaClearForSpawn(level, irisEntity, worldX, worldY, worldZ))) {
continue;
}
if (ModdedEntitySpawner.spawn(engine, irisEntity, level, worldX, worldY, worldZ, entityRng) != null) {
spawned++;
}
@@ -681,11 +688,11 @@ public final class ModdedWorldManager implements EngineWorldManager {
}
private boolean surfaceMatches(IrisSurface surface, ServerLevel level, int worldX, int worldY, int worldZ) {
BlockState below = level.getBlockState(new BlockPos(worldX, worldY - 1, worldZ));
BlockState below = level.getBlockState(new BlockPos(worldX, worldY - (surface.isFluid() ? 0 : 1), worldZ));
return matchesSurface(surface, below);
}
private static boolean matchesSurface(IrisSurface surface, BlockState below) {
static boolean matchesSurface(IrisSurface surface, BlockState below) {
if (ModdedBlockResolution.isSolid(below)) {
return surface == IrisSurface.LAND || surface == IrisSurface.OVERWORLD
|| (surface == IrisSurface.ANIMAL && isAnimalGround(below));