2013-12-27 23:59:59 +01:00
|
|
|
package appeng.helpers;
|
|
|
|
|
|
|
|
import java.util.Random;
|
|
|
|
|
|
|
|
import net.minecraft.block.Block;
|
2014-02-09 02:34:52 +01:00
|
|
|
import net.minecraft.init.Blocks;
|
2013-12-27 23:59:59 +01:00
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
import net.minecraft.world.World;
|
|
|
|
import net.minecraft.world.chunk.IChunkProvider;
|
|
|
|
import net.minecraft.world.gen.feature.WorldGenMinable;
|
|
|
|
import appeng.api.AEApi;
|
2014-02-09 06:08:27 +01:00
|
|
|
import appeng.core.AEConfig;
|
2013-12-27 23:59:59 +01:00
|
|
|
import cpw.mods.fml.common.IWorldGenerator;
|
|
|
|
|
|
|
|
final public class QuartzWorldGen implements IWorldGenerator
|
|
|
|
{
|
|
|
|
|
|
|
|
final WorldGenMinable oreNormal;
|
|
|
|
final WorldGenMinable oreCharged;
|
|
|
|
|
|
|
|
public QuartzWorldGen() {
|
2014-02-09 02:34:52 +01:00
|
|
|
Block normal = AEApi.instance().blocks().blockQuartzOre.block();
|
|
|
|
Block charged = AEApi.instance().blocks().blockQuartzOreCharged.block();
|
|
|
|
|
|
|
|
ItemStack is_normal = AEApi.instance().blocks().blockQuartzOre.stack( 1 );
|
|
|
|
ItemStack is_charged = AEApi.instance().blocks().blockQuartzOreCharged.stack( 1 );
|
2013-12-27 23:59:59 +01:00
|
|
|
|
|
|
|
if ( normal == null || charged == null )
|
|
|
|
{
|
2014-02-09 06:08:27 +01:00
|
|
|
oreNormal = new WorldGenMinable( normal, is_normal.getItemDamage(), AEConfig.instance.oresPerCluster, Blocks.stone );
|
|
|
|
oreCharged = new WorldGenMinable( charged, is_charged.getItemDamage(), AEConfig.instance.oresPerCluster, Blocks.stone );
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
oreNormal = oreCharged = null;
|
|
|
|
};
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void generate(Random r, int chunkX, int chunkZ, World w, IChunkProvider chunkGenerator, IChunkProvider chunkProvider)
|
|
|
|
{
|
|
|
|
int sealevel = w.provider.getAverageGroundLevel() + 1;
|
|
|
|
|
|
|
|
if ( oreNormal == null || oreCharged == null )
|
|
|
|
return;
|
|
|
|
|
|
|
|
double oreDepthMultiplier = 15 * 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)
|
|
|
|
{
|
|
|
|
WorldGenMinable whichOre = r.nextFloat() > 0.92 ? oreCharged : oreNormal;
|
|
|
|
int a = chunkX * 16 + r.nextInt( 22 );
|
|
|
|
int b = r.nextInt( 40 * sealevel / 64 ) + r.nextInt( 22 * sealevel / 64 ) + 12 * sealevel / 64;
|
|
|
|
int c = chunkZ * 16 + r.nextInt( 22 );
|
|
|
|
whichOre.generate( w, r, a, b, c );
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|