Skip to content

Commit

Permalink
Vines, small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
paulevsGitch committed Apr 19, 2020
1 parent e3340bd commit bc1077f
Show file tree
Hide file tree
Showing 9 changed files with 241 additions and 52 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package paulevs.skyworld.generator;

import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

import com.google.common.collect.ImmutableSet;
Expand All @@ -11,11 +14,20 @@
import net.minecraft.world.biome.source.BiomeLayerSampler;
import net.minecraft.world.biome.source.BiomeSource;
import net.minecraft.world.biome.source.VanillaLayeredBiomeSourceConfig;
import net.minecraft.world.gen.GenerationStep.Feature;
import net.minecraft.world.gen.feature.BranchedTreeFeatureConfig;
import net.minecraft.world.gen.feature.ConfiguredFeature;
import net.minecraft.world.gen.feature.DecoratedFeature;
import net.minecraft.world.gen.feature.DecoratedFeatureConfig;
import net.minecraft.world.gen.feature.RandomFeatureConfig;
import net.minecraft.world.gen.feature.RandomFeatureEntry;
import paulevs.skyworld.structures.features.FoliagePair;;

public class SkyWorldBiomeSource extends BiomeSource
{
private final BiomeLayerSampler biomeSampler;
private static final Set<Biome> BIOMES;
private static final Map<Biome, FoliagePair[]> FOLIAGE;

public SkyWorldBiomeSource(VanillaLayeredBiomeSourceConfig config)
{
Expand All @@ -31,12 +43,34 @@ public Biome getBiomeForNoiseGen(int biomeX, int biomeY, int biomeZ)

static
{
FOLIAGE = new HashMap<Biome, FoliagePair[]>();
Set<Biome> biomes = new HashSet<Biome>();
for (Biome biome: Registry.BIOME)
if (!biome.hasParent() && isValidCategory(biome.getCategory()) && biome.getDepth() > -0.3)
{
System.out.println(biome);
biomes.add(biome);
Set<FoliagePair> biomeFlora = new HashSet<FoliagePair>();
List<ConfiguredFeature<?,?>> vegetation = biome.getFeaturesForStep(Feature.VEGETAL_DECORATION);
for (ConfiguredFeature<?,?> feature: vegetation)
{
if (feature.feature instanceof DecoratedFeature)
{
DecoratedFeatureConfig dConfig = (DecoratedFeatureConfig) feature.config;
if (dConfig.feature.config instanceof RandomFeatureConfig)
{
RandomFeatureConfig rfConfig = (RandomFeatureConfig) dConfig.feature.config;
for (RandomFeatureEntry<?> rFeature: rfConfig.features)
{
if (rFeature.feature.config instanceof BranchedTreeFeatureConfig)
{
BranchedTreeFeatureConfig config = (BranchedTreeFeatureConfig) rFeature.feature.config;
biomeFlora.add(new FoliagePair(config.trunkProvider, config.leavesProvider));
}
}
}
}
}
FOLIAGE.put(biome, biomeFlora.toArray(new FoliagePair[] {}));
}
BIOMES = ImmutableSet.copyOf(biomes);
}
Expand All @@ -49,4 +83,9 @@ private static boolean isValidCategory(Category category)
category != Category.NETHER &&
category != Category.THEEND;
}

public static FoliagePair[] getFoliage(Biome biome)
{
return FOLIAGE.get(biome);
}
}
8 changes: 6 additions & 2 deletions src/main/java/paulevs/skyworld/mixin/WorldRenderMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import net.minecraft.client.world.ClientWorld;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3d;
import paulevs.skyworld.SkyWorldType;

@Mixin(WorldRenderer.class)
public class WorldRenderMixin
Expand All @@ -25,8 +26,11 @@ public class WorldRenderMixin
@Inject(method = "renderClouds(Lnet/minecraft/client/render/BufferBuilder;DDDLnet/minecraft/util/math/Vec3d;)V", at = @At("RETURN"))
private void clouds(BufferBuilder builder, double x, double y, double z, Vec3d color, CallbackInfo info)
{
renderCloudsBuf(builder, x, y - 16, z, color, 5, 7);
renderCloudsBuf(builder, x, y + 16, z, color, -6, -4);
if (world.getGeneratorType() == SkyWorldType.SKY_WORLD)
{
renderCloudsBuf(builder, x, y - 16, z, color, 5, 7);
renderCloudsBuf(builder, x, y + 16, z, color, -6, -4);
}
}

private void renderCloudsBuf(BufferBuilder builder, double x, double y, double z, Vec3d color, int offsetX, int offsetY)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.util.Random;

import net.minecraft.block.LeavesBlock;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IWorld;
import net.minecraft.world.gen.stateprovider.BlockStateProvider;
Expand Down Expand Up @@ -30,6 +31,11 @@ public void setTrunk(IWorld world, BlockPos pos, Random random)
world.setBlockState(pos, trunk.getBlockState(random, pos), 0);
}

public void setLeavesNoDecay(IWorld world, BlockPos pos, Random random)
{
world.setBlockState(pos, leaves.getBlockState(random, pos).with(LeavesBlock.PERSISTENT, true), 0);
}

@Override
public boolean equals(Object obj)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,6 @@ else if (isAir(world, B_POS.up(h)))
}
}
generateOres(box, world, random, radius);
generateBushes(box, world, random);
generateBushes(box, world, random, radius);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,6 @@ else if (isAir(world, B_POS.up(h)))
}
}
generateOres(box, world, random, radius);
generateBushes(box, world, random);
generateBushes(box, world, random, radius);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,6 @@ else if (isAir(world, B_POS.up(h)))
}
}
generateOres(box, world, random, radius);
generateBushes(box, world, random);
generateBushes(box, world, random, radius);
}
}
Loading

0 comments on commit bc1077f

Please sign in to comment.