Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package appeng.worldgen;
- import appeng.api.AEApi;
- import appeng.api.IAppEngApi;
- import appeng.api.definitions.IBlockDefinition;
- import appeng.api.definitions.IBlocks;
- import appeng.api.definitions.IDefinitions;
- import appeng.api.features.IWorldGen.WorldGenType;
- import appeng.core.AEConfig;
- import appeng.core.features.registries.WorldGenRegistry;
- import com.google.common.base.Optional;
- import cpw.mods.fml.common.IWorldGenerator;
- import java.util.Random;
- import net.minecraft.block.Block;
- import net.minecraft.init.Blocks;
- import net.minecraft.world.World;
- import net.minecraft.world.WorldProvider;
- import net.minecraft.world.chunk.IChunkProvider;
- import net.minecraft.world.gen.feature.WorldGenMinable;
- public final class QuartzWorldGen
- implements IWorldGenerator
- {
- private final WorldGenMinable oreNormal;
- private final WorldGenMinable oreCharged;
- public QuartzWorldGen()
- {
- IBlocks blocks = AEApi.instance().definitions().blocks();
- IBlockDefinition oreDefinition = blocks.quartzOre();
- IBlockDefinition chargedDefinition = blocks.quartzOreCharged();
- Block ore = (Block)oreDefinition.maybeBlock().orNull();
- Block charged = (Block)chargedDefinition.maybeBlock().orNull();
- this.oreNormal = new WorldGenMinable(ore, 0, AEConfig.instance.quartzOresPerCluster, Blocks.field_150348_b);
- this.oreCharged = new WorldGenMinable(charged, 0, AEConfig.instance.quartzOresPerCluster, Blocks.field_150348_b);
- }
- public void generate(Random r, int chunkX, int chunkZ, World w, IChunkProvider chunkGenerator, IChunkProvider chunkProvider)
- {
- int seaLevel = w.field_73011_w.func_76557_i() + 1;
- if (seaLevel < 20)
- {
- int x = (chunkX << 4) + 8;
- int z = (chunkZ << 4) + 8;
- seaLevel = w.func_72976_f(x, z);
- }
- if ((this.oreNormal == null) || (this.oreCharged == null)) {
- return;
- }
- double oreDepthMultiplier = AEConfig.instance.quartzOresClusterAmount * seaLevel / 64;
- int scale = (int)Math.round(r.nextGaussian() * Math.sqrt(oreDepthMultiplier) + oreDepthMultiplier);
- for (int x = 0; x < (r.nextBoolean() ? scale * 2 : scale) / 2; x++)
- {
- boolean isCharged = r.nextFloat() > AEConfig.instance.spawnChargedChance;
- WorldGenMinable whichOre = isCharged ? this.oreCharged : this.oreNormal;
- if (WorldGenRegistry.INSTANCE.isWorldGenEnabled(isCharged ? IWorldGen.WorldGenType.ChargedCertusQuartz : IWorldGen.WorldGenType.CertusQuartz, w))
- {
- int cx = chunkX * 16 + r.nextInt(22);
- int cy = r.nextInt(40 * seaLevel / 64) + r.nextInt(22 * seaLevel / 64) + 12 * seaLevel / 64;
- int cz = chunkZ * 16 + r.nextInt(22);
- whichOre.func_76484_a(w, r, cx, cy, cz);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement