Giant Mushroom

This commit is contained in:
paulevsGitch 2020-10-06 12:26:13 +03:00
parent 2afdc1e2eb
commit 150b005257
12 changed files with 288 additions and 6 deletions

View file

@ -12,6 +12,7 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.world.ServerWorldAccess;
import ru.betterend.util.BlocksHelper;
import ru.betterend.world.structures.StructureWorld;
public abstract class SDF {
private Function<PosInfo, BlockState> postProcess = (info) -> {
@ -120,4 +121,44 @@ public abstract class SDF {
return mapWorld.keySet();
}
public Set<BlockPos> fillRecursive(StructureWorld world, BlockPos start) {
Map<BlockPos, PosInfo> mapWorld = Maps.newHashMap();
Set<BlockPos> blocks = Sets.newHashSet();
Set<BlockPos> ends = Sets.newHashSet();
Set<BlockPos> add = Sets.newHashSet();
ends.add(new BlockPos(0, 0, 0));
boolean run = true;
while (run) {
for (BlockPos center: ends) {
for (Direction dir: Direction.values()) {
BlockPos pos = center.offset(dir);
BlockPos wpos = pos.add(start);
if (!blocks.contains(pos)) {
if (this.getDistance(pos.getX(), pos.getY(), pos.getZ()) < 0) {
BlockState state = getBlockState(wpos);
PosInfo.create(mapWorld, wpos).setState(state);
add.add(pos);
}
}
}
}
blocks.addAll(ends);
ends.clear();
ends.addAll(add);
add.clear();
run &= !ends.isEmpty();
}
mapWorld.forEach((pos, info) -> {
BlockState state = postProcess.apply(info);
world.setBlock(pos, state);
});
return mapWorld.keySet();
}
}