feat: added infdev generator

This commit is contained in:
Timo Ley 2024-11-16 14:42:10 +01:00
parent b779c11977
commit 02c79c5f0b
10 changed files with 957 additions and 0 deletions

View file

@ -14,6 +14,7 @@ import dev.tilera.cwg.api.options.IGeneratorOptionRegistry;
import dev.tilera.cwg.api.utils.BooleanOption;
import dev.tilera.cwg.api.utils.IntOption;
import dev.tilera.cwg.api.utils.StringOption;
import dev.tilera.cwg.biome.Biomes;
import dev.tilera.cwg.classic.ClassicChunkManagerFactory;
import dev.tilera.cwg.command.CommandChangeWorld;
import dev.tilera.cwg.dimensions.CustomDimensions;
@ -24,6 +25,7 @@ import dev.tilera.cwg.hooks.HookOption;
import dev.tilera.cwg.hooks.HookRegistry;
import dev.tilera.cwg.hooks.ICavegenHook;
import dev.tilera.cwg.hooks.SwissCavegenHook;
import dev.tilera.cwg.infdev.InfdevChunkManagerFactory;
import dev.tilera.cwg.noisegen.NoiseGeneratorOctavesFarlands;
import dev.tilera.cwg.options.ChunkManagerOption;
import dev.tilera.cwg.options.ConfigProvider;
@ -69,6 +71,7 @@ public class ClassicWorldgen {
@EventHandler
public void init(FMLInitializationEvent event)
{
Biomes.init();
MinecraftForge.TERRAIN_GEN_BUS.register(this);
MinecraftForge.EVENT_BUS.register(this);
registerGenerators();
@ -115,6 +118,7 @@ public class ClassicWorldgen {
).registerDefault());
CwgGlobals.getGeneratorRegistry().registerChunkManager(new ClassicChunkManagerFactory());
CwgGlobals.getGeneratorRegistry().registerChunkManager(new SingleBiomeChunkManagerFactory());
CwgGlobals.getGeneratorRegistry().registerChunkManager(new InfdevChunkManagerFactory());
}
@SubscribeEvent

View file

@ -19,6 +19,7 @@ public class Config {
public static boolean enableDesertLakes = true;
public static boolean enableModdedWorldgen = true;
public static int dimensionProviderID = 88;
public static int classicBiomeID = 70;
public static void initConfig() {
conf = new Configuration(new File(Loader.instance().getConfigDir(), "ClassicWorldgen.cfg"));
@ -36,6 +37,7 @@ public class Config {
enableDesertLakes = conf.getBoolean("enableDesertLakes", "worldgen", enableDesertLakes, "enable lakes in desert in classic worldgen");
enableModdedWorldgen = conf.getBoolean("enableModdedWorldgen", "worldgen", enableModdedWorldgen, "enable worldgen features from other mods");
dimensionProviderID = conf.getInt("providerID", "dimensions", dimensionProviderID, Integer.MIN_VALUE, Integer.MAX_VALUE, null);
classicBiomeID = conf.getInt("classicID", "biomes", classicBiomeID, Integer.MIN_VALUE, Integer.MAX_VALUE, "Biome ID of the Classic biome");
conf.save();
}

View file

@ -0,0 +1,21 @@
package dev.tilera.cwg.biome;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.world.biome.BiomeGenBase;
public class BiomeClassic extends BiomeGenBase {
public BiomeClassic(int id) {
super(id);
}
@SideOnly(Side.CLIENT)
public int getBiomeGrassColor(int a, int b, int c) {
return 11272039;
}
@SideOnly(Side.CLIENT)
public int getBiomeFoliageColor(int a, int b, int c) {
return 5242667;
}
}

View file

@ -0,0 +1,12 @@
package dev.tilera.cwg.biome;
import dev.tilera.cwg.Config;
import net.minecraft.world.biome.BiomeGenBase;
public class Biomes {
public static BiomeGenBase classic;
public static void init() {
classic = new BiomeClassic(Config.classicBiomeID).setColor(353825).setBiomeName("Classic");
}
}

View file

@ -0,0 +1,26 @@
package dev.tilera.cwg.infdev;
import net.minecraft.block.Block;
public class ChunkConverter {
public static void convert(Block[] blocks1, Block[] blocks2) {
int len1 = blocks1.length / 256;
int len2 = blocks2.length / 256;
int k = Math.min(len1, len2);
for (int x = 0; x < 16; ++x)
{
for (int z = 0; z < 16; ++z)
{
for (int y = 0; y < k; ++y)
{
int k1 = x * len1 * 16 | z * len1 | y;
int k2 = x * len2 * 16 | z * len2 | y;
blocks2[k2] = blocks1[k1];
}
}
}
}
}

View file

@ -0,0 +1,528 @@
package dev.tilera.cwg.infdev;
import java.util.List;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.BlockFalling;
import net.minecraft.entity.EnumCreatureType;
import net.minecraft.init.Blocks;
import net.minecraft.util.IProgressUpdate;
import net.minecraft.world.ChunkPosition;
import net.minecraft.world.SpawnerAnimals;
import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.chunk.IChunkProvider;
import net.minecraft.world.gen.MapGenBase;
import net.minecraft.world.gen.feature.WorldGenFlowers;
import net.minecraft.world.gen.feature.WorldGenLiquids;
import net.minecraft.world.gen.feature.WorldGenTrees;
import net.minecraft.world.gen.feature.WorldGenerator;
import net.minecraft.world.gen.structure.MapGenMineshaft;
import net.minecraft.world.gen.structure.MapGenStronghold;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.terraingen.PopulateChunkEvent.Post;
import net.minecraftforge.event.terraingen.PopulateChunkEvent.Pre;
public class ChunkGeneratorInfdev implements IChunkProvider {
private Random field_913_j;
private NoiseOctavesInfdev field_912_k;
private NoiseOctavesInfdev field_911_l;
private NoiseOctavesInfdev field_910_m;
private NoiseOctavesInfdev field_909_n;
private NoiseOctavesInfdev field_908_o;
public NoiseOctavesInfdev field_922_a;
public NoiseOctavesInfdev field_921_b;
public NoiseOctavesInfdev field_920_c;
private World field_907_p;
private final boolean mapFeaturesEnabled;
private double[] field_906_q;
private double[] field_905_r = new double[256];
private double[] field_904_s = new double[256];
private double[] field_903_t = new double[256];
private MapGenBase caveGenerator;
private MapGenStronghold strongholdGenerator = new MapGenStronghold();
private MapGenMineshaft mineshaftGenerator = new MapGenMineshaft();
double[] field_919_d;
double[] field_918_e;
double[] field_917_f;
double[] field_916_g;
double[] field_915_h;
int[][] field_914_i = new int[32][32];
public ChunkGeneratorInfdev(World world, long l, boolean par4, MapGenBase caveGenerator) {
this.field_907_p = world;
this.mapFeaturesEnabled = par4;
this.field_913_j = new Random(l);
this.field_912_k = new NoiseOctavesInfdev(this.field_913_j, 16);
this.field_911_l = new NoiseOctavesInfdev(this.field_913_j, 16);
this.field_910_m = new NoiseOctavesInfdev(this.field_913_j, 8);
this.field_909_n = new NoiseOctavesInfdev(this.field_913_j, 4);
this.field_908_o = new NoiseOctavesInfdev(this.field_913_j, 4);
this.field_922_a = new NoiseOctavesInfdev(this.field_913_j, 10);
this.field_921_b = new NoiseOctavesInfdev(this.field_913_j, 16);
this.field_920_c = new NoiseOctavesInfdev(this.field_913_j, 8);
this.caveGenerator = caveGenerator;
}
public void generateTerrain(int i, int j, Block[] blocks) {
byte byte0 = 4;
byte byte1 = 64;
int k = byte0 + 1;
byte byte2 = 17;
int l = byte0 + 1;
this.field_906_q = this.initializeNoiseField(this.field_906_q, i * byte0, 0, j * byte0, k, byte2, l);
for(int i1 = 0; i1 < byte0; ++i1) {
for(int j1 = 0; j1 < byte0; ++j1) {
for(int k1 = 0; k1 < 16; ++k1) {
double d = 0.125D;
double d1 = this.field_906_q[((i1 + 0) * l + j1 + 0) * byte2 + k1 + 0];
double d2 = this.field_906_q[((i1 + 0) * l + j1 + 1) * byte2 + k1 + 0];
double d3 = this.field_906_q[((i1 + 1) * l + j1 + 0) * byte2 + k1 + 0];
double d4 = this.field_906_q[((i1 + 1) * l + j1 + 1) * byte2 + k1 + 0];
double d5 = (this.field_906_q[((i1 + 0) * l + j1 + 0) * byte2 + k1 + 1] - d1) * d;
double d6 = (this.field_906_q[((i1 + 0) * l + j1 + 1) * byte2 + k1 + 1] - d2) * d;
double d7 = (this.field_906_q[((i1 + 1) * l + j1 + 0) * byte2 + k1 + 1] - d3) * d;
double d8 = (this.field_906_q[((i1 + 1) * l + j1 + 1) * byte2 + k1 + 1] - d4) * d;
for(int l1 = 0; l1 < 8; ++l1) {
double d9 = 0.25D;
double d10 = d1;
double d11 = d2;
double d12 = (d3 - d1) * d9;
double d13 = (d4 - d2) * d9;
for(int i2 = 0; i2 < 4; ++i2) {
int j2 = i2 + i1 * 4 << 11 | 0 + j1 * 4 << 7 | k1 * 8 + l1;
char c = 128;
double d14 = 0.25D;
double d15 = d10;
double d16 = (d11 - d10) * d14;
for(int k2 = 0; k2 < 4; ++k2) {
Block l2 = Blocks.air;
if (k1 * 8 + l1 < byte1) {
l2 = Blocks.water;
}
if (d15 > 0.0D) {
l2 = Blocks.stone;
}
blocks[j2] = l2;
j2 += c;
d15 += d16;
}
d10 += d12;
d11 += d13;
}
d1 += d5;
d2 += d6;
d3 += d7;
d4 += d8;
}
}
}
}
}
public void replaceBlocksForBiome(int i, int j, Block[] blocks) {
byte byte0 = 64;
double d = 0.03125D;
this.field_905_r = this.field_909_n.func_807_a(this.field_905_r, (double)(i * 16), (double)(j * 16), 0.0D, 16, 16, 1, d, d, 1.0D);
this.field_904_s = this.field_909_n.func_807_a(this.field_904_s, (double)(j * 16), 109.0134D, (double)(i * 16), 16, 1, 16, d, 1.0D, d);
this.field_903_t = this.field_908_o.func_807_a(this.field_903_t, (double)(i * 16), (double)(j * 16), 0.0D, 16, 16, 1, d * 2.0D, d * 2.0D, d * 2.0D);
for(int k = 0; k < 16; ++k) {
for(int l = 0; l < 16; ++l) {
boolean flag = this.field_905_r[k + l * 16] + this.field_913_j.nextDouble() * 0.2D > 0.0D;
boolean flag1 = this.field_904_s[k + l * 16] + this.field_913_j.nextDouble() * 0.2D > 3.0D;
int i1 = (int)(this.field_903_t[k + l * 16] / 3.0D + 3.0D + this.field_913_j.nextDouble() * 0.25D);
int j1 = -1;
Block byte1 = Blocks.grass;
Block byte2 = Blocks.dirt;
for(int k1 = 127; k1 >= 0; --k1) {
int l1 = (k * 16 + l) * 128 + k1;
if (k1 <= 0 + this.field_913_j.nextInt(6) - 1) {
blocks[l1] = Blocks.bedrock;
} else {
Block byte3 = blocks[l1];
if (byte3 == Blocks.air) {
j1 = -1;
} else if (byte3 == Blocks.stone) {
if (j1 == -1) {
if (i1 <= 0) {
byte1 = Blocks.air;
byte2 = Blocks.stone;
} else if (k1 >= byte0 - 4 && k1 <= byte0 + 1) {
byte1 = Blocks.grass;
byte2 = Blocks.dirt;
if (flag1) {
byte1 = Blocks.air;
}
if (flag1) {
byte2 = Blocks.gravel;
}
if (flag) {
byte1 = Blocks.sand;
}
if (flag) {
byte2 = Blocks.sand;
}
}
if (k1 < byte0 && byte1 == Blocks.air) {
byte1 = Blocks.flowing_water;
}
j1 = i1;
if (k1 >= byte0 - 1) {
blocks[l1] = (Block)byte1;
} else {
blocks[l1] = (Block)byte2;
}
} else if (j1 > 0) {
--j1;
blocks[l1] = (Block)byte2;
}
}
}
}
}
}
}
public Chunk loadChunk(int par1, int par2) {
return this.provideChunk(par1, par2);
}
public Chunk provideChunk(int i, int j) {
this.field_913_j.setSeed((long)i * 341873128712L + (long)j * 132897987541L);
Block[] blocks1 = new Block[32768];
this.generateTerrain(i, j, blocks1);
this.replaceBlocksForBiome(i, j, blocks1);
Block[] blocks2 = new Block[65536];
//System.arraycopy(blocks1, 0, blocks2, 0, blocks1.length);
ChunkConverter.convert(blocks1, blocks2);
this.caveGenerator.func_151539_a(this, this.field_907_p, i, j, blocks2);
if (this.mapFeaturesEnabled) {
this.strongholdGenerator.func_151539_a(this, this.field_907_p, i, j, blocks2);
this.mineshaftGenerator.func_151539_a(this, this.field_907_p, i, j, blocks2);
}
Chunk chunk = new Chunk(this.field_907_p, blocks2, new byte[65536], i, j);
chunk.generateSkylightMap();
return chunk;
}
private double[] initializeNoiseField(double[] ad, int i, int j, int k, int l, int i1, int j1) {
if (ad == null) {
ad = new double[l * i1 * j1];
}
double d = 684.412D;
double d1 = 684.412D;
this.field_916_g = this.field_922_a.func_807_a(this.field_916_g, (double)i, (double)j, (double)k, l, 1, j1, 1.0D, 0.0D, 1.0D);
this.field_915_h = this.field_921_b.func_807_a(this.field_915_h, (double)i, (double)j, (double)k, l, 1, j1, 100.0D, 0.0D, 100.0D);
this.field_919_d = this.field_910_m.func_807_a(this.field_919_d, (double)i, (double)j, (double)k, l, i1, j1, d / 80.0D, d1 / 160.0D, d / 80.0D);
this.field_918_e = this.field_912_k.func_807_a(this.field_918_e, (double)i, (double)j, (double)k, l, i1, j1, d, d1, d);
this.field_917_f = this.field_911_l.func_807_a(this.field_917_f, (double)i, (double)j, (double)k, l, i1, j1, d, d1, d);
int k1 = 0;
int l1 = 0;
for(int i2 = 0; i2 < l; ++i2) {
for(int j2 = 0; j2 < j1; ++j2) {
double d2 = (this.field_916_g[l1] + 256.0D) / 512.0D;
if (d2 > 1.0D) {
d2 = 1.0D;
}
double d3 = 0.0D;
double d4 = this.field_915_h[l1] / 8000.0D;
if (d4 < 0.0D) {
d4 = -d4;
}
d4 = d4 * 3.0D - 3.0D;
if (d4 < 0.0D) {
d4 /= 2.0D;
if (d4 < -1.0D) {
d4 = -1.0D;
}
d4 /= 1.4D;
d4 /= 2.0D;
d2 = 0.0D;
} else {
if (d4 > 1.0D) {
d4 = 1.0D;
}
d4 /= 6.0D;
}
d2 += 0.5D;
d4 = d4 * (double)i1 / 16.0D;
double d5 = (double)i1 / 2.0D + d4 * 4.0D;
++l1;
for(int k2 = 0; k2 < i1; ++k2) {
double d6 = 0.0D;
double d7 = ((double)k2 - d5) * 12.0D / d2;
if (d7 < 0.0D) {
d7 *= 4.0D;
}
double d8 = this.field_918_e[k1] / 512.0D;
double d9 = this.field_917_f[k1] / 512.0D;
double d10 = (this.field_919_d[k1] / 10.0D + 1.0D) / 2.0D;
if (d10 < 0.0D) {
d6 = d8;
} else if (d10 > 1.0D) {
d6 = d9;
} else {
d6 = d8 + (d9 - d8) * d10;
}
d6 -= d7;
double d12;
if (k2 > i1 - 4) {
d12 = (double)((float)(k2 - (i1 - 4)) / 3.0F);
d6 = d6 * (1.0D - d12) + -10.0D * d12;
}
if ((double)k2 < d3) {
d12 = (d3 - (double)k2) / 4.0D;
if (d12 < 0.0D) {
d12 = 0.0D;
}
if (d12 > 1.0D) {
d12 = 1.0D;
}
d6 = d6 * (1.0D - d12) + -10.0D * d12;
}
ad[k1] = d6;
++k1;
}
}
}
return ad;
}
public boolean chunkExists(int par1, int par2) {
return true;
}
public void populate(IChunkProvider ichunkprovider, int i, int j) {
BlockFalling.fallInstantly = true;
int k = i * 16;
int l = j * 16;
BiomeGenBase biomegenbase = this.field_907_p.getWorldChunkManager().getBiomeGenAt(k + 16, l + 16);
this.field_913_j.setSeed(this.field_907_p.getSeed());
long l1 = this.field_913_j.nextLong() / 2L * 2L + 1L;
long l2 = this.field_913_j.nextLong() / 2L * 2L + 1L;
this.field_913_j.setSeed((long)i * l1 + (long)j * l2 ^ this.field_907_p.getSeed());
double d = 0.25D;
MinecraftForge.EVENT_BUS.post(new Pre(ichunkprovider, this.field_907_p, this.field_913_j, i, j, false));
if (this.mapFeaturesEnabled) {
this.strongholdGenerator.generateStructuresInChunk(this.field_907_p, this.field_913_j, i, j);
this.mineshaftGenerator.generateStructuresInChunk(this.field_907_p, this.field_913_j, i, j);
}
int l3;
int i6;
int sn1;
int sn2;
for(l3 = 0; l3 < 20; ++l3) {
i6 = k + this.field_913_j.nextInt(16);
sn1 = this.field_913_j.nextInt(128);
sn2 = l + this.field_913_j.nextInt(16);
(new GenMinable(Blocks.dirt, 32, 0)).generate(this.field_907_p, this.field_913_j, i6, sn1, sn2);
}
for(l3 = 0; l3 < 10; ++l3) {
i6 = k + this.field_913_j.nextInt(16);
sn1 = this.field_913_j.nextInt(128);
sn2 = l + this.field_913_j.nextInt(16);
(new GenMinable(Blocks.gravel, 32, 0)).generate(this.field_907_p, this.field_913_j, i6, sn1, sn2);
}
for(l3 = 0; l3 < 20; ++l3) {
i6 = k + this.field_913_j.nextInt(16);
sn1 = this.field_913_j.nextInt(128);
sn2 = l + this.field_913_j.nextInt(16);
(new GenMinable(Blocks.coal_ore, 16, 0)).generate(this.field_907_p, this.field_913_j, i6, sn1, sn2);
}
for(l3 = 0; l3 < 20; ++l3) {
i6 = k + this.field_913_j.nextInt(16);
sn1 = this.field_913_j.nextInt(64);
sn2 = l + this.field_913_j.nextInt(16);
(new GenMinable(Blocks.iron_ore, 8, 0)).generate(this.field_907_p, this.field_913_j, i6, sn1, sn2);
}
for(l3 = 0; l3 < 2; ++l3) {
i6 = k + this.field_913_j.nextInt(16);
sn1 = this.field_913_j.nextInt(32);
sn2 = l + this.field_913_j.nextInt(16);
(new GenMinable(Blocks.gold_ore, 8, 0)).generate(this.field_907_p, this.field_913_j, i6, sn1, sn2);
}
for(l3 = 0; l3 < 8; ++l3) {
i6 = k + this.field_913_j.nextInt(16);
sn1 = this.field_913_j.nextInt(16);
sn2 = l + this.field_913_j.nextInt(16);
(new GenMinable(Blocks.redstone_ore, 7, 0)).generate(this.field_907_p, this.field_913_j, i6, sn1, sn2);
}
for(l3 = 0; l3 < 1; ++l3) {
i6 = k + this.field_913_j.nextInt(16);
sn1 = this.field_913_j.nextInt(16);
sn2 = l + this.field_913_j.nextInt(16);
(new GenMinable(Blocks.diamond_ore, 7, 0)).generate(this.field_907_p, this.field_913_j, i6, sn1, sn2);
}
d = 0.5D;
l3 = (int)((this.field_920_c.func_806_a((double)k * d, (double)l * d) / 8.0D + this.field_913_j.nextDouble() * 4.0D + 4.0D) / 3.0D);
if (l3 < 0) {
l3 = 0;
}
if (this.field_913_j.nextInt(10) == 0) {
++l3;
}
Object obj = new WorldGenTrees(false, 5, 0, 0, false);
int sn3;
for(sn1 = 0; sn1 < l3; ++sn1) {
sn2 = k + this.field_913_j.nextInt(16) + 8;
sn3 = l + this.field_913_j.nextInt(16) + 8;
((WorldGenerator)((WorldGenerator)obj)).setScale(1.0D, 1.0D, 1.0D);
((WorldGenerator)((WorldGenerator)obj)).generate(this.field_907_p, this.field_913_j, sn2, this.field_907_p.getHeightValue(sn2, sn3), sn3);
}
int j19;
for(sn1 = 0; sn1 < 2; ++sn1) {
sn2 = k + this.field_913_j.nextInt(16) + 8;
sn3 = this.field_913_j.nextInt(128);
j19 = l + this.field_913_j.nextInt(16) + 8;
(new WorldGenFlowers(Blocks.yellow_flower)).generate(this.field_907_p, this.field_913_j, sn2, sn3, j19);
}
if (this.field_913_j.nextInt(2) == 0) {
sn1 = k + this.field_913_j.nextInt(16) + 8;
sn2 = this.field_913_j.nextInt(128);
sn3 = l + this.field_913_j.nextInt(16) + 8;
(new WorldGenFlowers(Blocks.red_flower)).generate(this.field_907_p, this.field_913_j, sn1, sn2, sn3);
}
{
if (this.field_913_j.nextInt(6) == 0) {
sn1 = k + this.field_913_j.nextInt(16) + 8;
sn2 = this.field_913_j.nextInt(64);
sn3 = l + this.field_913_j.nextInt(16) + 8;
(new WorldGenFlowers(Blocks.brown_mushroom)).generate(this.field_907_p, this.field_913_j, sn1, sn2, sn3);
}
if (this.field_913_j.nextInt(12) == 0) {
sn1 = k + this.field_913_j.nextInt(16) + 8;
sn2 = this.field_913_j.nextInt(64);
sn3 = l + this.field_913_j.nextInt(16) + 8;
(new WorldGenFlowers(Blocks.red_mushroom)).generate(this.field_907_p, this.field_913_j, sn1, sn2, sn3);
}
}
for(sn1 = 0; sn1 < 50; ++sn1) {
sn2 = k + this.field_913_j.nextInt(16) + 8;
sn3 = this.field_913_j.nextInt(this.field_913_j.nextInt(120) + 8);
j19 = l + this.field_913_j.nextInt(16) + 8;
(new WorldGenLiquids(Blocks.flowing_water)).generate(this.field_907_p, this.field_913_j, sn2, sn3, j19);
}
for(sn1 = 0; sn1 < 20; ++sn1) {
sn2 = k + this.field_913_j.nextInt(16) + 8;
sn3 = this.field_913_j.nextInt(this.field_913_j.nextInt(this.field_913_j.nextInt(112) + 8) + 8);
j19 = l + this.field_913_j.nextInt(16) + 8;
(new WorldGenLiquids(Blocks.flowing_lava)).generate(this.field_907_p, this.field_913_j, sn2, sn3, j19);
}
SpawnerAnimals.performWorldGenSpawning(this.field_907_p, biomegenbase, k + 8, l + 8, 16, 16, this.field_913_j);
k += 8;
l += 8;
for(sn1 = 0; sn1 < 16; ++sn1) {
for(sn2 = 0; sn2 < 16; ++sn2) {
sn3 = this.field_907_p.getPrecipitationHeight(k + sn1, l + sn2);
if (this.field_907_p.isBlockFreezable(sn1 + k, sn3 - 1, sn2 + l)) {
this.field_907_p.setBlock(sn1 + k, sn3 - 1, sn2 + l, Blocks.ice, 0, 2);
}
Block b = this.field_907_p.getBlock(sn1 + k, sn3 - 1, sn2 + l);
if (this.field_907_p.func_147478_e(sn1 + k, sn3, sn2 + l, false) && b != Blocks.ice && b != Blocks.water && sn3 > 63) {
this.field_907_p.setBlock(sn1 + k, sn3, sn2 + l, Blocks.snow_layer, 0, 2);
}
}
}
MinecraftForge.EVENT_BUS.post(new Post(ichunkprovider, this.field_907_p, this.field_913_j, i, j, false));
BlockFalling.fallInstantly = false;
}
public boolean saveChunks(boolean par1, IProgressUpdate par2IProgressUpdate) {
return true;
}
public boolean unloadQueuedChunks() {
return false;
}
public boolean unload100OldestChunks() {
return false;
}
public boolean canSave() {
return true;
}
public String makeString() {
return "RandomLevelSource";
}
public List getPossibleCreatures(EnumCreatureType par1EnumCreatureType, int par2, int par3, int par4) {
BiomeGenBase var5 = this.field_907_p.getBiomeGenForCoords(par2, par4);
return var5 == null ? null : var5.getSpawnableList(par1EnumCreatureType);
}
public ChunkPosition func_147416_a(World par1World, String par2Str, int par3, int par4, int par5) {
return "Stronghold".equals(par2Str) && this.strongholdGenerator != null ? this.strongholdGenerator.func_151545_a(par1World, par3, par4, par5) : null;
}
public int getLoadedChunkCount() {
return 0;
}
public void saveExtraData() {
}
public void recreateStructures(int par1, int par2) {
if (this.mapFeaturesEnabled) {
this.strongholdGenerator.func_151539_a(this, this.field_907_p, par1, par2, (Block[])null);
this.mineshaftGenerator.func_151539_a(this, this.field_907_p, par1, par2, (Block[])null);
}
}
}

View file

@ -0,0 +1,118 @@
package dev.tilera.cwg.infdev;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import net.minecraft.world.gen.feature.WorldGenerator;
public class GenMinable extends WorldGenerator {
private Block minableBlock;
private int numberOfBlocks;
private int generatortype;
public GenMinable(Block b, int j, int type) {
this.minableBlock = b;
this.numberOfBlocks = j;
this.generatortype = type;
}
@Override
public boolean generate(World world, Random random, int i, int j, int k) {
float f;
double d;
double d1;
double d2;
double d3;
double d4;
double d5;
int l;
double d6;
double d7;
double d8;
double d9;
double d10;
double d11;
int i1;
int j1;
int k1;
if (this.generatortype != 0 && this.generatortype != 1) {
f = random.nextFloat() * 3.141593F;
d = (double)((float)(i + 8) + MathHelper.sin(f) * (float)this.numberOfBlocks / 8.0F);
d1 = (double)((float)(i + 8) - MathHelper.sin(f) * (float)this.numberOfBlocks / 8.0F);
d2 = (double)((float)(k + 8) + MathHelper.cos(f) * (float)this.numberOfBlocks / 8.0F);
d3 = (double)((float)(k + 8) - MathHelper.cos(f) * (float)this.numberOfBlocks / 8.0F);
d4 = (double)(j + random.nextInt(3) + 2);
d5 = (double)(j + random.nextInt(3) + 2);
for(l = 0; l <= this.numberOfBlocks; ++l) {
d6 = d + (d1 - d) * (double)l / (double)this.numberOfBlocks;
d7 = d4 + (d5 - d4) * (double)l / (double)this.numberOfBlocks;
d8 = d2 + (d3 - d2) * (double)l / (double)this.numberOfBlocks;
d9 = random.nextDouble() * (double)this.numberOfBlocks / 16.0D;
d10 = (double)(MathHelper.sin((float)l * 3.141593F / (float)this.numberOfBlocks) + 1.0F) * d9 + 1.0D;
d11 = (double)(MathHelper.sin((float)l * 3.141593F / (float)this.numberOfBlocks) + 1.0F) * d9 + 1.0D;
i1 = MathHelper.floor_double(d6 - d10 / 2.0D);
j1 = MathHelper.floor_double(d7 - d11 / 2.0D);
k1 = MathHelper.floor_double(d8 - d10 / 2.0D);
int l1 = MathHelper.floor_double(d6 + d10 / 2.0D);
int i2 = MathHelper.floor_double(d7 + d11 / 2.0D);
int j2 = MathHelper.floor_double(d8 + d10 / 2.0D);
for(int k2 = i1; k2 <= l1; ++k2) {
double d12 = ((double)k2 + 0.5D - d6) / (d10 / 2.0D);
if (!(d12 * d12 >= 1.0D)) {
for(int l2 = j1; l2 <= i2; ++l2) {
double d13 = ((double)l2 + 0.5D - d7) / (d11 / 2.0D);
if (!(d12 * d12 + d13 * d13 >= 1.0D)) {
for(int i3 = k1; i3 <= j2; ++i3) {
double d14 = ((double)i3 + 0.5D - d8) / (d10 / 2.0D);
if (d12 * d12 + d13 * d13 + d14 * d14 < 1.0D && world.getBlock(k2, l2, i3) == Blocks.stone) {
world.setBlock(k2, l2, i3, this.minableBlock);
}
}
}
}
}
}
}
return true;
} else {
f = random.nextFloat() * 3.141593F;
d = (double)((float)(i + 8) + MathHelper.sin(f) * (float)this.numberOfBlocks / 8.0F);
d1 = (double)((float)(i + 8) - MathHelper.sin(f) * (float)this.numberOfBlocks / 8.0F);
d2 = (double)((float)(k + 8) + MathHelper.cos(f) * (float)this.numberOfBlocks / 8.0F);
d3 = (double)((float)(k + 8) - MathHelper.cos(f) * (float)this.numberOfBlocks / 8.0F);
d4 = (double)(j + random.nextInt(3) + 2);
d5 = (double)(j + random.nextInt(3) + 2);
for(l = 0; l <= this.numberOfBlocks; ++l) {
d6 = d + (d1 - d) * (double)l / (double)this.numberOfBlocks;
d7 = d4 + (d5 - d4) * (double)l / (double)this.numberOfBlocks;
d8 = d2 + (d3 - d2) * (double)l / (double)this.numberOfBlocks;
d9 = random.nextDouble() * (double)this.numberOfBlocks / 16.0D;
d10 = (double)(MathHelper.sin((float)l * 3.141593F / (float)this.numberOfBlocks) + 1.0F) * d9 + 1.0D;
d11 = (double)(MathHelper.sin((float)l * 3.141593F / (float)this.numberOfBlocks) + 1.0F) * d9 + 1.0D;
for(i1 = (int)(d6 - d10 / 2.0D); i1 <= (int)(d6 + d10 / 2.0D); ++i1) {
for(j1 = (int)(d7 - d11 / 2.0D); j1 <= (int)(d7 + d11 / 2.0D); ++j1) {
for(k1 = (int)(d8 - d10 / 2.0D); k1 <= (int)(d8 + d10 / 2.0D); ++k1) {
double d12 = ((double)i1 + 0.5D - d6) / (d10 / 2.0D);
double d13 = ((double)j1 + 0.5D - d7) / (d11 / 2.0D);
d12 = ((double)k1 + 0.5D - d8) / (d10 / 2.0D);
if (d12 * d12 + d13 * d13 + d12 * d12 < 1.0D && world.getBlock(i1, j1, k1) == Blocks.stone) {
world.setBlock(i1, j1, k1, this.minableBlock);
}
}
}
}
}
return true;
}
}
}

View file

@ -0,0 +1,42 @@
package dev.tilera.cwg.infdev;
import dev.tilera.cwg.DelegateChunkManager;
import dev.tilera.cwg.api.generator.AbstractChunkManager;
import dev.tilera.cwg.api.generator.IChunkManagerFactory;
import dev.tilera.cwg.api.hooks.IHookProvider;
import dev.tilera.cwg.api.options.IGeneratorOptionProvider;
import dev.tilera.cwg.api.options.IOption;
import dev.tilera.cwg.biome.Biomes;
import dev.tilera.cwg.hooks.ICavegenHook;
import net.minecraft.world.World;
import net.minecraft.world.biome.WorldChunkManagerHell;
import net.minecraft.world.gen.MapGenBase;
public class InfdevChunkManagerFactory implements IChunkManagerFactory {
@Override
public AbstractChunkManager createChunkManager(IGeneratorOptionProvider options, World world) {
MapGenBase caveGen = options.getValue("cwg:cavegen_hook", IHookProvider.class).getHook(ICavegenHook.class).createCaveGenerator();
return new DelegateChunkManager(
options,
new ChunkGeneratorInfdev(world, world.getSeed(), world.getWorldInfo().isMapFeaturesEnabled(), caveGen),
new WorldChunkManagerHell(Biomes.classic, 0.5f)
);
}
@Override
public String getID() {
return "cwg:infdev";
}
@Override
public String getDisplayName() {
return "Infdev";
}
@Override
public boolean hasSpecificOption(IOption<?> option) {
return false;
}
}

View file

@ -0,0 +1,51 @@
package dev.tilera.cwg.infdev;
import java.util.Random;
import net.minecraft.world.gen.NoiseGenerator;
public class NoiseOctavesInfdev extends NoiseGenerator {
private NoisePerlinInfdev[] field_1192_a;
private int field_1191_b;
public NoiseOctavesInfdev(Random random, int i) {
this.field_1191_b = i;
this.field_1192_a = new NoisePerlinInfdev[i];
for(int j = 0; j < i; ++j) {
this.field_1192_a[j] = new NoisePerlinInfdev(random);
}
}
public double func_806_a(double d, double d1) {
double d2 = 0.0D;
double d3 = 1.0D;
for(int i = 0; i < this.field_1191_b; ++i) {
d2 += this.field_1192_a[i].func_801_a(d * d3, d1 * d3) / d3;
d3 /= 2.0D;
}
return d2;
}
public double[] func_807_a(double[] ad, double d, double d1, double d2, int i, int j, int k, double d3, double d4, double d5) {
if (ad == null) {
ad = new double[i * j * k];
} else {
for(int l = 0; l < ad.length; ++l) {
ad[l] = 0.0D;
}
}
double d6 = 1.0D;
for(int i1 = 0; i1 < this.field_1191_b; ++i1) {
this.field_1192_a[i1].func_805_a(ad, d, d1, d2, i, j, k, d3 * d6, d4 * d6, d5 * d6, d6);
d6 /= 2.0D;
}
return ad;
}
}

View file

@ -0,0 +1,153 @@
package dev.tilera.cwg.infdev;
import java.util.Random;
import net.minecraft.world.gen.NoiseGenerator;
public class NoisePerlinInfdev extends NoiseGenerator {
private int[] field_1189_d;
public double field_1188_a;
public double field_1187_b;
public double field_1190_c;
public NoisePerlinInfdev() {
this(new Random());
}
public NoisePerlinInfdev(Random random) {
this.field_1189_d = new int[512];
this.field_1188_a = random.nextDouble() * 256.0D;
this.field_1187_b = random.nextDouble() * 256.0D;
this.field_1190_c = random.nextDouble() * 256.0D;
int j;
for(j = 0; j < 256; this.field_1189_d[j] = j++) {
}
for(j = 0; j < 256; ++j) {
int k = random.nextInt(256 - j) + j;
int l = this.field_1189_d[j];
this.field_1189_d[j] = this.field_1189_d[k];
this.field_1189_d[k] = l;
this.field_1189_d[j + 256] = this.field_1189_d[j];
}
}
public double func_802_a(double d, double d1, double d2) {
double d3 = d + this.field_1188_a;
double d4 = d1 + this.field_1187_b;
double d5 = d2 + this.field_1190_c;
int i = (int)d3;
int j = (int)d4;
int k = (int)d5;
if (d3 < (double)i) {
--i;
}
if (d4 < (double)j) {
--j;
}
if (d5 < (double)k) {
--k;
}
int l = i & 255;
int i1 = j & 255;
int j1 = k & 255;
d3 -= (double)i;
d4 -= (double)j;
d5 -= (double)k;
double d6 = d3 * d3 * d3 * (d3 * (d3 * 6.0D - 15.0D) + 10.0D);
double d7 = d4 * d4 * d4 * (d4 * (d4 * 6.0D - 15.0D) + 10.0D);
double d8 = d5 * d5 * d5 * (d5 * (d5 * 6.0D - 15.0D) + 10.0D);
int k1 = this.field_1189_d[l] + i1;
int l1 = this.field_1189_d[k1] + j1;
int i2 = this.field_1189_d[k1 + 1] + j1;
int j2 = this.field_1189_d[l + 1] + i1;
int k2 = this.field_1189_d[j2] + j1;
int l2 = this.field_1189_d[j2 + 1] + j1;
return this.func_804_b(d8, this.func_804_b(d7, this.func_804_b(d6, this.func_803_a(this.field_1189_d[l1], d3, d4, d5), this.func_803_a(this.field_1189_d[k2], d3 - 1.0D, d4, d5)), this.func_804_b(d6, this.func_803_a(this.field_1189_d[i2], d3, d4 - 1.0D, d5), this.func_803_a(this.field_1189_d[l2], d3 - 1.0D, d4 - 1.0D, d5))), this.func_804_b(d7, this.func_804_b(d6, this.func_803_a(this.field_1189_d[l1 + 1], d3, d4, d5 - 1.0D), this.func_803_a(this.field_1189_d[k2 + 1], d3 - 1.0D, d4, d5 - 1.0D)), this.func_804_b(d6, this.func_803_a(this.field_1189_d[i2 + 1], d3, d4 - 1.0D, d5 - 1.0D), this.func_803_a(this.field_1189_d[l2 + 1], d3 - 1.0D, d4 - 1.0D, d5 - 1.0D))));
}
public double func_804_b(double d, double d1, double d2) {
return d1 + d * (d2 - d1);
}
public double func_803_a(int i, double d, double d1, double d2) {
int j = i & 15;
double d3 = j >= 8 ? d1 : d;
double d4 = j >= 4 ? (j != 12 && j != 14 ? d2 : d) : d1;
return ((j & 1) != 0 ? -d3 : d3) + ((j & 2) != 0 ? -d4 : d4);
}
public double func_801_a(double d, double d1) {
return this.func_802_a(d, d1, 0.0D);
}
public void func_805_a(double[] ad, double d, double d1, double d2, int i, int j, int k, double d3, double d4, double d5, double d6) {
int l = 0;
double d7 = 1.0D / d6;
int i1 = -1;
double d8 = 0.0D;
double d9 = 0.0D;
double d10 = 0.0D;
double d11 = 0.0D;
for(int l2 = 0; l2 < i; ++l2) {
double d12 = (d + (double)l2) * d3 + this.field_1188_a;
int i3 = (int)d12;
if (d12 < (double)i3) {
--i3;
}
int j3 = i3 & 255;
d12 -= (double)i3;
double d13 = d12 * d12 * d12 * (d12 * (d12 * 6.0D - 15.0D) + 10.0D);
for(int k3 = 0; k3 < k; ++k3) {
double d14 = (d2 + (double)k3) * d5 + this.field_1190_c;
int l3 = (int)d14;
if (d14 < (double)l3) {
--l3;
}
int i4 = l3 & 255;
d14 -= (double)l3;
double d15 = d14 * d14 * d14 * (d14 * (d14 * 6.0D - 15.0D) + 10.0D);
for(int j4 = 0; j4 < j; ++j4) {
double d16 = (d1 + (double)j4) * d4 + this.field_1187_b;
int k4 = (int)d16;
if (d16 < (double)k4) {
--k4;
}
int l4 = k4 & 255;
d16 -= (double)k4;
double d17 = d16 * d16 * d16 * (d16 * (d16 * 6.0D - 15.0D) + 10.0D);
if (j4 == 0 || l4 != i1) {
i1 = l4;
int j1 = this.field_1189_d[j3] + l4;
int k1 = this.field_1189_d[j1] + i4;
int l1 = this.field_1189_d[j1 + 1] + i4;
int i2 = this.field_1189_d[j3 + 1] + l4;
int j2 = this.field_1189_d[i2] + i4;
int k2 = this.field_1189_d[i2 + 1] + i4;
d8 = this.func_804_b(d13, this.func_803_a(this.field_1189_d[k1], d12, d16, d14), this.func_803_a(this.field_1189_d[j2], d12 - 1.0D, d16, d14));
d9 = this.func_804_b(d13, this.func_803_a(this.field_1189_d[l1], d12, d16 - 1.0D, d14), this.func_803_a(this.field_1189_d[k2], d12 - 1.0D, d16 - 1.0D, d14));
d10 = this.func_804_b(d13, this.func_803_a(this.field_1189_d[k1 + 1], d12, d16, d14 - 1.0D), this.func_803_a(this.field_1189_d[j2 + 1], d12 - 1.0D, d16, d14 - 1.0D));
d11 = this.func_804_b(d13, this.func_803_a(this.field_1189_d[l1 + 1], d12, d16 - 1.0D, d14 - 1.0D), this.func_803_a(this.field_1189_d[k2 + 1], d12 - 1.0D, d16 - 1.0D, d14 - 1.0D));
}
double d18 = this.func_804_b(d17, d8, d9);
double d19 = this.func_804_b(d17, d10, d11);
double d20 = this.func_804_b(d15, d18, d19);
int var10001 = l++;
ad[var10001] += d20 * d7;
}
}
}
}
}