Start migration

This commit is contained in:
Aleksey 2021-04-08 21:55:07 +03:00
parent 6630ce0cab
commit 47ed597358
491 changed files with 12045 additions and 11953 deletions

View file

@ -1,6 +1,6 @@
package ru.betterend.integration.byg;
import net.minecraft.block.Block;
import net.minecraft.world.level.block.Block;
import ru.betterend.blocks.basis.EndWallPlantBlock;
import ru.betterend.blocks.basis.VineBlock;
import ru.betterend.registry.EndBlocks;
@ -8,8 +8,9 @@ import ru.betterend.registry.EndBlocks;
public class BYGBlocks {
public static final Block IVIS_MOSS = EndBlocks.registerBlock("ivis_moss", new EndWallPlantBlock());
public static final Block NIGHTSHADE_MOSS = EndBlocks.registerBlock("nightshade_moss", new EndWallPlantBlock());
public static final Block IVIS_VINE = EndBlocks.registerBlock("ivis_vine", new VineBlock());
public static void register() {}
public static void register() {
}
}

View file

@ -3,7 +3,7 @@ package ru.betterend.integration.byg;
import java.util.List;
import java.util.stream.Collectors;
import net.minecraft.util.Identifier;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.collection.WeightedList;
import net.minecraft.util.registry.BuiltinRegistries;
import net.minecraft.world.biome.Biome;
@ -32,31 +32,31 @@ public class BYGIntegration extends ModIntegration {
@Override
public void addBiomes() {
BYGBiomes.addBiomes();
Class<?> biomeClass = this.getClass("corgiaoc.byg.common.world.biome.BYGEndBiome");
List<Object> biomes = this.getStaticFieldValue(biomeClass, "BYG_END_BIOMES");
if (biomes != null && biomeClass != null) {
biomes.forEach((obj) -> {
Biome biome = this.getAndExecuteRuntime(biomeClass, obj, "getBiome");
if (biome != null) {
Identifier biomeID = BuiltinRegistries.BIOME.getId(biome);
ResourceLocation biomeID = BuiltinRegistries.BIOME.getId(biome);
EndBiome endBiome = EndBiomes.getBiome(biomeID);
Biome edge = this.getAndExecuteRuntime(biomeClass, obj, "getEdge");
if (edge != null) {
Identifier edgeID = BuiltinRegistries.BIOME.getId(edge);
ResourceLocation edgeID = BuiltinRegistries.BIOME.getId(edge);
EndBiomes.LAND_BIOMES.removeMutableBiome(edgeID);
EndBiomes.VOID_BIOMES.removeMutableBiome(edgeID);
EndBiome edgeBiome = EndBiomes.getBiome(edgeID);
endBiome.setEdge(edgeBiome);
}
else {
} else {
Boolean isVoid = this.getAndExecuteRuntime(biomeClass, obj, "isVoid");
if (isVoid != null && isVoid.booleanValue()) {
EndBiomes.LAND_BIOMES.removeMutableBiome(biomeID);
EndBiomes.VOID_BIOMES.addBiomeMutable(endBiome);
}
WeightedList<Identifier> subBiomes = this.getAndExecuteRuntime(biomeClass, obj, "getHills");
WeightedList<ResourceLocation> subBiomes = this.getAndExecuteRuntime(biomeClass, obj,
"getHills");
if (subBiomes != null) {
subBiomes.stream().collect(Collectors.toList()).forEach((id) -> {
EndBiome subBiome = EndBiomes.getBiome(id);

View file

@ -2,7 +2,7 @@ package ru.betterend.integration.byg.biomes;
import java.util.List;
import net.minecraft.entity.SpawnGroup;
import net.minecraft.world.entity.SpawnGroup;
import net.minecraft.sound.SoundEvent;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.biome.BiomeEffects;
@ -17,15 +17,15 @@ public class EterialGrove extends EndBiome {
public EterialGrove() {
super(makeDef());
}
private static BiomeDefinition makeDef() {
Biome biome = Integrations.BYG.getBiome("ethereal_islands");
BiomeEffects effects = biome.getEffects();
BiomeDefinition def = new BiomeDefinition("eterial_grove")
.setSurface(biome.getGenerationSettings().getSurfaceBuilder().get())
.addFeature(BYGFeatures.BIG_ETHER_TREE);
if (BetterEnd.isClient()) {
SoundEvent loop = effects.getLoopSound().get();
SoundEvent music = effects.getMusic().get().getSound();
@ -33,14 +33,14 @@ public class EterialGrove extends EndBiome {
SoundEvent mood = effects.getMoodSound().get().getSound();
def.setLoop(loop).setMusic(music).setAdditions(additions).setMood(mood);
}
for (SpawnGroup group: SpawnGroup.values()) {
for (SpawnGroup group : SpawnGroup.values()) {
List<SpawnEntry> list = biome.getSpawnSettings().getSpawnEntry(group);
list.forEach((entry) -> {
def.addMobSpawn(entry);
});
}
return def;
}
}

View file

@ -2,8 +2,8 @@ package ru.betterend.integration.byg.biomes;
import java.util.List;
import net.minecraft.entity.SpawnGroup;
import net.minecraft.particle.ParticleTypes;
import net.minecraft.world.entity.SpawnGroup;
import net.minecraft.core.particles.ParticleTypes;
import net.minecraft.sound.SoundEvent;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.biome.BiomeEffects;
@ -20,25 +20,19 @@ public class NightshadeRedwoods extends EndBiome {
public NightshadeRedwoods() {
super(makeDef());
}
private static BiomeDefinition makeDef() {
Biome biome = Integrations.BYG.getBiome("nightshade_forest");
BiomeEffects effects = biome.getEffects();
BiomeDefinition def = new BiomeDefinition("nightshade_redwoods")
.setFogColor(140, 108, 47)
.setFogDensity(1.5F)
.setWaterAndFogColor(55, 70, 186)
.setFoliageColor(122, 17, 155)
BiomeDefinition def = new BiomeDefinition("nightshade_redwoods").setFogColor(140, 108, 47).setFogDensity(1.5F)
.setWaterAndFogColor(55, 70, 186).setFoliageColor(122, 17, 155)
.setParticles(ParticleTypes.REVERSE_PORTAL, 0.002F)
.setSurface(biome.getGenerationSettings().getSurfaceBuilder().get())
.setGrassColor(48, 13, 89)
.setPlantsColor(200, 125, 9)
.addFeature(EndFeatures.END_LAKE_RARE)
.addFeature(BYGFeatures.NIGHTSHADE_REDWOOD_TREE)
.addFeature(BYGFeatures.NIGHTSHADE_MOSS_WOOD)
.setSurface(biome.getGenerationSettings().getSurfaceBuilder().get()).setGrassColor(48, 13, 89)
.setPlantsColor(200, 125, 9).addFeature(EndFeatures.END_LAKE_RARE)
.addFeature(BYGFeatures.NIGHTSHADE_REDWOOD_TREE).addFeature(BYGFeatures.NIGHTSHADE_MOSS_WOOD)
.addFeature(BYGFeatures.NIGHTSHADE_MOSS);
if (BetterEnd.isClient()) {
SoundEvent loop = effects.getLoopSound().get();
SoundEvent music = effects.getMusic().get().getSound();
@ -51,14 +45,14 @@ public class NightshadeRedwoods extends EndBiome {
def.addFeature(Feature.VEGETAL_DECORATION, feature.get());
});
});
for (SpawnGroup group: SpawnGroup.values()) {
for (SpawnGroup group : SpawnGroup.values()) {
List<SpawnEntry> list = biome.getSpawnSettings().getSpawnEntry(group);
list.forEach((entry) -> {
def.addMobSpawn(entry);
});
}
return def;
}
}

View file

@ -3,13 +3,13 @@ package ru.betterend.integration.byg.biomes;
import java.util.List;
import java.util.function.Supplier;
import net.minecraft.block.Block;
import net.minecraft.entity.SpawnGroup;
import net.minecraft.particle.ParticleTypes;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.entity.SpawnGroup;
import net.minecraft.core.particles.ParticleTypes;
import net.minecraft.sound.SoundEvent;
import net.minecraft.util.Identifier;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.registry.BuiltinRegistries;
import net.minecraft.util.registry.Registry;
import net.minecraft.core.Registry;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.biome.BiomeEffects;
import net.minecraft.world.biome.SpawnSettings.SpawnEntry;
@ -27,23 +27,18 @@ public class OldBulbisGardens extends EndBiome {
public OldBulbisGardens() {
super(makeDef());
}
private static BiomeDefinition makeDef() {
Biome biome = Integrations.BYG.getBiome("bulbis_gardens");
BiomeEffects effects = biome.getEffects();
Block ivis = Integrations.BYG.getBlock("ivis_phylium");
Block origin = biome.getGenerationSettings().getSurfaceConfig().getTopMaterial().getBlock();
BiomeDefinition def = new BiomeDefinition("old_bulbis_gardens")
.setFogColor(215, 132, 207)
.setFogDensity(1.8F)
.setWaterAndFogColor(40, 0, 56)
.setFoliageColor(122, 17, 155)
.setParticles(ParticleTypes.REVERSE_PORTAL, 0.002F)
.setSurface(ivis, origin)
.addFeature(EndFeatures.END_LAKE_RARE)
.addFeature(BYGFeatures.OLD_BULBIS_TREE);
BiomeDefinition def = new BiomeDefinition("old_bulbis_gardens").setFogColor(215, 132, 207).setFogDensity(1.8F)
.setWaterAndFogColor(40, 0, 56).setFoliageColor(122, 17, 155)
.setParticles(ParticleTypes.REVERSE_PORTAL, 0.002F).setSurface(ivis, origin)
.addFeature(EndFeatures.END_LAKE_RARE).addFeature(BYGFeatures.OLD_BULBIS_TREE);
if (BetterEnd.isClient()) {
SoundEvent loop = effects.getLoopSound().get();
SoundEvent music = effects.getMusic().get().getSound();
@ -51,25 +46,27 @@ public class OldBulbisGardens extends EndBiome {
SoundEvent mood = effects.getMoodSound().get().getSound();
def.setLoop(loop).setMusic(music).setAdditions(additions).setMood(mood);
}
for (SpawnGroup group: SpawnGroup.values()) {
for (SpawnGroup group : SpawnGroup.values()) {
List<SpawnEntry> list = biome.getSpawnSettings().getSpawnEntry(group);
list.forEach((entry) -> {
def.addMobSpawn(entry);
});
}
List<List<Supplier<ConfiguredFeature<?, ?>>>> features = biome.getGenerationSettings().getFeatures();
List<Supplier<ConfiguredFeature<?, ?>>> vegetal = features.get(Feature.VEGETAL_DECORATION.ordinal());
if (vegetal.size() > 2) {
Supplier<ConfiguredFeature<?, ?>> getter;
// Trees (first two features)
// I couldn't process them with conditions, so that's why they are hardcoded (paulevs)
// I couldn't process them with conditions, so that's why they are hardcoded
// (paulevs)
for (int i = 0; i < 2; i++) {
getter = vegetal.get(i);
ConfiguredFeature<?, ?> feature = getter.get();
Identifier id = BetterEnd.makeID("obg_feature_" + i);
feature = Registry.register(BuiltinRegistries.CONFIGURED_FEATURE, id, feature.decorate(ConfiguredFeatures.Decorators.SQUARE_HEIGHTMAP).repeatRandomly(1));
ResourceLocation id = BetterEnd.makeID("obg_feature_" + i);
feature = Registry.register(BuiltinRegistries.CONFIGURED_FEATURE, id,
feature.decorate(ConfiguredFeatures.Decorators.SQUARE_HEIGHTMAP).repeatRandomly(1));
def.addFeature(Feature.VEGETAL_DECORATION, feature);
}
// Grasses and other features
@ -79,13 +76,11 @@ public class OldBulbisGardens extends EndBiome {
def.addFeature(Feature.VEGETAL_DECORATION, feature);
}
}
def.addFeature(EndFeatures.PURPLE_POLYPORE)
.addFeature(BYGFeatures.IVIS_MOSS_WOOD)
.addFeature(BYGFeatures.IVIS_MOSS)
.addFeature(BYGFeatures.IVIS_VINE)
.addFeature(BYGFeatures.IVIS_SPROUT);
def.addFeature(EndFeatures.PURPLE_POLYPORE).addFeature(BYGFeatures.IVIS_MOSS_WOOD)
.addFeature(BYGFeatures.IVIS_MOSS).addFeature(BYGFeatures.IVIS_VINE)
.addFeature(BYGFeatures.IVIS_SPROUT);
return def;
}
}

View file

@ -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) {
//
// }
}

View file

@ -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));
}
}

View file

@ -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));
}
}

View file

@ -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));
}
}