Redwood tree start angle & city density option
This commit is contained in:
parent
7aa441171c
commit
b4ca488e66
4 changed files with 58 additions and 3 deletions
|
@ -69,6 +69,7 @@ public class NightshadeRedwoodTreeFeature extends DefaultFeature {
|
|||
float start = trunk.size() / 3F;
|
||||
float delta = trunk.size() * 0.6F;
|
||||
float max = height - 7;
|
||||
float startAngle = random.nextFloat() * MHelper.PI2;
|
||||
for (int i = 0; i < count; i++) {
|
||||
float scale = (float) (count - i) / count * 15;
|
||||
Vector3f offset = SplineHelper.getPos(trunk, (float) i / count * delta + start);
|
||||
|
@ -76,7 +77,7 @@ public class NightshadeRedwoodTreeFeature extends DefaultFeature {
|
|||
break;
|
||||
}
|
||||
List<Vector3f> branch = SplineHelper.copySpline(BRANCH);
|
||||
SplineHelper.rotateSpline(branch, i * 1.3F);
|
||||
SplineHelper.rotateSpline(branch, i * 1.3F + startAngle);
|
||||
SplineHelper.scale(branch, scale);
|
||||
SplineHelper.offsetParts(branch, random, 0.3F, 0.3F, 0.3F);
|
||||
SplineHelper.offset(branch, offset);
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
package ru.betterend.mixin.common;
|
||||
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
import net.minecraft.util.math.ChunkPos;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraft.world.biome.source.BiomeSource;
|
||||
import net.minecraft.world.gen.ChunkRandom;
|
||||
import net.minecraft.world.gen.chunk.ChunkGenerator;
|
||||
import net.minecraft.world.gen.feature.DefaultFeatureConfig;
|
||||
import net.minecraft.world.gen.feature.EndCityFeature;
|
||||
import ru.betterend.world.generator.GeneratorOptions;
|
||||
|
||||
@Mixin(EndCityFeature.class)
|
||||
public class EndCityFeatureMixin {
|
||||
@Inject(method = "shouldStartAt", at = @At("HEAD"), cancellable = true)
|
||||
private void be_shouldStartAt(ChunkGenerator chunkGenerator, BiomeSource biomeSource, long l, ChunkRandom chunkRandom, int i, int j, Biome biome, ChunkPos chunkPos, DefaultFeatureConfig defaultFeatureConfig, CallbackInfoReturnable<Boolean> info) {
|
||||
if (GeneratorOptions.useNewGenerator()) {
|
||||
int chance = GeneratorOptions.getEndCityFailChance();
|
||||
if (chance == 0) {
|
||||
info.setReturnValue(getGenerationHeight(i, j, chunkGenerator) >= 60);
|
||||
info.cancel();
|
||||
}
|
||||
else if (chunkRandom.nextInt(chance) == 0){
|
||||
info.setReturnValue(getGenerationHeight(i, j, chunkGenerator) >= 60);
|
||||
info.cancel();
|
||||
}
|
||||
else {
|
||||
info.setReturnValue(false);
|
||||
info.cancel();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Shadow
|
||||
private static int getGenerationHeight(int chunkX, int chunkZ, ChunkGenerator chunkGenerator) {
|
||||
return 0;
|
||||
}
|
||||
}
|
|
@ -14,6 +14,7 @@ public class GeneratorOptions {
|
|||
private static boolean newGenerator;
|
||||
private static boolean noRingVoid;
|
||||
private static boolean generateCentralIsland;
|
||||
private static int endCityFailChance;
|
||||
|
||||
public static void init() {
|
||||
biomeSizeLand = Configs.GENERATOR_CONFIG.getInt("biomeMap", "biomeSizeLand", 256);
|
||||
|
@ -27,6 +28,7 @@ public class GeneratorOptions {
|
|||
newGenerator = Configs.GENERATOR_CONFIG.getBoolean("customGenerator", "useNewGenerator", false);
|
||||
noRingVoid = Configs.GENERATOR_CONFIG.getBoolean("customGenerator", "noRingVoid", false);
|
||||
generateCentralIsland = Configs.GENERATOR_CONFIG.getBoolean("customGenerator", "generateCentralIsland", false);
|
||||
endCityFailChance = Configs.GENERATOR_CONFIG.getInt("customGenerator", "endCityFailChance", 5);
|
||||
}
|
||||
|
||||
public static int getBiomeSizeLand() {
|
||||
|
@ -72,4 +74,8 @@ public class GeneratorOptions {
|
|||
public static boolean hasCentralIsland() {
|
||||
return generateCentralIsland;
|
||||
}
|
||||
|
||||
public static int getEndCityFailChance() {
|
||||
return endCityFailChance;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -81,8 +81,13 @@ public class IslandLayer {
|
|||
private SDF getIsland(BlockPos pos) {
|
||||
SDF island = islands.get(pos);
|
||||
if (island == null) {
|
||||
if (pos.getX() == 0 && pos.getZ() == 0) {
|
||||
island = new SDFScale().setScale(1.3F).setSource(ISLAND);
|
||||
}
|
||||
else {
|
||||
RANDOM.setSeed(getSeed(pos.getX(), pos.getZ()));
|
||||
island = new SDFScale().setScale(RANDOM.nextFloat() + 0.5F).setSource(ISLAND);
|
||||
}
|
||||
islands.put(pos, island);
|
||||
}
|
||||
return island;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue