Umbrella Jungle prototype, removed numeric biome IDs
This commit is contained in:
parent
50fc0a7994
commit
57c6a0337b
4 changed files with 148 additions and 21 deletions
|
@ -0,0 +1,18 @@
|
|||
package ru.betterend.world.biome;
|
||||
|
||||
import ru.betterend.registry.EndBlocks;
|
||||
import ru.betterend.registry.EndFeatures;
|
||||
|
||||
public class BiomeUmbrellaJungle extends EndBiome {
|
||||
public BiomeUmbrellaJungle() {
|
||||
super(new BiomeDefinition("umbrella_jungle")
|
||||
.setFogColor(87, 223, 221)
|
||||
.setWaterAndFogColor(119, 198, 253)
|
||||
.setFoliageColor(27, 183, 194)
|
||||
.setFogDensity(2.3F)
|
||||
.setSurface(EndBlocks.END_MOSS)
|
||||
.addFeature(EndFeatures.UMBRELLA_TREE)
|
||||
.addFeature(EndFeatures.UMBRELLA_MOSS)
|
||||
.addFeature(EndFeatures.END_LAKE));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,125 @@
|
|||
package ru.betterend.world.features.trees;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.function.Function;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Material;
|
||||
import net.minecraft.client.util.math.Vector3f;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Box;
|
||||
import net.minecraft.world.StructureWorldAccess;
|
||||
import net.minecraft.world.gen.chunk.ChunkGenerator;
|
||||
import net.minecraft.world.gen.feature.DefaultFeatureConfig;
|
||||
import ru.betterend.registry.EndBlocks;
|
||||
import ru.betterend.registry.EndTags;
|
||||
import ru.betterend.util.MHelper;
|
||||
import ru.betterend.util.SplineHelper;
|
||||
import ru.betterend.util.sdf.PosInfo;
|
||||
import ru.betterend.util.sdf.SDF;
|
||||
import ru.betterend.util.sdf.operator.SDFUnion;
|
||||
import ru.betterend.world.features.DefaultFeature;
|
||||
|
||||
public class UmbrellaTreeFeature extends DefaultFeature {
|
||||
private static final Function<BlockState, Boolean> REPLACE;
|
||||
private static final Function<PosInfo, BlockState> POST;
|
||||
private static final List<Vector3f> SPLINE;
|
||||
private static final List<Vector3f> ROOT;
|
||||
|
||||
@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;
|
||||
|
||||
float size = MHelper.randRange(10, 20, random);
|
||||
int count = (int) (size * 0.15F);
|
||||
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;
|
||||
int z1 = ((pos.getZ() >> 4) << 4) - 16;
|
||||
Box limits = new Box(x1, pos.getY() - 5, z1, x1 + 47, pos.getY() + size * 2, z1 + 47);
|
||||
BlockState wood = EndBlocks.UMBRELLA_TREE.bark.getDefaultState();
|
||||
for (int i = 0; i < count; i++) {
|
||||
float angle = (float) i / (float) count * MHelper.PI2 + MHelper.randRange(0, var, random) + start;
|
||||
List<Vector3f> spline = SplineHelper.copySpline(SPLINE);
|
||||
float sizeXZ = (size + MHelper.randRange(0, size * 0.5F, random)) * 0.7F;
|
||||
SplineHelper.scale(spline, sizeXZ, sizeXZ * 1.5F + MHelper.randRange(0, size * 0.5F, random), sizeXZ);
|
||||
SplineHelper.offset(spline, new Vector3f((20 - size), 0, 0));
|
||||
SplineHelper.rotateSpline(spline, angle);
|
||||
SplineHelper.offsetParts(spline, random, 1F, 0, 1F);
|
||||
SDF branch = SplineHelper.buildSDF(spline, 2.3F, 1.3F, (bpos) -> {
|
||||
return wood;
|
||||
});
|
||||
|
||||
Vector3f vec = spline.get(spline.size() - 1);
|
||||
//float radius = (size + MHelper.randRange(0, size * 0.5F, random)) * 0.35F;
|
||||
vec = SplineHelper.getPos(spline, 0.3F);
|
||||
|
||||
makeRoots(world, pos.add(vec.getX(), vec.getY(), vec.getZ()), size * 0.4F + 5, random, wood);
|
||||
|
||||
sdf = (sdf == null) ? branch : new SDFUnion().setSourceA(sdf).setSourceB(branch);
|
||||
}
|
||||
|
||||
sdf.setReplaceFunction(REPLACE).setPostProcess(POST).fillArea(world, pos, limits);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void makeRoots(StructureWorldAccess world, BlockPos pos, float radius, Random random, BlockState wood) {
|
||||
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)) {
|
||||
SplineHelper.fillSpline(branch, world, wood, pos, REPLACE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
);
|
||||
SplineHelper.offset(ROOT, new Vector3f(0, -0.45F, 0));
|
||||
|
||||
REPLACE = (state) -> {
|
||||
if (state.isIn(EndTags.END_GROUND)) {
|
||||
return true;
|
||||
}
|
||||
if (state.getBlock() == EndBlocks.DRAGON_TREE_LEAVES) {
|
||||
return true;
|
||||
}
|
||||
if (state.getMaterial().equals(Material.PLANT)) {
|
||||
return true;
|
||||
}
|
||||
return state.getMaterial().isReplaceable();
|
||||
};
|
||||
|
||||
POST = (info) -> {
|
||||
if (EndBlocks.UMBRELLA_TREE.isTreeLog(info.getStateUp()) && EndBlocks.UMBRELLA_TREE.isTreeLog(info.getStateDown())) {
|
||||
return EndBlocks.UMBRELLA_TREE.log.getDefaultState();
|
||||
}
|
||||
return info.getState();
|
||||
};
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue