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) {
|
||||
//
|
||||
// }
|
||||
}
|
||||
|
|
|
@ -6,14 +6,14 @@ import java.util.Random;
|
|||
import com.google.common.base.Function;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.LeavesBlock;
|
||||
import net.minecraft.block.Material;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.LeavesBlock;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraft.client.util.math.Vector3f;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.BlockPos.Mutable;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.BlockPos.MutableBlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.StructureWorldAccess;
|
||||
import net.minecraft.world.gen.chunk.ChunkGenerator;
|
||||
import net.minecraft.world.gen.feature.DefaultFeatureConfig;
|
||||
|
@ -33,19 +33,25 @@ import ru.betterend.world.features.DefaultFeature;
|
|||
|
||||
public class GreatNightshadeTreeFeature extends DefaultFeature {
|
||||
private static final List<Vector3f> BRANCH;
|
||||
|
||||
|
||||
@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("nightshade_log");
|
||||
BlockState wood = Integrations.BYG.getDefaultState("nightshade_wood");
|
||||
BlockState leaves = Integrations.BYG.getDefaultState("nightshade_leaves").with(LeavesBlock.DISTANCE, 1);
|
||||
BlockState leaves_flower = Integrations.BYG.getDefaultState("flowering_nightshade_leaves").with(LeavesBlock.DISTANCE, 1);
|
||||
|
||||
Function<BlockPos, BlockState> splinePlacer = (bpos) -> { return log; };
|
||||
BlockState leaves_flower = Integrations.BYG.getDefaultState("flowering_nightshade_leaves")
|
||||
.with(LeavesBlock.DISTANCE, 1);
|
||||
|
||||
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();
|
||||
return state.isIn(EndTags.END_GROUND) || state.getMaterial().equals(Material.PLANT)
|
||||
|| state.getMaterial().isReplaceable();
|
||||
};
|
||||
Function<PosInfo, BlockState> post = (info) -> {
|
||||
if (info.getState().equals(log) && (!info.getStateUp().equals(log) || !info.getStateDown().equals(log))) {
|
||||
|
@ -56,15 +62,15 @@ public class GreatNightshadeTreeFeature extends DefaultFeature {
|
|||
Function<BlockState, Boolean> ignore = (state) -> {
|
||||
return state.equals(log) || state.equals(wood);
|
||||
};
|
||||
|
||||
|
||||
int height = MHelper.randRange(40, 60, random);
|
||||
List<Vector3f> trunk = SplineHelper.makeSpline(0, 0, 0, 0, height, 0, height / 4);
|
||||
SplineHelper.offsetParts(trunk, random, 0.8F, 0, 0.8F);
|
||||
|
||||
|
||||
if (!SplineHelper.canGenerate(trunk, pos, world, replace)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
int count = height >> 2;
|
||||
float start = trunk.size() / 3F;
|
||||
float delta = trunk.size() * 0.6F;
|
||||
|
@ -83,20 +89,21 @@ public class GreatNightshadeTreeFeature extends DefaultFeature {
|
|||
SplineHelper.fillSpline(branch, world, wood, pos, replace);
|
||||
}
|
||||
SplineHelper.fillSpline(trunk, world, log, pos, ignore);
|
||||
|
||||
|
||||
SDF sdf = SplineHelper.buildSDF(trunk, 2.3F, 0.8F, splinePlacer);
|
||||
SDF roots = new SDFSphere().setRadius(2F).setBlock(log);
|
||||
roots = new SDFFlatWave().setIntensity(2F).setRaysCount(MHelper.randRange(5, 7, random)).setAngle(random.nextFloat() * MHelper.PI2).setSource(roots);
|
||||
roots = new SDFFlatWave().setIntensity(2F).setRaysCount(MHelper.randRange(5, 7, random))
|
||||
.setAngle(random.nextFloat() * MHelper.PI2).setSource(roots);
|
||||
sdf = new SDFSmoothUnion().setRadius(2F).setSourceA(sdf).setSourceB(roots);
|
||||
sdf.setReplaceFunction(replace).addPostProcess(post).fillRecursive(world, pos);
|
||||
Vector3f last = SplineHelper.getPos(trunk, trunk.size() - 1.75F);
|
||||
for (int y = 0; y < 8; y++) {
|
||||
BlockPos p = pos.add(last.getX() + 0.5, last.getY() + y, last.getZ() + 0.5);
|
||||
BlockPos p = pos.offset(last.getX() + 0.5, last.getY() + y, last.getZ() + 0.5);
|
||||
BlocksHelper.setWithoutUpdate(world, p, y == 4 ? wood : log);
|
||||
}
|
||||
|
||||
|
||||
for (int y = 0; y < 16; y++) {
|
||||
BlockPos p = pos.add(last.getX() + 0.5, last.getY() + y, last.getZ() + 0.5);
|
||||
BlockPos p = pos.offset(last.getX() + 0.5, last.getY() + y, last.getZ() + 0.5);
|
||||
if (world.isAir(p)) {
|
||||
BlocksHelper.setWithoutUpdate(world, p, leaves);
|
||||
}
|
||||
|
@ -116,8 +123,8 @@ public class GreatNightshadeTreeFeature extends DefaultFeature {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
Mutable mut = new Mutable();
|
||||
|
||||
MutableBlockPos mut = new MutableBlockPos();
|
||||
Function<PosInfo, BlockState> leavesPost1 = (info) -> {
|
||||
if (info.getState().equals(log) || info.getState().equals(wood)) {
|
||||
for (int x = -6; x < 7; x++) {
|
||||
|
@ -133,7 +140,7 @@ public class GreatNightshadeTreeFeature extends DefaultFeature {
|
|||
mut.setY(y + info.getPos().getY());
|
||||
BlockState state = info.getState(mut);
|
||||
if (state.getBlock() instanceof LeavesBlock) {
|
||||
int distance = state.get(LeavesBlock.DISTANCE);
|
||||
int distance = state.getValue(LeavesBlock.DISTANCE);
|
||||
if (d < distance) {
|
||||
info.setState(mut, state.with(LeavesBlock.DISTANCE, d));
|
||||
}
|
||||
|
@ -149,15 +156,15 @@ public class GreatNightshadeTreeFeature extends DefaultFeature {
|
|||
if (info.getState().getBlock() instanceof LeavesBlock) {
|
||||
int distance = info.getState().get(LeavesBlock.DISTANCE);
|
||||
if (distance > MHelper.randRange(2, 4, random)) {
|
||||
return Blocks.AIR.getDefaultState();
|
||||
return Blocks.AIR.defaultBlockState();
|
||||
}
|
||||
for (Direction d: BlocksHelper.DIRECTIONS) {
|
||||
for (Direction d : BlocksHelper.DIRECTIONS) {
|
||||
int airCount = 0;
|
||||
if (info.getState(d).isAir()) {
|
||||
airCount ++;
|
||||
airCount++;
|
||||
}
|
||||
if (airCount > 5) {
|
||||
return Blocks.AIR.getDefaultState();
|
||||
return Blocks.AIR.defaultBlockState();
|
||||
}
|
||||
}
|
||||
if (random.nextInt(8) == 0) {
|
||||
|
@ -166,19 +173,19 @@ public class GreatNightshadeTreeFeature extends DefaultFeature {
|
|||
}
|
||||
return info.getState();
|
||||
};
|
||||
|
||||
|
||||
SDF canopy = new SDFCappedCone().setRadius1(12F).setRadius2(1f).setHeight(height * 0.3F).setBlock(leaves);
|
||||
canopy = new SDFDisplacement().setFunction((vec) -> { return MHelper.randRange(-3F, 3F, random); }).setSource(canopy);
|
||||
canopy.addPostProcess(leavesPost1).addPostProcess(leavesPost2).fillRecursiveIgnore(world, pos.add(0, height * 0.75, 0), ignore);
|
||||
|
||||
canopy = new SDFDisplacement().setFunction((vec) -> {
|
||||
return MHelper.randRange(-3F, 3F, random);
|
||||
}).setSource(canopy);
|
||||
canopy.addPostProcess(leavesPost1).addPostProcess(leavesPost2).fillRecursiveIgnore(world,
|
||||
pos.offset(0, height * 0.75, 0), ignore);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
static {
|
||||
BRANCH = Lists.newArrayList(new Vector3f(0, 0, 0),
|
||||
new Vector3f(0.25F, 0.1F, 0),
|
||||
new Vector3f(0.40F, 0.2F, 0),
|
||||
new Vector3f(0.50F, 0.4F, 0),
|
||||
new Vector3f(0.55F, 0.6F, 0));
|
||||
BRANCH = Lists.newArrayList(new Vector3f(0, 0, 0), new Vector3f(0.25F, 0.1F, 0), new Vector3f(0.40F, 0.2F, 0),
|
||||
new Vector3f(0.50F, 0.4F, 0), new Vector3f(0.55F, 0.6F, 0));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,14 +6,14 @@ import java.util.Random;
|
|||
import com.google.common.base.Function;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.LeavesBlock;
|
||||
import net.minecraft.block.Material;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.LeavesBlock;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraft.client.util.math.Vector3f;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.BlockPos.Mutable;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.BlockPos.MutableBlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.StructureWorldAccess;
|
||||
import net.minecraft.world.gen.chunk.ChunkGenerator;
|
||||
import net.minecraft.world.gen.feature.DefaultFeatureConfig;
|
||||
|
@ -33,19 +33,24 @@ import ru.betterend.world.features.DefaultFeature;
|
|||
|
||||
public class NightshadeRedwoodTreeFeature extends DefaultFeature {
|
||||
private static final List<Vector3f> BRANCH;
|
||||
|
||||
|
||||
@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("nightshade_log");
|
||||
BlockState wood = Integrations.BYG.getDefaultState("nightshade_wood");
|
||||
BlockState leaves = Integrations.BYG.getDefaultState("nightshade_leaves");
|
||||
BlockState leaves_flower = Integrations.BYG.getDefaultState("flowering_nightshade_leaves");
|
||||
|
||||
Function<BlockPos, BlockState> splinePlacer = (bpos) -> { return log; };
|
||||
|
||||
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();
|
||||
return state.isIn(EndTags.END_GROUND) || state.getMaterial().equals(Material.PLANT)
|
||||
|| state.getMaterial().isReplaceable();
|
||||
};
|
||||
Function<PosInfo, BlockState> post = (info) -> {
|
||||
if (info.getState().equals(log) && (!info.getStateUp().equals(log) || !info.getStateDown().equals(log))) {
|
||||
|
@ -56,15 +61,15 @@ public class NightshadeRedwoodTreeFeature extends DefaultFeature {
|
|||
Function<BlockState, Boolean> ignore = (state) -> {
|
||||
return state.equals(log) || state.equals(wood);
|
||||
};
|
||||
|
||||
|
||||
int height = MHelper.randRange(40, 60, random);
|
||||
List<Vector3f> trunk = SplineHelper.makeSpline(0, 0, 0, 0, height, 0, height / 4);
|
||||
SplineHelper.offsetParts(trunk, random, 0.8F, 0, 0.8F);
|
||||
|
||||
|
||||
if (!SplineHelper.canGenerate(trunk, pos, world, replace)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
int count = height >> 2;
|
||||
float start = trunk.size() / 3F;
|
||||
float delta = trunk.size() * 0.6F;
|
||||
|
@ -83,20 +88,21 @@ public class NightshadeRedwoodTreeFeature extends DefaultFeature {
|
|||
SplineHelper.offset(branch, offset);
|
||||
SplineHelper.fillSpline(branch, world, wood, pos, replace);
|
||||
}
|
||||
|
||||
|
||||
SDF sdf = SplineHelper.buildSDF(trunk, 2.3F, 0.8F, splinePlacer);
|
||||
SDF roots = new SDFSphere().setRadius(2F).setBlock(log);
|
||||
roots = new SDFFlatWave().setIntensity(2F).setRaysCount(MHelper.randRange(5, 7, random)).setAngle(random.nextFloat() * MHelper.PI2).setSource(roots);
|
||||
roots = new SDFFlatWave().setIntensity(2F).setRaysCount(MHelper.randRange(5, 7, random))
|
||||
.setAngle(random.nextFloat() * MHelper.PI2).setSource(roots);
|
||||
sdf = new SDFSmoothUnion().setRadius(2F).setSourceA(sdf).setSourceB(roots);
|
||||
sdf.setReplaceFunction(replace).addPostProcess(post).fillRecursive(world, pos);
|
||||
Vector3f last = SplineHelper.getPos(trunk, trunk.size() - 1.35F);
|
||||
for (int y = 0; y < 8; y++) {
|
||||
BlockPos p = pos.add(last.getX() + 0.5, last.getY() + y, last.getZ() + 0.5);
|
||||
BlockPos p = pos.offset(last.getX() + 0.5, last.getY() + y, last.getZ() + 0.5);
|
||||
BlocksHelper.setWithoutUpdate(world, p, y == 4 ? wood : log);
|
||||
}
|
||||
|
||||
|
||||
for (int y = 0; y < 16; y++) {
|
||||
BlockPos p = pos.add(last.getX() + 0.5, last.getY() + y, last.getZ() + 0.5);
|
||||
BlockPos p = pos.offset(last.getX() + 0.5, last.getY() + y, last.getZ() + 0.5);
|
||||
if (world.isAir(p)) {
|
||||
BlocksHelper.setWithoutUpdate(world, p, leaves);
|
||||
}
|
||||
|
@ -116,8 +122,8 @@ public class NightshadeRedwoodTreeFeature extends DefaultFeature {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
Mutable mut = new Mutable();
|
||||
|
||||
MutableBlockPos mut = new MutableBlockPos();
|
||||
Function<PosInfo, BlockState> leavesPost1 = (info) -> {
|
||||
if (info.getState().equals(log) || info.getState().equals(wood)) {
|
||||
for (int x = -6; x < 7; x++) {
|
||||
|
@ -133,7 +139,7 @@ public class NightshadeRedwoodTreeFeature extends DefaultFeature {
|
|||
mut.setY(y + info.getPos().getY());
|
||||
BlockState state = info.getState(mut);
|
||||
if (state.getBlock() instanceof LeavesBlock) {
|
||||
int distance = state.get(LeavesBlock.DISTANCE);
|
||||
int distance = state.getValue(LeavesBlock.DISTANCE);
|
||||
if (d < distance) {
|
||||
info.setState(mut, state.with(LeavesBlock.DISTANCE, d));
|
||||
}
|
||||
|
@ -149,15 +155,15 @@ public class NightshadeRedwoodTreeFeature extends DefaultFeature {
|
|||
if (info.getState().getBlock() instanceof LeavesBlock) {
|
||||
int distance = info.getState().get(LeavesBlock.DISTANCE);
|
||||
if (distance > MHelper.randRange(2, 4, random)) {
|
||||
return Blocks.AIR.getDefaultState();
|
||||
return Blocks.AIR.defaultBlockState();
|
||||
}
|
||||
for (Direction d: BlocksHelper.DIRECTIONS) {
|
||||
for (Direction d : BlocksHelper.DIRECTIONS) {
|
||||
int airCount = 0;
|
||||
if (info.getState(d).isAir()) {
|
||||
airCount ++;
|
||||
airCount++;
|
||||
}
|
||||
if (airCount > 5) {
|
||||
return Blocks.AIR.getDefaultState();
|
||||
return Blocks.AIR.defaultBlockState();
|
||||
}
|
||||
}
|
||||
if (random.nextInt(8) == 0) {
|
||||
|
@ -166,19 +172,19 @@ public class NightshadeRedwoodTreeFeature extends DefaultFeature {
|
|||
}
|
||||
return info.getState();
|
||||
};
|
||||
|
||||
|
||||
SDF canopy = new SDFCappedCone().setRadius1(12F).setRadius2(1f).setHeight(height * 0.3F).setBlock(leaves);
|
||||
canopy = new SDFDisplacement().setFunction((vec) -> { return MHelper.randRange(-3F, 3F, random); }).setSource(canopy);
|
||||
canopy.addPostProcess(leavesPost1).addPostProcess(leavesPost2).fillRecursiveIgnore(world, pos.add(0, height * 0.75, 0), ignore);
|
||||
|
||||
canopy = new SDFDisplacement().setFunction((vec) -> {
|
||||
return MHelper.randRange(-3F, 3F, random);
|
||||
}).setSource(canopy);
|
||||
canopy.addPostProcess(leavesPost1).addPostProcess(leavesPost2).fillRecursiveIgnore(world,
|
||||
pos.offset(0, height * 0.75, 0), ignore);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
static {
|
||||
BRANCH = Lists.newArrayList(new Vector3f(0, 0, 0),
|
||||
new Vector3f(0.25F, 0.1F, 0),
|
||||
new Vector3f(0.40F, 0.2F, 0),
|
||||
new Vector3f(0.50F, 0.4F, 0),
|
||||
new Vector3f(0.55F, 0.6F, 0));
|
||||
BRANCH = Lists.newArrayList(new Vector3f(0, 0, 0), new Vector3f(0.25F, 0.1F, 0), new Vector3f(0.40F, 0.2F, 0),
|
||||
new Vector3f(0.50F, 0.4F, 0), new Vector3f(0.55F, 0.6F, 0));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,13 +6,13 @@ import java.util.function.Function;
|
|||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.Material;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
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.util.math.Box;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.StructureWorldAccess;
|
||||
import net.minecraft.world.gen.chunk.ChunkGenerator;
|
||||
import net.minecraft.world.gen.feature.DefaultFeatureConfig;
|
||||
|
@ -34,30 +34,35 @@ public class OldBulbisTreeFeature extends DefaultFeature {
|
|||
private static final List<Vector3f> ROOT;
|
||||
private static final List<Vector3f> LEAF;
|
||||
private static final List<Vector3f> SIDE;
|
||||
|
||||
|
||||
@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;
|
||||
if (!world.getBlockState(pos.down(4)).getBlock().isIn(EndTags.GEN_TERRAIN)) 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;
|
||||
if (!world.getBlockState(pos.down(4)).getBlock().isIn(EndTags.GEN_TERRAIN))
|
||||
return false;
|
||||
|
||||
BlockState stem = Integrations.BYG.getDefaultState("bulbis_stem");
|
||||
BlockState wood = Integrations.BYG.getDefaultState("bulbis_wood");
|
||||
BlockState cap = Integrations.BYG.getDefaultState(random.nextBoolean() ? "bulbis_shell" : "purple_bulbis_shell");
|
||||
BlockState cap = Integrations.BYG
|
||||
.getDefaultState(random.nextBoolean() ? "bulbis_shell" : "purple_bulbis_shell");
|
||||
BlockState glow = Integrations.BYG.getDefaultState("purple_shroomlight");
|
||||
|
||||
|
||||
Function<BlockState, Boolean> replacement = (state) -> {
|
||||
if (state.equals(stem) || state.equals(wood) || state.isIn(EndTags.END_GROUND) || state.getMaterial().equals(Material.PLANT)) {
|
||||
if (state.equals(stem) || state.equals(wood) || state.isIn(EndTags.END_GROUND)
|
||||
|| state.getMaterial().equals(Material.PLANT)) {
|
||||
return true;
|
||||
}
|
||||
return state.getMaterial().isReplaceable();
|
||||
};
|
||||
|
||||
|
||||
float size = MHelper.randRange(10, 20, random);
|
||||
float addSize = MHelper.randRange(1, 1.7F, random);
|
||||
float addRad = addSize * 0.5F + 0.5F;
|
||||
int count = (int) (size * 0.15F);
|
||||
size *= addSize;
|
||||
float var = MHelper.PI2 / (float) (count * 3);
|
||||
float var = MHelper.PI2 / (float) (count * 3);
|
||||
float start = MHelper.randRange(0, MHelper.PI2, random);
|
||||
SDF sdf = null;
|
||||
int x1 = ((pos.getX() >> 4) << 4) - 16;
|
||||
|
@ -70,53 +75,56 @@ public class OldBulbisTreeFeature extends DefaultFeature {
|
|||
SplineHelper.scale(spline, sizeXZ, sizeXZ * 1.5F + MHelper.randRange(0, size * 0.5F, random), sizeXZ);
|
||||
SplineHelper.offset(spline, new Vector3f(size * random.nextFloat() * 0.3F, 0, 0));
|
||||
SplineHelper.rotateSpline(spline, angle);
|
||||
SplineHelper.offsetParts(spline, random, 1F, 0, 1F);//1.3F 0.8F
|
||||
SplineHelper.offsetParts(spline, random, 1F, 0, 1F);// 1.3F 0.8F
|
||||
SDF branch = SplineHelper.buildSDF(spline, 2.3F * addRad, 1.3F * addRad, (bpos) -> {
|
||||
return stem;
|
||||
});
|
||||
|
||||
Vector3f vec = spline.get(spline.size() - 1);
|
||||
float radius = (size + MHelper.randRange(0, size * 0.5F, random)) * 0.35F;
|
||||
bigSphere(world, pos.add(vec.getX(), vec.getY(), vec.getZ()), radius, cap, glow, wood, replacement, random);
|
||||
bigSphere(world, pos.offset(vec.getX(), vec.getY(), vec.getZ()), radius, cap, glow, wood, replacement,
|
||||
random);
|
||||
vec = SplineHelper.getPos(spline, 0.3F);
|
||||
makeRoots(world, pos.add(vec.getX(), vec.getY(), vec.getZ()), size * 0.4F + 5, random, wood, replacement);
|
||||
makeRoots(world, pos.offset(vec.getX(), vec.getY(), vec.getZ()), size * 0.4F + 5, random, wood,
|
||||
replacement);
|
||||
|
||||
sdf = (sdf == null) ? branch : new SDFUnion().setSourceA(sdf).setSourceB(branch);
|
||||
}
|
||||
|
||||
|
||||
sdf.setReplaceFunction(replacement).addPostProcess((info) -> {
|
||||
if (info.getState().equals(stem) && (!info.getStateUp().equals(stem) || !info.getStateDown().equals(stem))) {
|
||||
if (info.getState().equals(stem)
|
||||
&& (!info.getStateUp().equals(stem) || !info.getStateDown().equals(stem))) {
|
||||
return wood;
|
||||
}
|
||||
return info.getState();
|
||||
}).fillArea(world, pos, limits);
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void bigSphere(StructureWorldAccess world, BlockPos pos, float radius, BlockState cap, BlockState glow, BlockState wood, Function<BlockState, Boolean> replacement, Random random) {
|
||||
|
||||
private void bigSphere(StructureWorldAccess world, BlockPos pos, float radius, BlockState cap, BlockState glow,
|
||||
BlockState wood, Function<BlockState, Boolean> replacement, Random random) {
|
||||
OpenSimplexNoise noise = new OpenSimplexNoise(random.nextLong());
|
||||
SDF sphere = new SDFSphere().setRadius(radius).setBlock(cap);
|
||||
|
||||
|
||||
SDF sphereInner = new SDFSphere().setRadius(radius * 0.53F).setBlock(Blocks.AIR);
|
||||
sphereInner = new SDFDisplacement().setFunction((vec) -> {
|
||||
return (float) noise.eval(vec.getX() * 0.1, vec.getY() * 0.1, vec.getZ() * 0.1);
|
||||
}).setSource(sphereInner);
|
||||
|
||||
|
||||
SDF sphereGlow = new SDFSphere().setRadius(radius * 0.6F).setBlock(glow);
|
||||
sphereGlow = new SDFDisplacement().setFunction((vec) -> {
|
||||
return (float) noise.eval(vec.getX() * 0.1, vec.getY() * 0.1, vec.getZ() * 0.1) * 2F;
|
||||
}).setSource(sphereGlow);
|
||||
sphereGlow = new SDFSubtraction().setSourceA(sphereGlow).setSourceB(sphereInner);
|
||||
|
||||
|
||||
sphere = new SDFSubtraction().setSourceA(sphere).setSourceB(sphereGlow);
|
||||
sphere = new SDFSubtraction().setSourceA(sphere).setSourceB(sphereInner);
|
||||
|
||||
|
||||
float offsetY = radius * 1.7F;
|
||||
sphere = new SDFUnion().setSourceA(sphere).setSourceB(sphereGlow);
|
||||
sphere = new SDFTranslate().setTranslate(0, offsetY, 0).setSource(sphere);
|
||||
|
||||
|
||||
int leafCount = (int) (radius * 0.5F) + 2;
|
||||
for (int i = 0; i < 4; i++) {
|
||||
float angle = (float) i / 4 * MHelper.PI2;
|
||||
|
@ -124,72 +132,54 @@ public class OldBulbisTreeFeature extends DefaultFeature {
|
|||
SplineHelper.rotateSpline(spline, angle);
|
||||
SplineHelper.scale(spline, radius * 1.4F);
|
||||
SplineHelper.fillSplineForce(spline, world, wood, pos, replacement);
|
||||
|
||||
|
||||
for (int j = 0; j < leafCount; j++) {
|
||||
float delta = ((float) j / (float) (leafCount - 1));
|
||||
float scale = (float) Math.sin(delta * Math.PI) * 0.8F + 0.2F;
|
||||
float index = MathHelper.lerp(delta, 1F, 3.9F);
|
||||
float index = Mth.lerp(delta, 1F, 3.9F);
|
||||
Vector3f point = SplineHelper.getPos(spline, index);
|
||||
|
||||
|
||||
List<Vector3f> side = SplineHelper.copySpline(SIDE);
|
||||
SplineHelper.rotateSpline(side, angle);
|
||||
SplineHelper.scale(side, scale * radius);
|
||||
BlockPos p = pos.add(point.getX() + 0.5F, point.getY() + 0.5F, point.getZ() + 0.5F);
|
||||
BlockPos p = pos.offset(point.getX() + 0.5F, point.getY() + 0.5F, point.getZ() + 0.5F);
|
||||
SplineHelper.fillSplineForce(side, world, wood, p, replacement);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
sphere.fillArea(world, pos, new Box(pos.up((int) offsetY)).expand(radius * 1.3F));
|
||||
}
|
||||
|
||||
private void makeRoots(StructureWorldAccess world, BlockPos pos, float radius, Random random, BlockState wood, Function<BlockState, Boolean> replacement) {
|
||||
|
||||
private void makeRoots(StructureWorldAccess world, BlockPos pos, float radius, Random random, BlockState wood,
|
||||
Function<BlockState, Boolean> replacement) {
|
||||
int count = (int) (radius * 1.5F);
|
||||
for (int i = 0; i < count; i++) {
|
||||
float angle = (float) i / (float) count * MHelper.PI2;
|
||||
float scale = radius * MHelper.randRange(0.85F, 1.15F, random);
|
||||
|
||||
|
||||
List<Vector3f> branch = SplineHelper.copySpline(ROOT);
|
||||
SplineHelper.rotateSpline(branch, angle);
|
||||
SplineHelper.scale(branch, scale);
|
||||
Vector3f last = branch.get(branch.size() - 1);
|
||||
if (world.getBlockState(pos.add(last.getX(), last.getY(), last.getZ())).isIn(EndTags.GEN_TERRAIN)) {
|
||||
if (world.getBlockState(pos.offset(last.getX(), last.getY(), last.getZ())).isIn(EndTags.GEN_TERRAIN)) {
|
||||
SplineHelper.fillSpline(branch, world, wood, pos, replacement);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static {
|
||||
SPLINE = Lists.newArrayList(
|
||||
new Vector3f(0.00F, 0.00F, 0.00F),
|
||||
new Vector3f(0.10F, 0.35F, 0.00F),
|
||||
new Vector3f(0.20F, 0.50F, 0.00F),
|
||||
new Vector3f(0.30F, 0.55F, 0.00F),
|
||||
new Vector3f(0.42F, 0.70F, 0.00F),
|
||||
new Vector3f(0.50F, 1.00F, 0.00F)
|
||||
);
|
||||
|
||||
ROOT = Lists.newArrayList(new Vector3f(0F, 1F, 0),
|
||||
new Vector3f(0.1F, 0.70F, 0),
|
||||
new Vector3f(0.3F, 0.30F, 0),
|
||||
new Vector3f(0.7F, 0.05F, 0),
|
||||
new Vector3f(0.8F, -0.20F, 0)
|
||||
);
|
||||
SPLINE = Lists.newArrayList(new Vector3f(0.00F, 0.00F, 0.00F), new Vector3f(0.10F, 0.35F, 0.00F),
|
||||
new Vector3f(0.20F, 0.50F, 0.00F), new Vector3f(0.30F, 0.55F, 0.00F), new Vector3f(0.42F, 0.70F, 0.00F),
|
||||
new Vector3f(0.50F, 1.00F, 0.00F));
|
||||
|
||||
ROOT = Lists.newArrayList(new Vector3f(0F, 1F, 0), new Vector3f(0.1F, 0.70F, 0), new Vector3f(0.3F, 0.30F, 0),
|
||||
new Vector3f(0.7F, 0.05F, 0), new Vector3f(0.8F, -0.20F, 0));
|
||||
SplineHelper.offset(ROOT, new Vector3f(0, -0.45F, 0));
|
||||
|
||||
LEAF = Lists.newArrayList(
|
||||
new Vector3f(0.00F, 0.0F, 0),
|
||||
new Vector3f(0.10F, 0.4F, 0),
|
||||
new Vector3f(0.40F, 0.8F, 0),
|
||||
new Vector3f(0.75F, 0.9F, 0),
|
||||
new Vector3f(1.00F, 0.8F, 0)
|
||||
);
|
||||
|
||||
SIDE = Lists.newArrayList(
|
||||
new Vector3f(0, -0.3F, -0.5F),
|
||||
new Vector3f(0, -0.1F, -0.3F),
|
||||
new Vector3f(0, 0.0F, 0.0F),
|
||||
new Vector3f(0, -0.1F, 0.3F),
|
||||
new Vector3f(0, -0.3F, 0.5F)
|
||||
);
|
||||
|
||||
LEAF = Lists.newArrayList(new Vector3f(0.00F, 0.0F, 0), new Vector3f(0.10F, 0.4F, 0),
|
||||
new Vector3f(0.40F, 0.8F, 0), new Vector3f(0.75F, 0.9F, 0), new Vector3f(1.00F, 0.8F, 0));
|
||||
|
||||
SIDE = Lists.newArrayList(new Vector3f(0, -0.3F, -0.5F), new Vector3f(0, -0.1F, -0.3F),
|
||||
new Vector3f(0, 0.0F, 0.0F), new Vector3f(0, -0.1F, 0.3F), new Vector3f(0, -0.3F, 0.5F));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue