Start migration
This commit is contained in:
parent
6630ce0cab
commit
47ed597358
491 changed files with 12045 additions and 11953 deletions
|
@ -5,10 +5,10 @@ import java.util.Random;
|
|||
|
||||
import com.google.common.base.Function;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Material;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraft.client.util.math.Vector3f;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.StructureWorldAccess;
|
||||
import net.minecraft.world.gen.chunk.ChunkGenerator;
|
||||
import net.minecraft.world.gen.feature.DefaultFeatureConfig;
|
||||
|
@ -21,22 +21,27 @@ import ru.betterend.world.features.DefaultFeature;
|
|||
|
||||
public class BigEtherTreeFeature extends DefaultFeature {
|
||||
@Override
|
||||
public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, DefaultFeatureConfig config) {
|
||||
if (!world.getBlockState(pos.down()).getBlock().isIn(EndTags.END_GROUND)) return false;
|
||||
|
||||
public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos,
|
||||
DefaultFeatureConfig config) {
|
||||
if (!world.getBlockState(pos.below()).getBlock().isIn(EndTags.END_GROUND))
|
||||
return false;
|
||||
|
||||
BlockState log = Integrations.BYG.getDefaultState("ether_log");
|
||||
BlockState wood = Integrations.BYG.getDefaultState("ether_wood");
|
||||
//BlockState leaves = Integrations.BYG.getDefaultState("ether_leaves");
|
||||
Function<BlockPos, BlockState> splinePlacer = (bpos) -> { return log; };
|
||||
Function<BlockState, Boolean> replace = (state) -> {
|
||||
return state.isIn(EndTags.END_GROUND) || state.getMaterial().equals(Material.PLANT) || state.getMaterial().isReplaceable();
|
||||
// BlockState leaves = Integrations.BYG.getDefaultState("ether_leaves");
|
||||
Function<BlockPos, BlockState> splinePlacer = (bpos) -> {
|
||||
return log;
|
||||
};
|
||||
|
||||
Function<BlockState, Boolean> replace = (state) -> {
|
||||
return state.isIn(EndTags.END_GROUND) || state.getMaterial().equals(Material.PLANT)
|
||||
|| state.getMaterial().isReplaceable();
|
||||
};
|
||||
|
||||
int height = MHelper.randRange(40, 60, random);
|
||||
List<Vector3f> trunk = SplineHelper.makeSpline(0, 0, 0, 0, height, 0, height / 4);
|
||||
SplineHelper.offsetParts(trunk, random, 2F, 0, 2F);
|
||||
SDF sdf = SplineHelper.buildSDF(trunk, 2.3F, 0.8F, splinePlacer);
|
||||
|
||||
|
||||
int count = height / 15;
|
||||
for (int i = 1; i < count; i++) {
|
||||
float splinePos = (float) i / (float) count;
|
||||
|
@ -46,21 +51,22 @@ public class BigEtherTreeFeature extends DefaultFeature {
|
|||
List<Vector3f> branch = SplineHelper.makeSpline(0, 0, 0, length, 0, 0, points < 2 ? 2 : points);
|
||||
SplineHelper.powerOffset(branch, length, 2F);
|
||||
int rotCount = MHelper.randRange(5, 7, random);
|
||||
//float startRad = MathHelper.lerp(splinePos, 2.3F, 0.8F) * 0.8F;
|
||||
// float startRad = Mth.lerp(splinePos, 2.3F, 0.8F) * 0.8F;
|
||||
Vector3f start = SplineHelper.getPos(trunk, splinePos * (trunk.size() - 1));
|
||||
for (int j = 0; j < rotCount; j++) {
|
||||
float angle = startAngle + (float) j / rotCount * MHelper.PI2;
|
||||
List<Vector3f> br = SplineHelper.copySpline(branch);
|
||||
SplineHelper.offsetParts(br, random, 0, 1, 1);
|
||||
SplineHelper.rotateSpline(br, angle);
|
||||
|
||||
|
||||
SplineHelper.offset(br, start);
|
||||
SplineHelper.fillSpline(br, world, wood, pos, replace);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
sdf.setReplaceFunction((state) -> {
|
||||
return state.isIn(EndTags.END_GROUND) || state.getMaterial().equals(Material.PLANT) || state.getMaterial().isReplaceable();
|
||||
return state.isIn(EndTags.END_GROUND) || state.getMaterial().equals(Material.PLANT)
|
||||
|| state.getMaterial().isReplaceable();
|
||||
}).addPostProcess((info) -> {
|
||||
if (info.getState().equals(log) && (!info.getStateUp().equals(log) || !info.getStateDown().equals(log))) {
|
||||
return wood;
|
||||
|
@ -70,8 +76,9 @@ public class BigEtherTreeFeature extends DefaultFeature {
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
//private void makeLeavesSphere(StructureWorldAccess world, BlockPos pos, BlockState leaves, Function<BlockState, Boolean> ignore) {
|
||||
//
|
||||
//}
|
||||
|
||||
// private void makeLeavesSphere(StructureWorldAccess world, BlockPos pos,
|
||||
// BlockState leaves, Function<BlockState, Boolean> ignore) {
|
||||
//
|
||||
// }
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue