Lakugrove structure
This commit is contained in:
parent
0f9edccc4e
commit
91b40a3ae6
17 changed files with 301 additions and 64 deletions
|
@ -13,6 +13,7 @@ import com.google.common.collect.Sets;
|
|||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.BlockPos.Mutable;
|
||||
import net.minecraft.util.math.Box;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.world.ServerWorldAccess;
|
||||
import ru.betterend.util.BlocksHelper;
|
||||
|
@ -155,6 +156,102 @@ public abstract class SDF {
|
|||
}
|
||||
}
|
||||
|
||||
public void fillArea(ServerWorldAccess world, BlockPos center, Box box) {
|
||||
Map<BlockPos, PosInfo> mapWorld = Maps.newHashMap();
|
||||
Map<BlockPos, PosInfo> addInfo = Maps.newHashMap();
|
||||
|
||||
Mutable mut = new Mutable();
|
||||
for (int y = (int) box.minY; y <= box.maxY; y++) {
|
||||
mut.setY(y);
|
||||
for (int x = (int) box.minX; x <= box.maxX; x++) {
|
||||
mut.setX(x);
|
||||
for (int z = (int) box.minZ; z <= box.maxZ; z++) {
|
||||
mut.setZ(z);
|
||||
if (canReplace.apply(world.getBlockState(mut))) {
|
||||
BlockPos fpos = mut.subtract(center);
|
||||
if (this.getDistance(fpos.getX(), fpos.getY(), fpos.getZ()) < 0) {
|
||||
PosInfo.create(mapWorld, addInfo, mut.toImmutable()).setState(getBlockState(mut));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<PosInfo> infos = new ArrayList<PosInfo>(mapWorld.values());
|
||||
if (infos.size() > 0) {
|
||||
Collections.sort(infos);
|
||||
infos.forEach((info) -> {
|
||||
BlockState state = postProcess.apply(info);
|
||||
BlocksHelper.setWithoutUpdate(world, info.getPos(), state);
|
||||
});
|
||||
|
||||
infos.clear();
|
||||
infos.addAll(addInfo.values());
|
||||
Collections.sort(infos);
|
||||
infos.forEach((info) -> {
|
||||
if (canReplace.apply(world.getBlockState(info.getPos()))) {
|
||||
BlockState state = postProcess.apply(info);
|
||||
BlocksHelper.setWithoutUpdate(world, info.getPos(), state);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public void fillRecursiveIgnore(ServerWorldAccess world, BlockPos start, Function<BlockState, Boolean> ignore) {
|
||||
Map<BlockPos, PosInfo> mapWorld = Maps.newHashMap();
|
||||
Map<BlockPos, PosInfo> addInfo = 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;
|
||||
|
||||
Mutable bPos = new Mutable();
|
||||
|
||||
while (run) {
|
||||
for (BlockPos center: ends) {
|
||||
for (Direction dir: Direction.values()) {
|
||||
bPos.set(center).move(dir);
|
||||
BlockPos wpos = bPos.add(start);
|
||||
BlockState state = world.getBlockState(wpos);
|
||||
boolean ign = ignore.apply(state);
|
||||
if (!blocks.contains(bPos) && (ign || canReplace.apply(state))) {
|
||||
if (this.getDistance(bPos.getX(), bPos.getY(), bPos.getZ()) < 0) {
|
||||
PosInfo.create(mapWorld, addInfo, wpos).setState(ign ? state : getBlockState(bPos));
|
||||
add.add(bPos.toImmutable());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
blocks.addAll(ends);
|
||||
ends.clear();
|
||||
ends.addAll(add);
|
||||
add.clear();
|
||||
|
||||
run &= !ends.isEmpty();
|
||||
}
|
||||
|
||||
List<PosInfo> infos = new ArrayList<PosInfo>(mapWorld.values());
|
||||
if (infos.size() > 0) {
|
||||
Collections.sort(infos);
|
||||
infos.forEach((info) -> {
|
||||
BlockState state = postProcess.apply(info);
|
||||
BlocksHelper.setWithoutUpdate(world, info.getPos(), state);
|
||||
});
|
||||
|
||||
infos.clear();
|
||||
infos.addAll(addInfo.values());
|
||||
Collections.sort(infos);
|
||||
infos.forEach((info) -> {
|
||||
if (canReplace.apply(world.getBlockState(info.getPos()))) {
|
||||
BlockState state = postProcess.apply(info);
|
||||
BlocksHelper.setWithoutUpdate(world, info.getPos(), state);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public void fillRecursive(StructureWorld world, BlockPos start) {
|
||||
Map<BlockPos, PosInfo> mapWorld = Maps.newHashMap();
|
||||
Map<BlockPos, PosInfo> addInfo = Maps.newHashMap();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue