Fixed structure generation. Closes #1531

This commit is contained in:
Adubbz 2020-02-16 20:46:46 +11:00
parent 974a1cc242
commit fa6dd5f3be
2 changed files with 28 additions and 2 deletions

View file

@ -7,6 +7,8 @@
******************************************************************************/
package biomesoplenty.api.enums;
import biomesoplenty.api.biome.BOPBiomes;
import biomesoplenty.init.ModBiomes;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Lists;
@ -193,6 +195,7 @@ public enum BOPClimates
set.addAll(climate.getIslandBiomes().stream().map(weightedBiomeEntry -> weightedBiomeEntry.biome).collect(Collectors.toSet()));
}
ModBiomes.subBiomes.values().forEach(weightedSubBiome -> set.add(weightedSubBiome.biome));
return ImmutableSet.copyOf(set);
}

View file

@ -29,13 +29,16 @@ import java.util.Random;
import java.util.Set;
import java.util.stream.Collectors;
public class BOPBiomeProvider extends BiomeProvider
public class BOPBiomeProvider extends OverworldBiomeProvider
{
private final Layer noiseBiomeLayer;
protected final Set<Biome> possibleBiomes;
public BOPBiomeProvider(OverworldBiomeProviderSettings settingsProvider)
{
super(BOPClimates.getOverworldBiomes());
super(settingsProvider);
this.possibleBiomes = Sets.newHashSet(super.possibleBiomes);
this.possibleBiomes.addAll(BOPClimates.getOverworldBiomes());
this.noiseBiomeLayer = BOPLayerUtil.createGenLayers(settingsProvider.getSeed(), settingsProvider.getGeneratorType(), settingsProvider.getGeneratorSettings())[0];
}
@ -44,4 +47,24 @@ public class BOPBiomeProvider extends BiomeProvider
{
return this.noiseBiomeLayer.get(x, z);
}
@Override
public boolean canGenerateStructure(Structure<?> structure)
{
return this.supportedStructures.computeIfAbsent(structure, (p_226839_1_) -> this.possibleBiomes.stream().anyMatch((biome) -> biome.isValidStart(p_226839_1_)));
}
@Override
public Set<BlockState> getSurfaceBlocks()
{
if (this.surfaceBlocks.isEmpty())
{
for(Biome biome : this.possibleBiomes)
{
this.surfaceBlocks.add(biome.getSurfaceBuilderConfig().getTopMaterial());
}
}
return this.surfaceBlocks;
}
}