Fixed too long void roots
This commit is contained in:
parent
c285bb5136
commit
9ed5b7df19
2 changed files with 18 additions and 1 deletions
|
@ -13,6 +13,7 @@ import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.BlockPos.Mutable;
|
import net.minecraft.util.math.BlockPos.Mutable;
|
||||||
import net.minecraft.util.math.MathHelper;
|
import net.minecraft.util.math.MathHelper;
|
||||||
import net.minecraft.world.StructureWorldAccess;
|
import net.minecraft.world.StructureWorldAccess;
|
||||||
|
import ru.betterend.registry.EndTags;
|
||||||
import ru.betterend.util.sdf.SDF;
|
import ru.betterend.util.sdf.SDF;
|
||||||
import ru.betterend.util.sdf.operator.SDFUnion;
|
import ru.betterend.util.sdf.operator.SDFUnion;
|
||||||
import ru.betterend.util.sdf.primitive.SDFLine;
|
import ru.betterend.util.sdf.primitive.SDFLine;
|
||||||
|
@ -87,6 +88,22 @@ public class SplineHelper {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean fillSplineRoot(List<Vector3f> spline, StructureWorldAccess world, BlockState state, BlockPos pos, Function<BlockState, Boolean> replace) {
|
||||||
|
Vector3f startPos = spline.get(0);
|
||||||
|
for (int i = 1; i < spline.size(); i++) {
|
||||||
|
Vector3f endPos = spline.get(i);
|
||||||
|
if (i > 3 && !world.getBlockState(pos.add(endPos.getX(), endPos.getY(), endPos.getZ())).isIn(EndTags.END_GROUND)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!(fillLine(startPos, endPos, world, state, pos, replace))) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
startPos = endPos;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
private static boolean fillLine(Vector3f start, Vector3f end, StructureWorldAccess world, BlockState state, BlockPos pos, Function<BlockState, Boolean> replace) {
|
private static boolean fillLine(Vector3f start, Vector3f end, StructureWorldAccess world, BlockState state, BlockPos pos, Function<BlockState, Boolean> replace) {
|
||||||
float dx = end.getX() - start.getX();
|
float dx = end.getX() - start.getX();
|
||||||
float dy = end.getY() - start.getY();
|
float dy = end.getY() - start.getY();
|
||||||
|
|
|
@ -105,7 +105,7 @@ public class DragonTreeFeature extends DefaultFeature {
|
||||||
List<Vector3f> branch = SplineHelper.copySpline(ROOT);
|
List<Vector3f> branch = SplineHelper.copySpline(ROOT);
|
||||||
SplineHelper.rotateSpline(branch, angle);
|
SplineHelper.rotateSpline(branch, angle);
|
||||||
SplineHelper.scale(branch, scale);
|
SplineHelper.scale(branch, scale);
|
||||||
SplineHelper.fillSpline(branch, world, EndBlocks.DRAGON_TREE.bark.getDefaultState(), pos, REPLACE);
|
SplineHelper.fillSplineRoot(branch, world, EndBlocks.DRAGON_TREE.bark.getDefaultState(), pos, REPLACE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue