Create Arrakis brushable deposits after terrain population
This commit is contained in:
parent
2eb3f54b8f
commit
3322ba507e
2 changed files with 21 additions and 10 deletions
|
|
@ -444,6 +444,10 @@ public final class DuneTerrain extends JavaPlugin implements Listener {
|
|||
placeRandomSpicePatch(data, chunkX, chunkZ, heights,emittedSpice);
|
||||
if (plugin.getConfig().getBoolean("dense-spice.enabled", true)) {
|
||||
int spacing = Math.max(128, plugin.getConfig().getInt("dense-spice.spacing", 512));
|
||||
for(var entries=emittedSpice.iterator();entries.hasNext();){
|
||||
var p=entries.next();
|
||||
if(DenseSpice.contains(world.getSeed(),chunkX*16+p.x(),chunkZ*16+p.z(),spacing))entries.remove();
|
||||
}
|
||||
for (int x=0;x<16;x++) for(int z=0;z<16;z++)
|
||||
if(DenseSpice.contains(world.getSeed(),chunkX*16+x,chunkZ*16+z,spacing))
|
||||
data.setBlock(x,heights[x][z],z,Material.ORANGE_TERRACOTTA);
|
||||
|
|
@ -573,8 +577,8 @@ public final class DuneTerrain extends JavaPlugin implements Listener {
|
|||
for (int i = 0; i < count; i++) {
|
||||
int x = random.nextInt(16), z = random.nextInt(16), y = heights[x][z];
|
||||
Material surface = data.getType(x, y, z);
|
||||
if (y + 1 < maxY && y > minY && (surface == Material.SAND || surface == Material.RED_SAND)){
|
||||
data.setBlock(x, y, z, Material.SUSPICIOUS_SAND);emitted.add(new SpiceDepositProvenance.Position(x,y,z));}
|
||||
if (y + 1 < maxY && y > minY && SpiceDepositProvenance.hostSand(surface))
|
||||
emitted.add(new SpiceDepositProvenance.Position(x,y,z));
|
||||
}
|
||||
}
|
||||
private void placeRandomSpicePatch(ChunkData data, int chunkX, int chunkZ, int[][] heights,List<SpiceDepositProvenance.Position> emitted) {
|
||||
|
|
@ -604,8 +608,8 @@ public final class DuneTerrain extends JavaPlugin implements Listener {
|
|||
long blockSeed = mix64(gx * 0x9E3779B97F4A7C15L ^ gz * 0xC2B2AE3D27D4EB4FL ^ salt);
|
||||
if (hashUnit(blockSeed) >= density) continue;
|
||||
int y = heights[x][z];
|
||||
if (data.getType(x, y, z) == Material.SAND || data.getType(x, y, z) == Material.RED_SAND)
|
||||
{data.setBlock(x, y, z, Material.SUSPICIOUS_SAND);emitted.add(new SpiceDepositProvenance.Position(x,y,z));}
|
||||
if (SpiceDepositProvenance.hostSand(data.getType(x, y, z)))
|
||||
emitted.add(new SpiceDepositProvenance.Position(x,y,z));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,15 +32,20 @@ final class SpiceDepositProvenance extends BlockPopulator {
|
|||
void capture(WorldInfo world,int cx,int cz,Collection<Position> positions,ChunkGenerator.ChunkData data){
|
||||
if(world.getUID()==null||pending.size()>=4096)return; // Fail closed; never grow an unbounded generation cache.
|
||||
Set<Position> actual=new HashSet<>();
|
||||
for(Position p:positions)if(data.getType(p.x(),p.y(),p.z())==Material.SUSPICIOUS_SAND)actual.add(new Position(cx*16+p.x(),p.y(),cz*16+p.z()));
|
||||
for(Position p:positions)if(hostSand(data.getType(p.x(),p.y(),p.z())))actual.add(new Position(cx*16+p.x(),p.y(),cz*16+p.z()));
|
||||
if(!actual.isEmpty())pending.put(new ChunkKey(world.getUID(),cx,cz),Set.copyOf(actual));
|
||||
}
|
||||
@Override public void populate(WorldInfo world,Random random,int cx,int cz,LimitedRegion region){
|
||||
Set<Position> positions=pending.remove(new ChunkKey(world.getUID(),cx,cz));if(positions==null)return;
|
||||
for(Position p:positions)if(region.isInRegion(p.x(),p.y(),p.z())&®ion.getType(p.x(),p.y(),p.z())==Material.SUSPICIOUS_SAND){
|
||||
BlockState state=region.getBlockState(p.x(),p.y(),p.z());mark(state);
|
||||
for(Position p:positions)if(region.isInRegion(p.x(),p.y(),p.z())){
|
||||
Material host=region.getType(p.x(),p.y(),p.z());
|
||||
if(!hostSand(host))continue;
|
||||
// Materialize the block entity only after native carving and structure population.
|
||||
region.setType(p.x(),p.y(),p.z(),Material.SUSPICIOUS_SAND);
|
||||
if(!mark(region.getBlockState(p.x(),p.y(),p.z())))region.setType(p.x(),p.y(),p.z(),host);
|
||||
}
|
||||
}
|
||||
static boolean hostSand(Material type){return type==Material.SAND||type==Material.RED_SAND;}
|
||||
static boolean mark(BlockState state){
|
||||
if(state.getType()!=Material.SUSPICIOUS_SAND||!(state instanceof BrushableBlock tile)||tile.getLootTable()!=null||tile.getItem()!=null&&!tile.getItem().isEmpty())return false;
|
||||
tile.getPersistentDataContainer().set(KEY,PersistentDataType.BYTE,(byte)1);return tile.update(true,false);
|
||||
|
|
|
|||
Loading…
Reference in a new issue

Staff