SDF materials
This commit is contained in:
parent
2e632bf245
commit
257307d93d
14 changed files with 107 additions and 15 deletions
|
@ -6,15 +6,15 @@ import java.util.function.Function;
|
|||
import com.google.common.collect.Sets;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.world.ServerWorldAccess;
|
||||
import ru.betterend.util.BlocksHelper;
|
||||
|
||||
public interface ISDF {
|
||||
public float getDistance(float x, float y, float z);
|
||||
|
||||
public void setBlock(ServerWorldAccess world, BlockPos pos);
|
||||
|
||||
default void fillRecursive(ServerWorldAccess world, BlockPos start, Function<BlockState, Boolean> canReplace, int dx, int dy, int dz) {
|
||||
Set<BlockPos> blocks = Sets.newHashSet();
|
||||
Set<BlockPos> ends = Sets.newHashSet();
|
||||
|
@ -34,8 +34,10 @@ public interface ISDF {
|
|||
|
||||
if (!blocks.contains(pos) && canReplace.apply(world.getBlockState(wpos))) {
|
||||
if (this.getDistance(pos.getX(), pos.getY(), pos.getZ()) < 0) {
|
||||
BlocksHelper.setWithoutUpdate(world, wpos, Blocks.STONE);
|
||||
add.add(pos);
|
||||
setBlock(world, wpos);
|
||||
if (Math.abs(pos.getX()) < dx && Math.abs(pos.getY()) < dy && Math.abs(pos.getZ()) < dz) {
|
||||
add.add(pos);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -65,7 +67,7 @@ public interface ISDF {
|
|||
|
||||
if (!blocks.contains(pos) && canReplace.apply(world.getBlockState(wpos))) {
|
||||
if (this.getDistance(pos.getX(), pos.getY(), pos.getZ()) <= 0) {
|
||||
BlocksHelper.setWithoutUpdate(world, wpos, Blocks.STONE);
|
||||
setBlock(world, wpos);
|
||||
add.add(pos);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue