2015-08-29 14:33:25 +02:00
/ *
* This file ( " OreGen.java " ) is part of the Actually Additions Mod for Minecraft .
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http : //github.com/Ellpeck/ActuallyAdditions/blob/master/README.md
* View the source code at https : //github.com/Ellpeck/ActuallyAdditions
*
* <EFBFBD> 2015 Ellpeck
* /
2015-03-07 12:51:28 +01:00
package ellpeck.actuallyadditions.gen ;
2014-11-10 16:47:04 +01:00
2015-02-17 16:15:16 +01:00
import cpw.mods.fml.common.IWorldGenerator ;
import cpw.mods.fml.common.registry.GameRegistry ;
2015-03-08 14:58:26 +01:00
import ellpeck.actuallyadditions.blocks.InitBlocks ;
import ellpeck.actuallyadditions.blocks.metalists.TheMiscBlocks ;
2015-04-24 19:22:03 +02:00
import ellpeck.actuallyadditions.config.values.ConfigBoolValues ;
import ellpeck.actuallyadditions.config.values.ConfigIntValues ;
2015-03-29 15:29:05 +02:00
import ellpeck.actuallyadditions.util.ModUtil ;
2015-02-17 16:15:16 +01:00
import net.minecraft.block.Block ;
2015-03-08 14:58:26 +01:00
import net.minecraft.init.Blocks ;
2015-06-29 20:55:56 +02:00
import net.minecraft.util.MathHelper ;
2014-11-10 16:47:04 +01:00
import net.minecraft.world.World ;
2015-08-02 06:55:32 +02:00
import net.minecraft.world.WorldType ;
2014-11-10 16:47:04 +01:00
import net.minecraft.world.chunk.IChunkProvider ;
import net.minecraft.world.gen.feature.WorldGenMinable ;
import java.util.Random ;
2015-02-09 17:25:05 +01:00
public class OreGen implements IWorldGenerator {
2014-11-10 16:47:04 +01:00
2015-10-03 10:16:18 +02:00
public static void init ( ) {
ModUtil . LOGGER . info ( " Registering World Generator... " ) ;
GameRegistry . registerWorldGenerator ( new OreGen ( ) , 10 ) ;
}
2015-02-20 22:45:33 +01:00
@Override
2014-11-10 16:47:04 +01:00
public void generate ( Random random , int chunkX , int chunkZ , World world , IChunkProvider chunkGenerator , IChunkProvider chunkProvider ) {
2015-10-03 10:16:18 +02:00
if ( world . provider . terrainType = = WorldType . FLAT ) {
return ;
}
2015-08-02 06:55:32 +02:00
2015-06-28 12:42:38 +02:00
switch ( world . provider . dimensionId ) {
2014-11-10 16:47:04 +01:00
case - 1 :
2014-11-19 18:01:44 +01:00
generateNether ( world , random , chunkX * 16 , chunkZ * 16 ) ;
2015-10-02 16:48:01 +02:00
//case 0:
// generateSurface(world, random, chunkX*16, chunkZ*16);
2014-11-10 16:47:04 +01:00
case 1 :
2014-11-19 18:01:44 +01:00
generateEnd ( world , random , chunkX * 16 , chunkZ * 16 ) ;
2015-06-28 12:42:38 +02:00
default :
generateSurface ( world , random , chunkX * 16 , chunkZ * 16 ) ;
2014-11-10 16:47:04 +01:00
}
}
2015-10-03 10:19:40 +02:00
@SuppressWarnings ( " unused " )
private void generateNether ( World world , Random random , int x , int z ) {
}
2014-11-10 16:47:04 +01:00
@SuppressWarnings ( " unused " )
private void generateEnd ( World world , Random random , int x , int z ) {
}
private void generateSurface ( World world , Random random , int x , int z ) {
2015-06-28 12:42:38 +02:00
if ( ConfigBoolValues . GENERATE_QUARTZ . isEnabled ( ) ) {
2015-06-29 20:55:56 +02:00
this . addOreSpawn ( InitBlocks . blockMisc , TheMiscBlocks . ORE_QUARTZ . ordinal ( ) , Blocks . stone , world , random , x , z , MathHelper . getRandomIntegerInRange ( random , ConfigIntValues . BLACK_QUARTZ_BASE_AMOUNT . getValue ( ) , ConfigIntValues . BLACK_QUARTZ_ADD_CHANCE . getValue ( ) ) , ConfigIntValues . BLACK_QUARTZ_CHANCE . getValue ( ) , ConfigIntValues . BLACK_QUARTZ_MIN_HEIGHT . getValue ( ) , ConfigIntValues . BLACK_QUARTZ_MAX_HEIGHT . getValue ( ) ) ;
2015-06-28 12:42:38 +02:00
}
2014-11-10 16:47:04 +01:00
}
2015-03-08 14:58:26 +01:00
public void addOreSpawn ( Block block , int meta , Block blockIn , World world , Random random , int blockXPos , int blockZPos , int maxVeinSize , int chancesToSpawn , int minY , int maxY ) {
if ( maxY > minY ) {
2015-10-02 16:48:01 +02:00
int yDiff = maxY - minY ;
2015-03-08 14:58:26 +01:00
for ( int i = 0 ; i < chancesToSpawn ; i + + ) {
2015-10-02 16:48:01 +02:00
int posX = blockXPos + random . nextInt ( 16 ) ;
int posY = minY + random . nextInt ( yDiff ) ;
int posZ = blockZPos + random . nextInt ( 16 ) ;
2015-03-08 14:58:26 +01:00
new WorldGenMinable ( block , meta , maxVeinSize , blockIn ) . generate ( world , random , posX , posY , posZ ) ;
}
2014-11-10 16:47:04 +01:00
}
2015-10-02 16:48:01 +02:00
else {
ModUtil . LOGGER . fatal ( " Couldn't generate ' " + block . getUnlocalizedName ( ) + " ' into the world because the Min Y coordinate is bigger than the Max! This is definitely a Config Error! Check the Files! " ) ;
}
2015-03-08 14:58:26 +01:00
}
2014-11-10 16:47:04 +01:00
}