diff --git a/src/main/java/com/progwml6/natura/common/config/Config.java b/src/main/java/com/progwml6/natura/common/config/Config.java index 50a9a6f9..202801bc 100644 --- a/src/main/java/com/progwml6/natura/common/config/Config.java +++ b/src/main/java/com/progwml6/natura/common/config/Config.java @@ -6,7 +6,6 @@ import net.minecraftforge.common.config.Configuration; import net.minecraftforge.common.config.Property; -import net.minecraftforge.fml.common.Loader; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; import slimeknights.mantle.pulsar.config.ForgeCFG; @@ -46,12 +45,6 @@ public static boolean syncConfig() doRetrogen = configFile.get(RETROGEN, "Retroactive Generation", doRetrogen).getBoolean(doRetrogen); // Retrogen End - boolean BoP = false; - if (Loader.isModLoaded("BiomesOPlenty")) - { - BoP = true; - } - babyHeatscarMinimum = configFile.get(MOB_CHANGES, "Minimum Baby Heatscar Spiders on Spider Death", babyHeatscarMinimum).getInt(babyHeatscarMinimum); if (babyHeatscarMinimum < 0) { @@ -64,7 +57,6 @@ public static boolean syncConfig() babyHeatscarMaximum = 0; } - overrideNether = configFile.get(ENABLE_DISABLE, "Override Nether", !BoP).getBoolean(!BoP); canRespawnInNether = configFile.get(ENABLE_DISABLE, "Obelisks let players respawn in the Nether", canRespawnInNether).getBoolean(canRespawnInNether); // Trees Start @@ -204,6 +196,17 @@ public static boolean syncConfig() ashSpawnRange = configFile.get(WORLDGEN, "Ash Cloud Spawn Range", ashSpawnRange).getInt(ashSpawnRange); // Cloud End + // Mineable Start + generateTaintedSoil = configFile.get(ENABLE_DISABLE, "Generate Tained Soil", generateTaintedSoil).getBoolean(generateTaintedSoil); + generateHeatSand = configFile.get(ENABLE_DISABLE, "Generate Heat Sand", generateHeatSand).getBoolean(generateHeatSand); + + tainedSoilClusterCount = configFile.get(WORLDGEN, "Tainted Soil Cluster Count", tainedSoilClusterCount).getInt(tainedSoilClusterCount); + heatSandClusterCount = configFile.get(WORLDGEN, "Heat Sand Cluster Count", heatSandClusterCount).getInt(heatSandClusterCount); + + tainedSoilClusterSize = configFile.get(WORLDGEN, "Tainted Soil Cluster Size", tainedSoilClusterSize).getInt(tainedSoilClusterSize); + heatSandClusterSize = configFile.get(WORLDGEN, "Heat Sand Cluster Size", heatSandClusterSize).getInt(heatSandClusterSize); + // Mineable End + thornSpawnRarity = configFile.get(WORLDGEN, "Thornvines Spawn Rarity", thornSpawnRarity).getInt(thornSpawnRarity); enableHeatscarSpider = configFile.get(ENTITIES, "Enable Heatscar Spiders", enableHeatscarSpider).getBoolean(enableHeatscarSpider); @@ -213,11 +216,13 @@ public static boolean syncConfig() // save changes if any boolean changed = false; + if (configFile.hasChanged()) { configFile.save(); changed = true; } + return changed; } @@ -264,7 +269,6 @@ public static boolean syncConfig() public static int seaLevel = 64; public static int flatSeaLevel = 1; - public static boolean overrideNether = true; public static boolean canRespawnInNether = true; // Trees Start @@ -336,10 +340,22 @@ public static boolean syncConfig() public static int stingberrySpawnRange = 100; // Berries End - //Overworld + // Mineables Start + public static boolean generateTaintedSoil = true; + public static boolean generateHeatSand = true; + + public static int tainedSoilClusterCount = 4; + public static int heatSandClusterCount = 4; + + public static int tainedSoilClusterSize = 33; + public static int heatSandClusterSize = 33; + // Mineables End + + // Overworld Start public static boolean generateBarley = true; public static boolean generateCotton = true; public static boolean generateBluebells = true; + // Overworld End public static boolean generateGreenglowshroom = true; public static boolean generatePurpleglowshroom = true; diff --git a/src/main/java/com/progwml6/natura/world/NaturaWorld.java b/src/main/java/com/progwml6/natura/world/NaturaWorld.java index 2d557ad6..eb328784 100644 --- a/src/main/java/com/progwml6/natura/world/NaturaWorld.java +++ b/src/main/java/com/progwml6/natura/world/NaturaWorld.java @@ -7,19 +7,17 @@ import com.progwml6.natura.common.NaturaPulse; import com.progwml6.natura.common.config.Config; import com.progwml6.natura.library.Util; -import com.progwml6.natura.world.dimension.WorldProviderNetherite; import com.progwml6.natura.world.worldgen.CloudGenerator; import com.progwml6.natura.world.worldgen.CropGenerator; import com.progwml6.natura.world.worldgen.GlowshroomGenerator; import com.progwml6.natura.world.worldgen.NetherBerryBushesGenerator; +import com.progwml6.natura.world.worldgen.NetherMinableGenerator; import com.progwml6.natura.world.worldgen.NetherTreesGenerator; import com.progwml6.natura.world.worldgen.OverworldBerryBushesGenerator; import com.progwml6.natura.world.worldgen.OverworldTreesGenerator; import com.progwml6.natura.world.worldgen.VineGenerator; import com.progwml6.natura.world.worldgen.retrogen.TickHandlerWorldRetrogen; -import net.minecraft.world.DimensionType; -import net.minecraftforge.common.DimensionManager; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.fml.common.SidedProxy; import net.minecraftforge.fml.common.event.FMLInitializationEvent; @@ -74,11 +72,7 @@ public void postInit(FMLPostInitializationEvent event) GameRegistry.registerWorldGenerator(GlowshroomGenerator.INSTANCE, 0); GameRegistry.registerWorldGenerator(VineGenerator.INSTANCE, 0); - if (Config.overrideNether) - { - DimensionManager.unregisterDimension(-1); - DimensionManager.registerDimension(-1, DimensionType.register("Nether", "_nether", -1, WorldProviderNetherite.class, false)); - } + GameRegistry.registerWorldGenerator(NetherMinableGenerator.INSTANCE, 0); } MinecraftForge.EVENT_BUS.register(TickHandlerWorldRetrogen.INSTANCE); diff --git a/src/main/java/com/progwml6/natura/world/dimension/ChunkNetherite.java b/src/main/java/com/progwml6/natura/world/dimension/ChunkNetherite.java deleted file mode 100644 index 37c66248..00000000 --- a/src/main/java/com/progwml6/natura/world/dimension/ChunkNetherite.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.progwml6.natura.world.dimension; - -import net.minecraft.block.material.Material; -import net.minecraft.block.state.IBlockState; -import net.minecraft.world.World; -import net.minecraft.world.chunk.Chunk; -import net.minecraft.world.chunk.ChunkPrimer; -import net.minecraft.world.chunk.storage.ExtendedBlockStorage; - -public class ChunkNetherite extends Chunk -{ - public ChunkNetherite(World worldIn, ChunkPrimer primer, int x, int z) - { - super(worldIn, x, z); - boolean flag = !worldIn.provider.hasNoSky(); - ExtendedBlockStorage[] storageArrays = this.getBlockStorageArray(); - - for (int j = 0; j < 16; ++j) - { - for (int k = 0; k < 16; ++k) - { - for (int l = 0; l < 256; ++l) - { - IBlockState iblockstate = primer.getBlockState(j, l, k); - - if (iblockstate.getMaterial() != Material.AIR) - { - int i1 = l >> 4; - - if (storageArrays[i1] == NULL_BLOCK_STORAGE) - { - storageArrays[i1] = new ExtendedBlockStorage(i1 << 4, flag); - } - - storageArrays[i1].set(j, l & 15, k, iblockstate); - } - } - } - } - } -} diff --git a/src/main/java/com/progwml6/natura/world/dimension/ChunkProviderNetherite.java b/src/main/java/com/progwml6/natura/world/dimension/ChunkProviderNetherite.java deleted file mode 100644 index 28d33202..00000000 --- a/src/main/java/com/progwml6/natura/world/dimension/ChunkProviderNetherite.java +++ /dev/null @@ -1,547 +0,0 @@ -package com.progwml6.natura.world.dimension; - -import java.util.List; -import java.util.Random; - -import javax.annotation.Nullable; - -import com.progwml6.natura.nether.NaturaNether; - -import net.minecraft.block.BlockFalling; -import net.minecraft.block.material.Material; -import net.minecraft.block.state.IBlockState; -import net.minecraft.block.state.pattern.BlockMatcher; -import net.minecraft.entity.EnumCreatureType; -import net.minecraft.init.Blocks; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.ChunkPos; -import net.minecraft.util.math.MathHelper; -import net.minecraft.world.World; -import net.minecraft.world.biome.Biome; -import net.minecraft.world.chunk.Chunk; -import net.minecraft.world.chunk.ChunkPrimer; -import net.minecraft.world.chunk.IChunkGenerator; -import net.minecraft.world.gen.MapGenBase; -import net.minecraft.world.gen.MapGenCavesHell; -import net.minecraft.world.gen.NoiseGeneratorOctaves; -import net.minecraft.world.gen.feature.WorldGenBush; -import net.minecraft.world.gen.feature.WorldGenGlowStone1; -import net.minecraft.world.gen.feature.WorldGenGlowStone2; -import net.minecraft.world.gen.feature.WorldGenHellLava; -import net.minecraft.world.gen.feature.WorldGenMinable; -import net.minecraft.world.gen.feature.WorldGenerator; -import net.minecraft.world.gen.structure.MapGenNetherBridge; - -public class ChunkProviderNetherite implements IChunkGenerator -{ - protected static final IBlockState AIR = Blocks.AIR.getDefaultState(); - - protected static final IBlockState NETHERRACK = Blocks.NETHERRACK.getDefaultState(); - - protected static final IBlockState BEDROCK = Blocks.BEDROCK.getDefaultState(); - - protected static final IBlockState LAVA = Blocks.LAVA.getDefaultState(); - - protected static final IBlockState GRAVEL = Blocks.GRAVEL.getDefaultState(); - - protected static final IBlockState SOUL_SAND = Blocks.SOUL_SAND.getDefaultState(); - - protected static final IBlockState TAINTED_SOIL = NaturaNether.netherTaintedSoil.getDefaultState(); - - protected static final IBlockState HEAT_SAND = NaturaNether.netherHeatSand.getDefaultState(); - - private final World world; - - private final boolean generateStructures; - - private final Random rand; - - /** Holds the noise used to determine whether slowsand can be generated at a location */ - private double[] slowsandNoise = new double[256]; - - private double[] gravelNoise = new double[256]; - - private double[] depthBuffer = new double[256]; - - private double[] buffer; - - private NoiseGeneratorOctaves lperlinNoise1; - - private NoiseGeneratorOctaves lperlinNoise2; - - private NoiseGeneratorOctaves perlinNoise1; - - /** Determines whether slowsand or gravel can be generated at a location */ - private NoiseGeneratorOctaves slowsandGravelNoiseGen; - - /** Determines whether something other than nettherack can be generated at a location */ - private NoiseGeneratorOctaves netherrackExculsivityNoiseGen; - - public NoiseGeneratorOctaves scaleNoise; - - public NoiseGeneratorOctaves depthNoise; - - private final WorldGenNetheriteFire fireFeature = new WorldGenNetheriteFire(); - - private final WorldGenGlowStone1 lightGemGen = new WorldGenGlowStone1(); - - private final WorldGenGlowStone2 hellPortalGen = new WorldGenGlowStone2(); - - private final WorldGenerator quartzGen = new WorldGenMinable(Blocks.QUARTZ_ORE.getDefaultState(), 14, BlockMatcher.forBlock(Blocks.NETHERRACK)); - - private final WorldGenerator magmaGen = new WorldGenMinable(Blocks.MAGMA.getDefaultState(), 33, BlockMatcher.forBlock(Blocks.NETHERRACK)); - - private final WorldGenHellLava lavaTrapGen = new WorldGenHellLava(Blocks.FLOWING_LAVA, true); - - private final WorldGenHellLava hellSpringGen = new WorldGenHellLava(Blocks.FLOWING_LAVA, false); - - private final WorldGenBush brownMushroomFeature = new WorldGenBush(Blocks.BROWN_MUSHROOM); - - private final WorldGenBush redMushroomFeature = new WorldGenBush(Blocks.RED_MUSHROOM); - - private MapGenNetherBridge genNetherBridge = new MapGenNetherBridge(); - - private MapGenBase genNetherCaves = new MapGenCavesHell(); - - double[] pnr; - - double[] ar; - - double[] br; - - double[] noiseData4; - - double[] dr; - - public ChunkProviderNetherite(World worldIn, boolean p_i45637_2_, long seed) - { - this.world = worldIn; - this.generateStructures = p_i45637_2_; - this.rand = new Random(seed); - this.lperlinNoise1 = new NoiseGeneratorOctaves(this.rand, 16); - this.lperlinNoise2 = new NoiseGeneratorOctaves(this.rand, 16); - this.perlinNoise1 = new NoiseGeneratorOctaves(this.rand, 8); - this.slowsandGravelNoiseGen = new NoiseGeneratorOctaves(this.rand, 4); - this.netherrackExculsivityNoiseGen = new NoiseGeneratorOctaves(this.rand, 4); - this.scaleNoise = new NoiseGeneratorOctaves(this.rand, 10); - this.depthNoise = new NoiseGeneratorOctaves(this.rand, 16); - worldIn.setSeaLevel(63); - - net.minecraftforge.event.terraingen.InitNoiseGensEvent.ContextHell ctx = new net.minecraftforge.event.terraingen.InitNoiseGensEvent.ContextHell(lperlinNoise1, lperlinNoise2, perlinNoise1, slowsandGravelNoiseGen, netherrackExculsivityNoiseGen, scaleNoise, depthNoise); - ctx = net.minecraftforge.event.terraingen.TerrainGen.getModdedNoiseGenerators(worldIn, this.rand, ctx); - this.lperlinNoise1 = ctx.getLPerlin1(); - this.lperlinNoise2 = ctx.getLPerlin2(); - this.perlinNoise1 = ctx.getPerlin(); - this.slowsandGravelNoiseGen = ctx.getPerlin2(); - this.netherrackExculsivityNoiseGen = ctx.getPerlin3(); - this.scaleNoise = ctx.getScale(); - this.depthNoise = ctx.getDepth(); - this.genNetherBridge = (MapGenNetherBridge) net.minecraftforge.event.terraingen.TerrainGen.getModdedMapGen(genNetherBridge, net.minecraftforge.event.terraingen.InitMapGenEvent.EventType.NETHER_BRIDGE); - this.genNetherCaves = net.minecraftforge.event.terraingen.TerrainGen.getModdedMapGen(genNetherCaves, net.minecraftforge.event.terraingen.InitMapGenEvent.EventType.NETHER_CAVE); - } - - public void prepareHeights(int p_185936_1_, int p_185936_2_, ChunkPrimer primer) - { - int j = this.world.getSeaLevel() / 2 + 1; - this.buffer = this.getHeights(this.buffer, p_185936_1_ * 4, 0, p_185936_2_ * 4, 5, 17, 5); - - for (int j1 = 0; j1 < 4; ++j1) - { - for (int k1 = 0; k1 < 4; ++k1) - { - for (int l1 = 0; l1 < 16; ++l1) - { - double d1 = this.buffer[((j1 + 0) * 5 + k1 + 0) * 17 + l1 + 0]; - double d2 = this.buffer[((j1 + 0) * 5 + k1 + 1) * 17 + l1 + 0]; - double d3 = this.buffer[((j1 + 1) * 5 + k1 + 0) * 17 + l1 + 0]; - double d4 = this.buffer[((j1 + 1) * 5 + k1 + 1) * 17 + l1 + 0]; - double d5 = (this.buffer[((j1 + 0) * 5 + k1 + 0) * 17 + l1 + 1] - d1) * 0.125D; - double d6 = (this.buffer[((j1 + 0) * 5 + k1 + 1) * 17 + l1 + 1] - d2) * 0.125D; - double d7 = (this.buffer[((j1 + 1) * 5 + k1 + 0) * 17 + l1 + 1] - d3) * 0.125D; - double d8 = (this.buffer[((j1 + 1) * 5 + k1 + 1) * 17 + l1 + 1] - d4) * 0.125D; - - for (int i2 = 0; i2 < 8; ++i2) - { - double d10 = d1; - double d11 = d2; - double d12 = (d3 - d1) * 0.25D; - double d13 = (d4 - d2) * 0.25D; - - for (int j2 = 0; j2 < 4; ++j2) - { - double d15 = d10; - double d16 = (d11 - d10) * 0.25D; - - for (int k2 = 0; k2 < 4; ++k2) - { - IBlockState iblockstate = null; - - if (l1 * 8 + i2 < j) - { - iblockstate = LAVA; - } - - if (d15 > 0.0D) - { - iblockstate = NETHERRACK; - } - - if (d15 > 56.0D) - { - iblockstate = TAINTED_SOIL; - } - - int l2 = j2 + j1 * 4; - int i3 = i2 + l1 * 8; - int j3 = k2 + k1 * 4; - primer.setBlockState(l2, i3, j3, iblockstate); - d15 += d16; - } - - d10 += d12; - d11 += d13; - } - - d1 += d5; - d2 += d6; - d3 += d7; - d4 += d8; - } - } - } - } - } - - public void buildSurfaces(int p_185937_1_, int p_185937_2_, ChunkPrimer primer) - { - if (!net.minecraftforge.event.ForgeEventFactory.onReplaceBiomeBlocks(this, p_185937_1_, p_185937_2_, primer, this.world)) - return; - int i = this.world.getSeaLevel() + 1; - this.slowsandNoise = this.slowsandGravelNoiseGen.generateNoiseOctaves(this.slowsandNoise, p_185937_1_ * 16, p_185937_2_ * 16, 0, 16, 16, 1, 0.03125D, 0.03125D, 1.0D); - this.gravelNoise = this.slowsandGravelNoiseGen.generateNoiseOctaves(this.gravelNoise, p_185937_1_ * 16, 109, p_185937_2_ * 16, 16, 1, 16, 0.03125D, 1.0D, 0.03125D); - this.depthBuffer = this.netherrackExculsivityNoiseGen.generateNoiseOctaves(this.depthBuffer, p_185937_1_ * 16, p_185937_2_ * 16, 0, 16, 16, 1, 0.0625D, 0.0625D, 0.0625D); - - for (int j = 0; j < 16; ++j) - { - for (int k = 0; k < 16; ++k) - { - boolean flag = this.slowsandNoise[j + k * 16] + this.rand.nextDouble() * 0.2D > 0.0D; - boolean flag1 = this.gravelNoise[j + k * 16] + this.rand.nextDouble() * 0.2D > 0.0D; - int l = (int) (this.depthBuffer[j + k * 16] / 3.0D + 3.0D + this.rand.nextDouble() * 0.25D); - int i1 = -1; - IBlockState iblockstate = NETHERRACK; - IBlockState iblockstate1 = TAINTED_SOIL; - - for (int j1 = 127; j1 >= 0; --j1) - { - if (j1 < 127 - this.rand.nextInt(5) && j1 > this.rand.nextInt(5)) - { - IBlockState iblockstate2 = primer.getBlockState(k, j1, j); - - if (iblockstate2.getBlock() != null && iblockstate2.getMaterial() != Material.AIR) - { - if (iblockstate2.getBlock() == Blocks.NETHERRACK) - { - if (i1 == -1) - { - if (l <= 0) - { - iblockstate = AIR; - iblockstate1 = NETHERRACK; - } - else if (j1 >= i - 4 && j1 <= i + 1) - { - iblockstate = NETHERRACK; - iblockstate1 = TAINTED_SOIL; - - if (flag1) - { - iblockstate = GRAVEL; - iblockstate1 = NETHERRACK; - } - - if (flag) - { - iblockstate = SOUL_SAND; - iblockstate1 = HEAT_SAND; - } - } - - if (j1 < i && (iblockstate == null || iblockstate.getMaterial() == Material.AIR)) - { - iblockstate = LAVA; - } - - i1 = l; - - if (j1 >= i - 1) - { - primer.setBlockState(k, j1, j, iblockstate); - } - else - { - primer.setBlockState(k, j1, j, iblockstate1); - } - } - else if (i1 > 0) - { - --i1; - primer.setBlockState(k, j1, j, iblockstate1); - } - } - } - else - { - i1 = -1; - } - } - else - { - primer.setBlockState(k, j1, j, BEDROCK); - } - } - } - } - } - - /** - * Generates the chunk at the specified position, from scratch - */ - @Override - public Chunk provideChunk(int x, int z) - { - this.rand.setSeed(x * 341873128712L + z * 132897987541L); - ChunkPrimer chunkprimer = new ChunkPrimer(); - this.prepareHeights(x, z, chunkprimer); - this.buildSurfaces(x, z, chunkprimer); - this.genNetherCaves.generate(this.world, x, z, chunkprimer); - - if (this.generateStructures) - { - this.genNetherBridge.generate(this.world, x, z, chunkprimer); - } - - Chunk chunk = new ChunkNetherite(this.world, chunkprimer, x, z); - Biome[] abiome = this.world.getBiomeProvider().getBiomes((Biome[]) null, x * 16, z * 16, 16, 16); - byte[] abyte = chunk.getBiomeArray(); - - for (int i = 0; i < abyte.length; ++i) - { - abyte[i] = (byte) Biome.getIdForBiome(abiome[i]); - } - - chunk.resetRelightChecks(); - return chunk; - } - - private double[] getHeights(double[] p_185938_1_, int p_185938_2_, int p_185938_3_, int p_185938_4_, int p_185938_5_, int p_185938_6_, int p_185938_7_) - { - if (p_185938_1_ == null) - { - p_185938_1_ = new double[p_185938_5_ * p_185938_6_ * p_185938_7_]; - } - - net.minecraftforge.event.terraingen.ChunkGeneratorEvent.InitNoiseField event = new net.minecraftforge.event.terraingen.ChunkGeneratorEvent.InitNoiseField(this, p_185938_1_, p_185938_2_, p_185938_3_, p_185938_4_, p_185938_5_, p_185938_6_, p_185938_7_); - net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(event); - if (event.getResult() == net.minecraftforge.fml.common.eventhandler.Event.Result.DENY) - return event.getNoisefield(); - - this.noiseData4 = this.scaleNoise.generateNoiseOctaves(this.noiseData4, p_185938_2_, p_185938_3_, p_185938_4_, p_185938_5_, 1, p_185938_7_, 1.0D, 0.0D, 1.0D); - this.dr = this.depthNoise.generateNoiseOctaves(this.dr, p_185938_2_, p_185938_3_, p_185938_4_, p_185938_5_, 1, p_185938_7_, 100.0D, 0.0D, 100.0D); - this.pnr = this.perlinNoise1.generateNoiseOctaves(this.pnr, p_185938_2_, p_185938_3_, p_185938_4_, p_185938_5_, p_185938_6_, p_185938_7_, 8.555150000000001D, 34.2206D, 8.555150000000001D); - this.ar = this.lperlinNoise1.generateNoiseOctaves(this.ar, p_185938_2_, p_185938_3_, p_185938_4_, p_185938_5_, p_185938_6_, p_185938_7_, 684.412D, 2053.236D, 684.412D); - this.br = this.lperlinNoise2.generateNoiseOctaves(this.br, p_185938_2_, p_185938_3_, p_185938_4_, p_185938_5_, p_185938_6_, p_185938_7_, 684.412D, 2053.236D, 684.412D); - int i = 0; - double[] adouble = new double[p_185938_6_]; - - for (int j = 0; j < p_185938_6_; ++j) - { - adouble[j] = Math.cos(j * Math.PI * 6.0D / p_185938_6_) * 2.0D; - double d2 = j; - - if (j > p_185938_6_ / 2) - { - d2 = p_185938_6_ - 1 - j; - } - - if (d2 < 4.0D) - { - d2 = 4.0D - d2; - adouble[j] -= d2 * d2 * d2 * 10.0D; - } - } - - for (int l = 0; l < p_185938_5_; ++l) - { - for (int i1 = 0; i1 < p_185938_7_; ++i1) - { - for (int k = 0; k < p_185938_6_; ++k) - { - double d4 = adouble[k]; - double d5 = this.ar[i] / 512.0D; - double d6 = this.br[i] / 512.0D; - double d7 = (this.pnr[i] / 10.0D + 1.0D) / 2.0D; - double d8; - - if (d7 < 0.0D) - { - d8 = d5; - } - else if (d7 > 1.0D) - { - d8 = d6; - } - else - { - d8 = d5 + (d6 - d5) * d7; - } - - d8 = d8 - d4; - - if (k > p_185938_6_ - 4) - { - double d9 = (k - (p_185938_6_ - 4)) / 3.0F; - d8 = d8 * (1.0D - d9) + -10.0D * d9; - } - - if (k < 0.0D) - { - double d10 = (0.0D - k) / 4.0D; - d10 = MathHelper.clamp(d10, 0.0D, 1.0D); - d8 = d8 * (1.0D - d10) + -10.0D * d10; - } - - p_185938_1_[i] = d8; - ++i; - } - } - } - - return p_185938_1_; - } - - /** - * Generate initial structures in this chunk, e.g. mineshafts, temples, lakes, and dungeons - */ - @Override - public void populate(int x, int z) - { - BlockFalling.fallInstantly = true; - net.minecraftforge.event.ForgeEventFactory.onChunkPopulate(true, this, this.world, this.rand, x, z, false); - int i = x * 16; - int j = z * 16; - BlockPos blockpos = new BlockPos(i, 0, j); - Biome biome = this.world.getBiome(blockpos.add(16, 0, 16)); - ChunkPos chunkpos = new ChunkPos(x, z); - this.genNetherBridge.generateStructure(this.world, this.rand, chunkpos); - - if (net.minecraftforge.event.terraingen.TerrainGen.populate(this, this.world, this.rand, x, z, false, net.minecraftforge.event.terraingen.PopulateChunkEvent.Populate.EventType.NETHER_LAVA)) - for (int k = 0; k < 8; ++k) - { - this.hellSpringGen.generate(this.world, this.rand, blockpos.add(this.rand.nextInt(16) + 8, this.rand.nextInt(120) + 4, this.rand.nextInt(16) + 8)); - } - - if (net.minecraftforge.event.terraingen.TerrainGen.populate(this, this.world, this.rand, x, z, false, net.minecraftforge.event.terraingen.PopulateChunkEvent.Populate.EventType.FIRE)) - for (int i1 = 0; i1 < this.rand.nextInt(this.rand.nextInt(10) + 1) + 1; ++i1) - { - this.fireFeature.generate(this.world, this.rand, blockpos.add(this.rand.nextInt(16) + 8, this.rand.nextInt(120) + 4, this.rand.nextInt(16) + 8)); - } - - if (net.minecraftforge.event.terraingen.TerrainGen.populate(this, this.world, this.rand, x, z, false, net.minecraftforge.event.terraingen.PopulateChunkEvent.Populate.EventType.GLOWSTONE)) - { - for (int j1 = 0; j1 < this.rand.nextInt(this.rand.nextInt(10) + 1); ++j1) - { - this.lightGemGen.generate(this.world, this.rand, blockpos.add(this.rand.nextInt(16) + 8, this.rand.nextInt(120) + 4, this.rand.nextInt(16) + 8)); - } - - for (int k1 = 0; k1 < 10; ++k1) - { - this.hellPortalGen.generate(this.world, this.rand, blockpos.add(this.rand.nextInt(16) + 8, this.rand.nextInt(128), this.rand.nextInt(16) + 8)); - } - } //Forge: End doGLowstone - - net.minecraftforge.event.ForgeEventFactory.onChunkPopulate(false, this, this.world, this.rand, x, z, false); - net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.terraingen.DecorateBiomeEvent.Pre(this.world, this.rand, blockpos)); - - if (net.minecraftforge.event.terraingen.TerrainGen.decorate(this.world, this.rand, blockpos, net.minecraftforge.event.terraingen.DecorateBiomeEvent.Decorate.EventType.SHROOM)) - { - if (this.rand.nextBoolean()) - { - this.brownMushroomFeature.generate(this.world, this.rand, blockpos.add(this.rand.nextInt(16) + 8, this.rand.nextInt(128), this.rand.nextInt(16) + 8)); - } - - if (this.rand.nextBoolean()) - { - this.redMushroomFeature.generate(this.world, this.rand, blockpos.add(this.rand.nextInt(16) + 8, this.rand.nextInt(128), this.rand.nextInt(16) + 8)); - } - } - - if (net.minecraftforge.event.terraingen.TerrainGen.generateOre(this.world, this.rand, quartzGen, blockpos, net.minecraftforge.event.terraingen.OreGenEvent.GenerateMinable.EventType.QUARTZ)) - for (int l1 = 0; l1 < 16; ++l1) - { - this.quartzGen.generate(this.world, this.rand, blockpos.add(this.rand.nextInt(16), this.rand.nextInt(108) + 10, this.rand.nextInt(16))); - } - - int i2 = this.world.getSeaLevel() / 2 + 1; - - if (net.minecraftforge.event.terraingen.TerrainGen.populate(this, this.world, this.rand, x, z, false, net.minecraftforge.event.terraingen.PopulateChunkEvent.Populate.EventType.NETHER_MAGMA)) - for (int l = 0; l < 4; ++l) - { - this.magmaGen.generate(this.world, this.rand, blockpos.add(this.rand.nextInt(16), i2 - 5 + this.rand.nextInt(10), this.rand.nextInt(16))); - } - - if (net.minecraftforge.event.terraingen.TerrainGen.populate(this, this.world, this.rand, x, z, false, net.minecraftforge.event.terraingen.PopulateChunkEvent.Populate.EventType.NETHER_LAVA2)) - for (int j2 = 0; j2 < 16; ++j2) - { - this.lavaTrapGen.generate(this.world, this.rand, blockpos.add(this.rand.nextInt(16) + 8, this.rand.nextInt(108) + 10, this.rand.nextInt(16) + 8)); - } - - biome.decorate(this.world, this.rand, new BlockPos(i, 0, j)); - - net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.terraingen.DecorateBiomeEvent.Post(this.world, this.rand, blockpos)); - - BlockFalling.fallInstantly = false; - } - - /** - * Called to generate additional structures after initial worldgen, used by ocean monuments - */ - @Override - public boolean generateStructures(Chunk chunkIn, int x, int z) - { - return false; - } - - @Override - public List getPossibleCreatures(EnumCreatureType creatureType, BlockPos pos) - { - if (creatureType == EnumCreatureType.MONSTER) - { - if (this.genNetherBridge.isInsideStructure(pos)) - { - return this.genNetherBridge.getSpawnList(); - } - - if (this.genNetherBridge.isPositionInStructure(this.world, pos) && this.world.getBlockState(pos.down()).getBlock() == Blocks.NETHER_BRICK) - { - return this.genNetherBridge.getSpawnList(); - } - } - - Biome biome = this.world.getBiome(pos); - return biome.getSpawnableList(creatureType); - } - - @Override - @Nullable - public BlockPos getStrongholdGen(World worldIn, String structureName, BlockPos position, boolean p_180513_4_) - { - return "Fortress".equals(structureName) && this.genNetherBridge != null ? this.genNetherBridge.getClosestStrongholdPos(worldIn, position, p_180513_4_) : null; - } - - @Override - public void recreateStructures(Chunk chunkIn, int x, int z) - { - this.genNetherBridge.generate(this.world, x, z, (ChunkPrimer) null); - } -} diff --git a/src/main/java/com/progwml6/natura/world/dimension/WorldGenNetheriteFire.java b/src/main/java/com/progwml6/natura/world/dimension/WorldGenNetheriteFire.java deleted file mode 100644 index 99c613d4..00000000 --- a/src/main/java/com/progwml6/natura/world/dimension/WorldGenNetheriteFire.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.progwml6.natura.world.dimension; - -import java.util.Random; - -import com.progwml6.natura.nether.NaturaNether; - -import net.minecraft.init.Blocks; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; -import net.minecraft.world.gen.feature.WorldGenerator; - -public class WorldGenNetheriteFire extends WorldGenerator -{ - @Override - public boolean generate(World worldIn, Random rand, BlockPos position) - { - for (int i = 0; i < 64; ++i) - { - BlockPos blockpos = position.add(rand.nextInt(8) - rand.nextInt(8), rand.nextInt(4) - rand.nextInt(4), rand.nextInt(8) - rand.nextInt(8)); - - if (worldIn.isAirBlock(blockpos) && (worldIn.getBlockState(blockpos.down()).getBlock() == Blocks.NETHERRACK || worldIn.getBlockState(blockpos.down()).getBlock() == NaturaNether.netherTaintedSoil)) - { - worldIn.setBlockState(blockpos, Blocks.FIRE.getDefaultState(), 2); - } - } - - return true; - } -} diff --git a/src/main/java/com/progwml6/natura/world/dimension/WorldProviderNetherite.java b/src/main/java/com/progwml6/natura/world/dimension/WorldProviderNetherite.java deleted file mode 100644 index b995277f..00000000 --- a/src/main/java/com/progwml6/natura/world/dimension/WorldProviderNetherite.java +++ /dev/null @@ -1,77 +0,0 @@ -package com.progwml6.natura.world.dimension; - -import com.progwml6.natura.common.config.Config; - -import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.init.Biomes; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.WorldProviderHell; -import net.minecraft.world.biome.BiomeProvider; -import net.minecraft.world.biome.BiomeProviderSingle; -import net.minecraft.world.chunk.IChunkGenerator; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -public class WorldProviderNetherite extends WorldProviderHell -{ - /** - * Creates a new {@link BiomeProvider} for the WorldProvider, and also sets the values of {@link #hasSkylight} and - * {@link #hasNoSky} appropriately. - * - * Note that subclasses generally override this method without calling the parent version. - */ - @Override - public void init() - { - this.biomeProvider = new BiomeProviderSingle(Biomes.HELL); - this.doesWaterVaporize = true; - this.hasNoSky = true; - } - - @Override - public IChunkGenerator createChunkGenerator() - { - return new ChunkProviderNetherite(this.world, this.world.getWorldInfo().isMapFeaturesEnabled(), this.world.getSeed()); - } - - /** - * True if the player can respawn in this dimension (true = overworld, false = nether). - */ - @Override - public boolean canRespawnHere() - { - return false; - } - - /** - * Returns true if the given X,Z coordinate should show environmental fog. - */ - @Override - @SideOnly(Side.CLIENT) - public boolean doesXZShowFog(int x, int z) - { - return true; - } - - /** - * Determines the dimension the player will be respawned in, typically this brings them back to the overworld. - * - * @param player The player that is respawning - * @return The dimension to respawn the player in - */ - @Override - public int getRespawnDimension(EntityPlayerMP player) - { - if (Config.canRespawnInNether) - { - BlockPos coords = player.getBedLocation(-1); - - if (coords != null) - { - return -1; - } - } - - return 0; - } -} diff --git a/src/main/java/com/progwml6/natura/world/worldgen/NetherMinableGenerator.java b/src/main/java/com/progwml6/natura/world/worldgen/NetherMinableGenerator.java new file mode 100644 index 00000000..8048e800 --- /dev/null +++ b/src/main/java/com/progwml6/natura/world/worldgen/NetherMinableGenerator.java @@ -0,0 +1,108 @@ +package com.progwml6.natura.world.worldgen; + +import java.util.Random; + +import com.progwml6.natura.common.config.Config; +import com.progwml6.natura.nether.NaturaNether; + +import net.minecraft.block.state.pattern.BlockMatcher; +import net.minecraft.init.Blocks; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; +import net.minecraft.world.biome.Biome; +import net.minecraft.world.chunk.IChunkGenerator; +import net.minecraft.world.chunk.IChunkProvider; +import net.minecraft.world.gen.feature.WorldGenMinable; +import net.minecraftforge.common.BiomeDictionary; +import net.minecraftforge.common.BiomeDictionary.Type; +import net.minecraftforge.fml.common.IWorldGenerator; + +public class NetherMinableGenerator implements IWorldGenerator +{ + public static NetherMinableGenerator INSTANCE = new NetherMinableGenerator(); + + //@formatter:off + WorldGenMinable tainedSoilGen; + WorldGenMinable heatSandGen; + //@formatter:on + + public NetherMinableGenerator() + { + this.tainedSoilGen = new WorldGenMinable(NaturaNether.netherTaintedSoil.getDefaultState(), Config.tainedSoilClusterSize, BlockMatcher.forBlock(Blocks.NETHERRACK)); + this.heatSandGen = new WorldGenMinable(NaturaNether.netherHeatSand.getDefaultState(), Config.heatSandClusterSize, BlockMatcher.forBlock(Blocks.SOUL_SAND)); + } + + @Override + public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider) + { + this.generateNether(random, chunkX, chunkZ, world); + } + + public void retroGen(Random random, int chunkX, int chunkZ, World world) + { + this.generateNether(random, chunkX, chunkZ, world); + + world.getChunkFromChunkCoords(chunkX, chunkZ).setChunkModified(); + } + + public void generateNether(Random random, int chunkX, int chunkZ, World world) + { + int xSpawn, ySpawn, zSpawn; + + int xPos = chunkX * 16; + int yPos = world.getSeaLevel() / 2 + 1 - 5; + int zPos = chunkZ * 16; + + BlockPos chunkPos = new BlockPos(xPos, 0, zPos); + + Biome biome = world.getChunkFromBlockCoords(chunkPos).getBiome(chunkPos, world.getBiomeProvider()); + + if (biome == null) + { + return; + } + + if (this.shouldGenerateInDimension(world.provider.getDimension())) + { + if (BiomeDictionary.hasType(biome, Type.NETHER)) + { + if (Config.generateTaintedSoil) + { + for (int i = 0; i < Config.tainedSoilClusterCount; i++) + { + xSpawn = xPos + random.nextInt(16); + ySpawn = yPos + random.nextInt(10); + zSpawn = zPos + random.nextInt(16); + + tainedSoilGen.generate(world, random, new BlockPos(xSpawn, ySpawn, zSpawn)); + } + } + + if (Config.generateHeatSand) + { + for (int i = 0; i < Config.heatSandClusterCount; i++) + { + xSpawn = xPos + random.nextInt(16); + ySpawn = yPos + random.nextInt(10); + zSpawn = zPos + random.nextInt(16); + + heatSandGen.generate(world, random, new BlockPos(xSpawn, ySpawn, zSpawn)); + } + } + } + } + } + + public boolean shouldGenerateInDimension(int dimension) + { + for (int dimensionId : Config.netherWorldGenBlacklist) + { + if (dimension == dimensionId) + { + return false; + } + } + + return true; + } +} diff --git a/src/main/java/com/progwml6/natura/world/worldgen/retrogen/TickHandlerWorldRetrogen.java b/src/main/java/com/progwml6/natura/world/worldgen/retrogen/TickHandlerWorldRetrogen.java index 4de503fc..36112f1c 100644 --- a/src/main/java/com/progwml6/natura/world/worldgen/retrogen/TickHandlerWorldRetrogen.java +++ b/src/main/java/com/progwml6/natura/world/worldgen/retrogen/TickHandlerWorldRetrogen.java @@ -13,6 +13,7 @@ import com.progwml6.natura.world.worldgen.CropGenerator; import com.progwml6.natura.world.worldgen.GlowshroomGenerator; import com.progwml6.natura.world.worldgen.NetherBerryBushesGenerator; +import com.progwml6.natura.world.worldgen.NetherMinableGenerator; import com.progwml6.natura.world.worldgen.NetherTreesGenerator; import com.progwml6.natura.world.worldgen.OverworldBerryBushesGenerator; import com.progwml6.natura.world.worldgen.OverworldTreesGenerator; @@ -42,6 +43,7 @@ public class TickHandlerWorldRetrogen private NetherBerryBushesGenerator netherBerryBushesGenerator; private GlowshroomGenerator glowshroomGenerator; private VineGenerator vineGenerator; + private NetherMinableGenerator netherMineableGenerator; //@formatter:on private final LinkedListMultimap chunkRegenList = LinkedListMultimap.create(); @@ -64,6 +66,7 @@ public TickHandlerWorldRetrogen() netherBerryBushesGenerator = new NetherBerryBushesGenerator(); glowshroomGenerator = new GlowshroomGenerator(); vineGenerator = new VineGenerator(); + netherMineableGenerator = new NetherMinableGenerator(); } } @@ -84,6 +87,7 @@ public void onWorldTick(WorldTickEvent event) if (!chunkList.isEmpty()) { ChunkCoords coords = chunkList.get(0); + chunkList.remove(0); // This bit is from FML's GameRegistry.generateWorld where the seed is constructed. @@ -91,16 +95,19 @@ public void onWorldTick(WorldTickEvent event) Random random = new Random(worldSeed); long xSeed = random.nextLong() >> 2 + 1L; long zSeed = random.nextLong() >> 2 + 1L; + random.setSeed(xSeed * coords.xCoord + zSeed * coords.zCoord ^ worldSeed); if (Natura.pulseManager.isPulseLoaded(NaturaOverworld.PulseId)) { this.overworldTreesGenerator.retroGen(random, coords.xCoord, coords.zCoord, world); this.overworldBerryBushesGenerator.retroGen(random, coords.xCoord, coords.zCoord, world); + if (Config.enableCloudBlocks) { this.cloudGenerator.retroGen(random, coords.xCoord, coords.zCoord, world); } + this.cropGenerator.retroGen(random, coords.xCoord, coords.zCoord, world); } @@ -110,6 +117,7 @@ public void onWorldTick(WorldTickEvent event) this.netherBerryBushesGenerator.retroGen(random, coords.xCoord, coords.zCoord, world); this.glowshroomGenerator.retroGen(random, coords.xCoord, coords.zCoord, world); this.vineGenerator.retroGen(random, coords.xCoord, coords.zCoord, world); + this.netherMineableGenerator.retroGen(random, coords.xCoord, coords.zCoord, world); } } }