Merge remote-tracking branch 'origin/master'

This commit is contained in:
Aleksey 2021-01-13 17:03:57 +03:00
commit d105d88e00
4 changed files with 58 additions and 3 deletions

View file

@ -69,6 +69,7 @@ public class NightshadeRedwoodTreeFeature extends DefaultFeature {
float start = trunk.size() / 3F; float start = trunk.size() / 3F;
float delta = trunk.size() * 0.6F; float delta = trunk.size() * 0.6F;
float max = height - 7; float max = height - 7;
float startAngle = random.nextFloat() * MHelper.PI2;
for (int i = 0; i < count; i++) { for (int i = 0; i < count; i++) {
float scale = (float) (count - i) / count * 15; float scale = (float) (count - i) / count * 15;
Vector3f offset = SplineHelper.getPos(trunk, (float) i / count * delta + start); Vector3f offset = SplineHelper.getPos(trunk, (float) i / count * delta + start);
@ -76,7 +77,7 @@ public class NightshadeRedwoodTreeFeature extends DefaultFeature {
break; break;
} }
List<Vector3f> branch = SplineHelper.copySpline(BRANCH); List<Vector3f> branch = SplineHelper.copySpline(BRANCH);
SplineHelper.rotateSpline(branch, i * 1.3F); SplineHelper.rotateSpline(branch, i * 1.3F + startAngle);
SplineHelper.scale(branch, scale); SplineHelper.scale(branch, scale);
SplineHelper.offsetParts(branch, random, 0.3F, 0.3F, 0.3F); SplineHelper.offsetParts(branch, random, 0.3F, 0.3F, 0.3F);
SplineHelper.offset(branch, offset); SplineHelper.offset(branch, offset);

View file

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

View file

@ -14,6 +14,7 @@ public class GeneratorOptions {
private static boolean newGenerator; private static boolean newGenerator;
private static boolean noRingVoid; private static boolean noRingVoid;
private static boolean generateCentralIsland; private static boolean generateCentralIsland;
private static int endCityFailChance;
public static void init() { public static void init() {
biomeSizeLand = Configs.GENERATOR_CONFIG.getInt("biomeMap", "biomeSizeLand", 256); biomeSizeLand = Configs.GENERATOR_CONFIG.getInt("biomeMap", "biomeSizeLand", 256);
@ -27,6 +28,7 @@ public class GeneratorOptions {
newGenerator = Configs.GENERATOR_CONFIG.getBoolean("customGenerator", "useNewGenerator", false); newGenerator = Configs.GENERATOR_CONFIG.getBoolean("customGenerator", "useNewGenerator", false);
noRingVoid = Configs.GENERATOR_CONFIG.getBoolean("customGenerator", "noRingVoid", false); noRingVoid = Configs.GENERATOR_CONFIG.getBoolean("customGenerator", "noRingVoid", false);
generateCentralIsland = Configs.GENERATOR_CONFIG.getBoolean("customGenerator", "generateCentralIsland", false); generateCentralIsland = Configs.GENERATOR_CONFIG.getBoolean("customGenerator", "generateCentralIsland", false);
endCityFailChance = Configs.GENERATOR_CONFIG.getInt("customGenerator", "endCityFailChance", 5);
} }
public static int getBiomeSizeLand() { public static int getBiomeSizeLand() {
@ -72,4 +74,8 @@ public class GeneratorOptions {
public static boolean hasCentralIsland() { public static boolean hasCentralIsland() {
return generateCentralIsland; return generateCentralIsland;
} }
public static int getEndCityFailChance() {
return endCityFailChance;
}
} }

View file

@ -81,8 +81,13 @@ public class IslandLayer {
private SDF getIsland(BlockPos pos) { private SDF getIsland(BlockPos pos) {
SDF island = islands.get(pos); SDF island = islands.get(pos);
if (island == null) { if (island == null) {
RANDOM.setSeed(getSeed(pos.getX(), pos.getZ())); if (pos.getX() == 0 && pos.getZ() == 0) {
island = new SDFScale().setScale(RANDOM.nextFloat() + 0.5F).setSource(ISLAND); 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); islands.put(pos, island);
} }
return island; return island;