mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
reimplement oil (regular + sand) bubbles as MapGenBase
This commit is contained in:
parent
264ee49212
commit
edbc062da0
@ -1,7 +1,6 @@
|
||||
package com.hbm.lib;
|
||||
|
||||
import com.hbm.world.gen.MapGenChainloader.MapGenEventHandler;
|
||||
import com.hbm.world.gen.MapGenCrater;
|
||||
import com.hbm.blocks.ModBlocks;
|
||||
import com.hbm.config.GeneralConfig;
|
||||
import com.hbm.config.WorldConfig;
|
||||
@ -11,9 +10,12 @@ import com.hbm.world.gen.NTMWorldGenerator;
|
||||
import com.hbm.world.gen.component.*;
|
||||
import com.hbm.world.gen.component.BunkerComponents.BunkerStart;
|
||||
import com.hbm.world.gen.nbt.NBTStructure;
|
||||
import com.hbm.world.gen.terrain.MapGenBubble;
|
||||
import com.hbm.world.gen.terrain.MapGenCrater;
|
||||
|
||||
import cpw.mods.fml.common.IWorldGenerator;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
import net.minecraft.world.gen.structure.MapGenStructureIO;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
@ -64,6 +66,26 @@ public class HbmWorld {
|
||||
sellafieldCrater.targetBiome = BiomeGenBase.desert;
|
||||
MapGenChainloader.addOverworldGenerator(sellafieldCrater);
|
||||
}
|
||||
|
||||
if(WorldConfig.oilSpawn > 0) {
|
||||
MapGenBubble oilBubble = new MapGenBubble(WorldConfig.oilSpawn);
|
||||
oilBubble.block = ModBlocks.ore_oil;
|
||||
oilBubble.setSize(8, 16);
|
||||
MapGenChainloader.addOverworldGenerator(oilBubble);
|
||||
}
|
||||
|
||||
int sandBubbleSpawn = 200;
|
||||
if(sandBubbleSpawn > 0) {
|
||||
MapGenBubble sandOilBubble = new MapGenBubble(sandBubbleSpawn);
|
||||
sandOilBubble.replace = Blocks.sand;
|
||||
sandOilBubble.block = ModBlocks.ore_oil_sand;
|
||||
sandOilBubble.canSpawn = biome -> !biome.canSpawnLightningBolt() && biome.temperature >= 1.5F;
|
||||
sandOilBubble.minY = 56;
|
||||
sandOilBubble.rangeY = 16;
|
||||
sandOilBubble.setSize(16, 48);
|
||||
sandOilBubble.fuzzy = true;
|
||||
MapGenChainloader.addOverworldGenerator(sandOilBubble);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -223,18 +223,6 @@ public class HbmWorldGen implements IWorldGenerator {
|
||||
}
|
||||
}
|
||||
|
||||
// if(biome == BiomeGenBase.plains || biome == BiomeGenBase.desert) {
|
||||
// if(WorldConfig.radioStructure > 0 && rand.nextInt(WorldConfig.radioStructure) == 0) {
|
||||
// for(int a = 0; a < 1; a++) {
|
||||
// int x = i + rand.nextInt(16);
|
||||
// int z = j + rand.nextInt(16);
|
||||
// int y = world.getHeightValue(x, z);
|
||||
//
|
||||
// new Radio01().generate(world, rand, x, y, z);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
if(biome.temperature >= 0.4F && biome.rainfall <= 0.6F) {
|
||||
if(WorldConfig.antennaStructure > 0 && rand.nextInt(WorldConfig.antennaStructure) == 0) {
|
||||
for(int a = 0; a < 1; a++) {
|
||||
@ -278,26 +266,6 @@ public class HbmWorldGen implements IWorldGenerator {
|
||||
}
|
||||
}
|
||||
|
||||
if(!biome.canSpawnLightningBolt() && biome.temperature >= 1.5F) {
|
||||
if(rand.nextInt(200) == 0) {
|
||||
for(int a = 0; a < 1; a++) {
|
||||
int x = i + rand.nextInt(16);
|
||||
int z = j + rand.nextInt(16);
|
||||
int y = world.getHeightValue(x, z);
|
||||
|
||||
OilSandBubble.spawnOil(world, x, y, z, 15 + rand.nextInt(31));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// if(WorldConfig.factoryStructure > 0 && rand.nextInt(WorldConfig.factoryStructure) == 0) {
|
||||
// int x = i + rand.nextInt(16);
|
||||
// int z = j + rand.nextInt(16);
|
||||
// int y = world.getHeightValue(x, z);
|
||||
//
|
||||
// new Factory().generate(world, rand, x, y, z);
|
||||
// }
|
||||
|
||||
if(WorldConfig.dudStructure > 0 && rand.nextInt(WorldConfig.dudStructure) == 0) {
|
||||
int x = i + 8 + rand.nextInt(16);
|
||||
int z = j + 8 + rand.nextInt(16);
|
||||
@ -527,14 +495,6 @@ public class HbmWorldGen implements IWorldGenerator {
|
||||
}
|
||||
}
|
||||
|
||||
if(WorldConfig.oilSpawn > 0 && rand.nextInt(WorldConfig.oilSpawn) == 0) {
|
||||
int randPosX = i + rand.nextInt(16);
|
||||
int randPosY = rand.nextInt(25);
|
||||
int randPosZ = j + rand.nextInt(16);
|
||||
|
||||
OilBubble.spawnOil(world, randPosX, randPosY, randPosZ, 10 + rand.nextInt(7));
|
||||
}
|
||||
|
||||
if(WorldConfig.bedrockOilSpawn > 0 && rand.nextInt(WorldConfig.bedrockOilSpawn) == 0) {
|
||||
int randPosX = i + rand.nextInt(16);
|
||||
int randPosZ = j + rand.nextInt(16);
|
||||
|
||||
@ -1,33 +0,0 @@
|
||||
package com.hbm.world.feature;
|
||||
|
||||
import com.hbm.blocks.ModBlocks;
|
||||
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class OilBubble {
|
||||
|
||||
public static void spawnOil(World world, int x, int y, int z, int radius) {
|
||||
int r = radius;
|
||||
int r2 = r * r;
|
||||
int r22 = r2 / 2;
|
||||
|
||||
for (int xx = -r; xx < r; xx++) {
|
||||
int X = xx + x;
|
||||
int XX = xx * xx;
|
||||
for (int yy = -r; yy < r; yy++) {
|
||||
int Y = yy + y;
|
||||
int YY = XX + yy * yy * 3;
|
||||
for (int zz = -r; zz < r; zz++) {
|
||||
int Z = zz + z;
|
||||
int ZZ = YY + zz * zz;
|
||||
if (ZZ < r22) {
|
||||
if(world.getBlock(X, Y, Z) == Blocks.stone)
|
||||
world.setBlock(X, Y, Z, ModBlocks.ore_oil);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,37 +0,0 @@
|
||||
package com.hbm.world.feature;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import com.hbm.blocks.ModBlocks;
|
||||
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class OilSandBubble {
|
||||
|
||||
private final static Random field_149933_a = new Random();
|
||||
|
||||
public static void spawnOil(World world, int x, int y, int z, int radius) {
|
||||
int r = radius;
|
||||
int r2 = r * r;
|
||||
int r22 = r2 / 2;
|
||||
|
||||
for (int xx = -r; xx < r; xx++) {
|
||||
int X = xx + x;
|
||||
int XX = xx * xx;
|
||||
for (int yy = -r; yy < r; yy++) {
|
||||
int Y = yy + y;
|
||||
int YY = XX + yy * yy * 3;
|
||||
for (int zz = -r; zz < r; zz++) {
|
||||
int Z = zz + z;
|
||||
int ZZ = YY + zz * zz;
|
||||
if (ZZ < r22 + field_149933_a.nextInt(r22 / 3)) {
|
||||
if(world.getBlock(X, Y, Z) == Blocks.sand)
|
||||
world.setBlock(X, Y, Z, ModBlocks.ore_oil_sand);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
79
src/main/java/com/hbm/world/gen/terrain/MapGenBubble.java
Normal file
79
src/main/java/com/hbm/world/gen/terrain/MapGenBubble.java
Normal file
@ -0,0 +1,79 @@
|
||||
package com.hbm.world.gen.terrain;
|
||||
|
||||
import java.util.function.Predicate;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
import net.minecraft.world.gen.MapGenBase;
|
||||
|
||||
public class MapGenBubble extends MapGenBase {
|
||||
|
||||
/**
|
||||
* Generates oil bubbles, which are generally wider than a chunk, in a safe + cascadeless manner
|
||||
* Pretty much just an oblate sphere generator (dimensions: 3 x 1 x 3)
|
||||
*/
|
||||
|
||||
private final int frequency;
|
||||
private int minSize = 8;
|
||||
private int maxSize = 64;
|
||||
|
||||
public int minY = 0;
|
||||
public int rangeY = 25;
|
||||
|
||||
public boolean fuzzy;
|
||||
|
||||
public Block block;
|
||||
public Block replace = Blocks.stone;
|
||||
|
||||
public Predicate<BiomeGenBase> canSpawn;
|
||||
|
||||
public MapGenBubble(int frequency) {
|
||||
this.frequency = frequency;
|
||||
}
|
||||
|
||||
public void setSize(int minSize, int maxSize) {
|
||||
this.minSize = minSize;
|
||||
this.maxSize = maxSize;
|
||||
|
||||
this.range = (maxSize / 8) + 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void func_151538_a(World world, int offsetX, int offsetZ, int chunkX, int chunkZ, Block[] blocks) {
|
||||
if(rand.nextInt(frequency) == 0 && (canSpawn == null || canSpawn.test(world.getBiomeGenForCoords(offsetX * 16, offsetZ * 16)))) {
|
||||
int xCoord = chunkX - offsetX;
|
||||
int zCoord = chunkZ - offsetZ;
|
||||
|
||||
int yCoord = rand.nextInt(rangeY) + minY;
|
||||
|
||||
double radius = rand.nextInt(maxSize - minSize) + minSize;
|
||||
double radiusSqr = (radius * radius) / 2; // original OilBubble implementation divided the square by 2 for some reason
|
||||
|
||||
int yMin = Math.max(1, MathHelper.floor_double(yCoord - radius));
|
||||
int yMax = MathHelper.ceiling_double_int(yCoord + radius);
|
||||
|
||||
for(int bx = 15; bx >= 0; bx--) // bx, bz is the coordinate of the block we're modifying, relative to the generating chunk origin
|
||||
for(int bz = 15; bz >= 0; bz--)
|
||||
for(int by = yMin; by < yMax; by++) {
|
||||
int index = (bx * 16 + bz) * 256 + by;
|
||||
|
||||
if(blocks[index] == replace) {
|
||||
// x, z are the coordinates relative to the target virtual chunk origin
|
||||
int x = xCoord * 16 + bx;
|
||||
int z = zCoord * 16 + bz;
|
||||
int y = yCoord - by;
|
||||
|
||||
double rSqr = x * x + z * z + y * y * 3;
|
||||
if(fuzzy) rSqr -= rand.nextDouble() * radiusSqr / 3;
|
||||
if(rSqr < radiusSqr) {
|
||||
blocks[index] = block;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,4 +1,4 @@
|
||||
package com.hbm.world.gen;
|
||||
package com.hbm.world.gen.terrain;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.util.MathHelper;
|
||||
Loading…
x
Reference in New Issue
Block a user