Added support for Nether biomes

This commit is contained in:
Adubbz 2019-08-04 22:04:37 +10:00
parent 689c3d5f00
commit d7e36a8ac0
6 changed files with 249 additions and 3 deletions

View File

@ -1,6 +1,7 @@
package biomesoplenty.common.biome.nether;
import biomesoplenty.api.block.BOPBlocks;
import biomesoplenty.api.enums.BOPClimates;
import biomesoplenty.common.biome.NetherBiomeBOP;
import biomesoplenty.common.world.gen.feature.BOPBiomeFeatures;
import biomesoplenty.common.world.gen.feature.SplotchConfig;
@ -46,5 +47,7 @@ public class AshenInfernoBiome extends NetherBiomeBOP
this.addSpawn(EntityClassification.MONSTER, new SpawnListEntry(EntityType.ZOMBIE_PIGMAN, 80, 4, 4));
this.addSpawn(EntityClassification.MONSTER, new SpawnListEntry(EntityType.MAGMA_CUBE, 20, 4, 4));
this.addSpawn(EntityClassification.MONSTER, new SpawnListEntry(EntityType.ENDERMAN, 1, 4, 4));
this.addWeight(BOPClimates.HELL, 3);
}
}

View File

@ -0,0 +1,71 @@
/*******************************************************************************
* Copyright 2014-2019, the Biomes O' Plenty Team
*
* This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International Public License.
*
* To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/4.0/.
******************************************************************************/
package biomesoplenty.common.world;
import biomesoplenty.common.world.layer.*;
import biomesoplenty.common.world.layer.traits.LazyAreaLayerContextBOP;
import com.google.common.collect.ImmutableList;
import net.minecraft.util.registry.Registry;
import net.minecraft.world.WorldType;
import net.minecraft.world.biome.Biomes;
import net.minecraft.world.gen.IExtendedNoiseRandom;
import net.minecraft.world.gen.OverworldGenSettings;
import net.minecraft.world.gen.area.IArea;
import net.minecraft.world.gen.area.IAreaFactory;
import net.minecraft.world.gen.area.LazyArea;
import net.minecraft.world.gen.layer.*;
import java.util.function.LongFunction;
public class BOPNetherLayerUtil
{
public static <T extends IArea, C extends IExtendedNoiseRandom<T>> IAreaFactory<T> createBiomeFactory(IAreaFactory<T> landFactory, LongFunction<C> contextFactory)
{
IAreaFactory<T> biomeFactory = GenLayerNetherBiome.INSTANCE.apply(contextFactory.apply(200L));
// magnify the biome layer
biomeFactory = LayerUtil.repeat(1000L, ZoomLayer.NORMAL, biomeFactory, 2, contextFactory);
return biomeFactory;
}
public static <T extends IArea, C extends IExtendedNoiseRandom<T>> ImmutableList<IAreaFactory<T>> createAreaFactories(WorldType worldType, OverworldGenSettings settings, LongFunction<C> contextFactory)
{
int biomeSize = 3;
// The nether has no oceans, only land
IAreaFactory<T> landFactory = GenLayerLand.INSTANCE.apply(contextFactory.apply(1L));
// Allocate the biomes
IAreaFactory<T> biomesFactory = createBiomeFactory(landFactory, contextFactory);
// Zoom more based on the biome size
for (int i = 0; i < biomeSize; ++i)
{
biomesFactory = ZoomLayer.NORMAL.apply(contextFactory.apply((long)(1000 + i)), biomesFactory);
if (i == 0) biomesFactory = AddIslandLayer.INSTANCE.apply(contextFactory.apply(3L), biomesFactory);
if (i == 1 || biomeSize == 1) biomesFactory = GenLayerShoreBOP.INSTANCE.apply(contextFactory.apply(1000L), biomesFactory);
}
biomesFactory = SmoothLayer.INSTANCE.apply(contextFactory.apply(1000L), biomesFactory);
// Finish biomes with Voroni zoom
IAreaFactory<T> voroniZoomBiomesFactory = VoroniZoomLayer.INSTANCE.apply(contextFactory.apply(10L), biomesFactory);
return ImmutableList.of(biomesFactory, voroniZoomBiomesFactory, biomesFactory);
}
public static Layer[] createGenLayers(long seed, WorldType worldType, OverworldGenSettings settings)
{
ImmutableList<IAreaFactory<LazyArea>> factoryList = createAreaFactories(worldType, settings, (seedModifier) ->
{
return new LazyAreaLayerContextBOP(1, seed, seedModifier);
});
Layer biomesLayer = new Layer(factoryList.get(0));
Layer voroniZoomBiomesLayer = new Layer(factoryList.get(1));
Layer biomesLayer2 = new Layer(factoryList.get(2));
return new Layer[]{biomesLayer, voroniZoomBiomesLayer, biomesLayer2};
}
}

View File

@ -0,0 +1,116 @@
/*******************************************************************************
* Copyright 2014-2019, the Biomes O' Plenty Team
*
* This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International Public License.
*
* To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/4.0/.
******************************************************************************/
package biomesoplenty.common.world;
import com.google.common.collect.Sets;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.biome.Biomes;
import net.minecraft.world.biome.provider.BiomeProvider;
import net.minecraft.world.biome.provider.OverworldBiomeProviderSettings;
import net.minecraft.world.gen.OverworldGenSettings;
import net.minecraft.world.gen.feature.structure.Structure;
import net.minecraft.world.gen.layer.Layer;
import net.minecraft.world.gen.layer.LayerUtil;
import net.minecraft.world.storage.WorldInfo;
import javax.annotation.Nullable;
import java.util.Collections;
import java.util.List;
import java.util.Random;
import java.util.Set;
public class NetherBiomeProvider extends BiomeProvider
{
private final Layer genBiomes;
private final Layer biomeFactoryLayer;
public NetherBiomeProvider(OverworldBiomeProviderSettings settingsProvider)
{
this.topBlocksCache.add(Blocks.NETHERRACK.getDefaultState());
WorldInfo worldinfo = settingsProvider.getWorldInfo();
OverworldGenSettings overworldgensettings = settingsProvider.getGeneratorSettings();
Layer[] alayer = BOPNetherLayerUtil.createGenLayers(worldinfo.getSeed(), worldinfo.getGenerator(), overworldgensettings);
this.genBiomes = alayer[0];
this.biomeFactoryLayer = alayer[1];
}
@Override
public Biome getBiome(int x, int y) {
return this.biomeFactoryLayer.func_215738_a(x, y);
}
@Override
public Biome func_222366_b(int p_222366_1_, int p_222366_2_)
{
return this.genBiomes.func_215738_a(p_222366_1_, p_222366_2_);
}
@Override
public Biome[] getBiomes(int x, int z, int width, int length, boolean cacheFlag)
{
return this.biomeFactoryLayer.generateBiomes(x, z, width, length);
}
@Override
public Set<Biome> getBiomesInSquare(int centerX, int centerZ, int sideLength)
{
int i = centerX - sideLength >> 2;
int j = centerZ - sideLength >> 2;
int k = centerX + sideLength >> 2;
int l = centerZ + sideLength >> 2;
int i1 = k - i + 1;
int j1 = l - j + 1;
Set<Biome> set = Sets.newHashSet();
Collections.addAll(set, this.genBiomes.generateBiomes(i, j, i1, j1));
return set;
}
@Nullable
public BlockPos findBiomePosition(int x, int z, int range, List<Biome> biomes, Random random)
{
int i = x - range >> 2;
int j = z - range >> 2;
int k = x + range >> 2;
int l = z + range >> 2;
int i1 = k - i + 1;
int j1 = l - j + 1;
Biome[] abiome = this.genBiomes.generateBiomes(i, j, i1, j1);
BlockPos blockpos = null;
int k1 = 0;
for(int l1 = 0; l1 < i1 * j1; ++l1) {
int i2 = i + l1 % i1 << 2;
int j2 = j + l1 / i1 << 2;
if (biomes.contains(abiome[l1])) {
if (blockpos == null || random.nextInt(k1 + 1) == 0) {
blockpos = new BlockPos(i2, 0, j2);
}
++k1;
}
}
return blockpos;
}
@Override
public boolean hasStructure(Structure<?> structureIn)
{
return true;
}
@Override
public Set<BlockState> getSurfaceBlocks()
{
return this.topBlocksCache;
}
}

View File

@ -38,14 +38,19 @@ public class WorldTypeBOP extends WorldType
return new ChunkGeneratorOverworldBOP(world, new BOPBiomeProvider(biomeProviderSettings), overworldGenSettings);
}
/*else if (world.getDimension().getType() == DimensionType.THE_NETHER)
else if (world.getDimension().getType() == DimensionType.THE_NETHER)
{
NetherGenSettings nethergensettings = ChunkGeneratorType.CAVES.createSettings();
nethergensettings.setDefaultBlock(Blocks.NETHERRACK.getDefaultState());
nethergensettings.setDefaultFluid(Blocks.LAVA.getDefaultState());
return ChunkGeneratorType.CAVES.create(world, BiomeProviderType.FIXED.create(BiomeProviderType.FIXED.createSettings().setBiome(BOPBiomes.undergarden.get())), nethergensettings);
// The nether shares biome provider settings with the overworld
OverworldBiomeProviderSettings biomeProviderSettings = new OverworldBiomeProviderSettings();
biomeProviderSettings.setWorldInfo(world.getWorldInfo());
return ChunkGeneratorType.CAVES.create(world, new NetherBiomeProvider(biomeProviderSettings), nethergensettings);
}
else if (world.getDimension().getType() == DimensionType.THE_END)
/*else if (world.getDimension().getType() == DimensionType.THE_END)
{
BlockPos SPAWN = new BlockPos(100, 50, 0);

View File

@ -0,0 +1,20 @@
/*******************************************************************************
* Copyright 2014-2019, the Biomes O' Plenty Team
*
* This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International Public License.
*
* To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/4.0/.
******************************************************************************/
package biomesoplenty.common.world.layer;
import net.minecraft.world.gen.INoiseRandom;
import net.minecraft.world.gen.layer.traits.IAreaTransformer0;
public enum GenLayerLand implements IAreaTransformer0
{
INSTANCE;
public int apply(INoiseRandom random, int x, int z) {
return 1;
}
}

View File

@ -0,0 +1,31 @@
/*******************************************************************************
* Copyright 2014-2019, the Biomes O' Plenty Team
*
* This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International Public License.
*
* To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/4.0/.
******************************************************************************/
package biomesoplenty.common.world.layer;
import biomesoplenty.api.enums.BOPClimates;
import biomesoplenty.init.ModBiomes;
import net.minecraft.util.registry.Registry;
import net.minecraft.world.biome.Biomes;
import net.minecraft.world.gen.INoiseRandom;
import net.minecraft.world.gen.area.IArea;
import net.minecraft.world.gen.layer.traits.IAreaTransformer0;
import net.minecraft.world.gen.layer.traits.IAreaTransformer1;
import net.minecraft.world.gen.layer.traits.IAreaTransformer2;
import net.minecraft.world.gen.layer.traits.IDimOffset0Transformer;
import net.minecraftforge.common.BiomeManager;
public enum GenLayerNetherBiome implements IAreaTransformer0, IDimOffset0Transformer
{
INSTANCE;
@Override
public int apply(INoiseRandom context, int x, int z)
{
return Registry.BIOME.getId(BOPClimates.HELL.getRandomBiome(context, Biomes.NETHER));
}
}