2014-11-14 12:02:52 +01:00
|
|
|
/*
|
|
|
|
* This file is part of Applied Energistics 2.
|
|
|
|
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
|
|
|
*
|
|
|
|
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
|
|
|
*/
|
|
|
|
|
2015-01-03 02:53:14 +01:00
|
|
|
package appeng.worldgen;
|
|
|
|
|
2014-03-02 09:35:11 +01:00
|
|
|
|
|
|
|
import java.util.Random;
|
|
|
|
|
|
|
|
import net.minecraft.block.Block;
|
|
|
|
import net.minecraft.init.Blocks;
|
|
|
|
import net.minecraft.world.World;
|
|
|
|
import net.minecraft.world.chunk.IChunkProvider;
|
|
|
|
import net.minecraft.world.gen.feature.WorldGenMinable;
|
2014-12-29 21:59:05 +01:00
|
|
|
|
|
|
|
import cpw.mods.fml.common.IWorldGenerator;
|
|
|
|
|
2014-03-02 09:35:11 +01:00
|
|
|
import appeng.api.AEApi;
|
2015-01-03 02:53:14 +01:00
|
|
|
import appeng.api.definitions.IBlockDefinition;
|
|
|
|
import appeng.api.definitions.IBlocks;
|
2014-08-06 04:03:30 +02:00
|
|
|
import appeng.api.features.IWorldGen.WorldGenType;
|
2014-03-02 09:35:11 +01:00
|
|
|
import appeng.core.AEConfig;
|
2014-08-06 04:03:30 +02:00
|
|
|
import appeng.core.features.registries.WorldGenRegistry;
|
2014-03-02 09:35:11 +01:00
|
|
|
|
2015-01-03 02:53:14 +01:00
|
|
|
|
2015-04-06 00:35:42 +02:00
|
|
|
public final class QuartzWorldGen implements IWorldGenerator
|
2014-03-02 09:35:11 +01:00
|
|
|
{
|
2015-01-03 02:53:14 +01:00
|
|
|
private final WorldGenMinable oreNormal;
|
|
|
|
private final WorldGenMinable oreCharged;
|
2014-03-02 09:35:11 +01:00
|
|
|
|
2015-01-03 02:53:14 +01:00
|
|
|
public QuartzWorldGen()
|
|
|
|
{
|
|
|
|
final IBlocks blocks = AEApi.instance().definitions().blocks();
|
|
|
|
final IBlockDefinition oreDefinition = blocks.quartzOre();
|
|
|
|
final IBlockDefinition chargedDefinition = blocks.quartzOreCharged();
|
2014-03-02 09:35:11 +01:00
|
|
|
|
2015-01-03 02:53:14 +01:00
|
|
|
final Block ore = oreDefinition.maybeBlock().orNull();
|
|
|
|
final Block charged = chargedDefinition.maybeBlock().orNull();
|
2014-03-02 09:35:11 +01:00
|
|
|
|
2015-01-03 02:53:14 +01:00
|
|
|
this.oreNormal = new WorldGenMinable( ore, 0, AEConfig.instance.quartzOresPerCluster, Blocks.stone );
|
|
|
|
this.oreCharged = new WorldGenMinable( charged, 0, AEConfig.instance.quartzOresPerCluster, Blocks.stone );
|
2014-09-28 00:50:06 +02:00
|
|
|
}
|
2014-03-02 09:35:11 +01:00
|
|
|
|
|
|
|
@Override
|
2015-01-03 02:53:14 +01:00
|
|
|
public void generate( Random r, int chunkX, int chunkZ, World w, IChunkProvider chunkGenerator, IChunkProvider chunkProvider )
|
2014-03-02 09:35:11 +01:00
|
|
|
{
|
2014-09-28 11:47:17 +02:00
|
|
|
int seaLevel = w.provider.getAverageGroundLevel() + 1;
|
2014-03-02 09:35:11 +01:00
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
if( seaLevel < 20 )
|
2014-08-16 03:26:16 +02:00
|
|
|
{
|
2015-01-03 02:53:14 +01:00
|
|
|
int x = ( chunkX << 4 ) + 8;
|
|
|
|
int z = ( chunkZ << 4 ) + 8;
|
2014-09-28 11:47:17 +02:00
|
|
|
seaLevel = w.getHeightValue( x, z );
|
2014-08-16 03:26:16 +02:00
|
|
|
}
|
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
if( this.oreNormal == null || this.oreCharged == null )
|
2014-03-02 09:35:11 +01:00
|
|
|
return;
|
|
|
|
|
2014-09-28 11:47:17 +02:00
|
|
|
double oreDepthMultiplier = AEConfig.instance.quartzOresClusterAmount * seaLevel / 64;
|
2014-03-02 09:35:11 +01:00
|
|
|
int scale = (int) Math.round( r.nextGaussian() * Math.sqrt( oreDepthMultiplier ) + oreDepthMultiplier );
|
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
for( int x = 0; x < ( r.nextBoolean() ? scale * 2 : scale ) / 2; ++x )
|
2014-03-02 09:35:11 +01:00
|
|
|
{
|
2014-08-06 04:03:30 +02:00
|
|
|
boolean isCharged = r.nextFloat() > AEConfig.instance.spawnChargedChance;
|
2014-12-29 15:13:47 +01:00
|
|
|
WorldGenMinable whichOre = isCharged ? this.oreCharged : this.oreNormal;
|
2014-08-06 04:03:30 +02:00
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
if( WorldGenRegistry.INSTANCE.isWorldGenEnabled( isCharged ? WorldGenType.ChargedCertusQuartz : WorldGenType.CertusQuartz, w ) )
|
2014-08-06 04:03:30 +02:00
|
|
|
{
|
|
|
|
int cx = chunkX * 16 + r.nextInt( 22 );
|
2014-09-28 11:47:17 +02:00
|
|
|
int cy = r.nextInt( 40 * seaLevel / 64 ) + r.nextInt( 22 * seaLevel / 64 ) + 12 * seaLevel / 64;
|
2014-08-06 04:03:30 +02:00
|
|
|
int cz = chunkZ * 16 + r.nextInt( 22 );
|
|
|
|
whichOre.generate( w, r, cx, cy, cz );
|
|
|
|
}
|
2014-03-02 09:35:11 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|