Giant Mushroom
This commit is contained in:
parent
2afdc1e2eb
commit
150b005257
12 changed files with 288 additions and 6 deletions
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
15
src/main/java/ru/betterend/util/sdf/operator/SDFRound.java
Normal file
15
src/main/java/ru/betterend/util/sdf/operator/SDFRound.java
Normal file
|
@ -0,0 +1,15 @@
|
|||
package ru.betterend.util.sdf.operator;
|
||||
|
||||
public class SDFRound extends SDFUnary {
|
||||
private float radius;
|
||||
|
||||
public SDFRound setRadius(float radius) {
|
||||
this.radius = radius;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getDistance(float x, float y, float z) {
|
||||
return this.source.getDistance(x, y, z) - radius;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue