ActuallyAdditions/src/main/java/de/ellpeck/actuallyadditions/gen/OreGen.java

88 lines
3.5 KiB
Java
Raw Normal View History

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
2016-01-03 16:05:51 +01:00
* http://ellpeck.de/actaddlicense/
2015-08-29 14:33:25 +02:00
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
2016-01-03 16:05:51 +01:00
* © 2016 Ellpeck
2015-08-29 14:33:25 +02:00
*/
2015-12-30 22:02:15 +01:00
package de.ellpeck.actuallyadditions.gen;
import cpw.mods.fml.common.IWorldGenerator;
import cpw.mods.fml.common.registry.GameRegistry;
2015-12-30 22:02:15 +01:00
import de.ellpeck.actuallyadditions.blocks.InitBlocks;
import de.ellpeck.actuallyadditions.blocks.metalists.TheMiscBlocks;
import de.ellpeck.actuallyadditions.config.ConfigValues;
import de.ellpeck.actuallyadditions.config.values.ConfigBoolValues;
import de.ellpeck.actuallyadditions.util.ModUtil;
import de.ellpeck.actuallyadditions.util.Util;
import net.minecraft.block.Block;
2015-03-08 14:58:26 +01:00
import net.minecraft.init.Blocks;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import net.minecraft.world.WorldType;
import net.minecraft.world.chunk.IChunkProvider;
import net.minecraft.world.gen.feature.WorldGenMinable;
import java.util.Random;
public class OreGen implements IWorldGenerator{
public static final int QUARTZ_MIN = 0;
public static final int QUARTZ_MAX = 45;
2015-10-03 10:16:18 +02:00
public static void init(){
ModUtil.LOGGER.info("Registering World Generator...");
GameRegistry.registerWorldGenerator(new OreGen(), 10);
}
@Override
public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider){
2015-12-20 23:38:24 +01:00
if(world.provider.terrainType != WorldType.FLAT && Util.arrayContains(ConfigValues.oreGenDimensionBlacklist, world.provider.dimensionId) < 0){
switch(world.provider.dimensionId){
case -1:
2015-12-20 23:38:24 +01:00
generateNether(world, random, chunkX*16, chunkZ*16);
//case 0:
// generateSurface(world, random, chunkX*16, chunkZ*16);
case 1:
2015-12-20 23:38:24 +01:00
generateEnd(world, random, chunkX*16, chunkZ*16);
default:
2015-12-20 23:38:24 +01:00
generateSurface(world, random, chunkX*16, chunkZ*16);
}
}
}
2015-10-03 10:19:40 +02:00
@SuppressWarnings("unused")
2015-12-20 23:38:24 +01:00
private void generateNether(World world, Random random, int x, int z){
2015-10-03 10:19:40 +02:00
}
@SuppressWarnings("unused")
2015-12-20 23:38:24 +01:00
private void generateEnd(World world, Random random, int x, int z){
}
2015-12-20 23:38:24 +01:00
private void generateSurface(World world, Random random, int x, int z){
if(ConfigBoolValues.GENERATE_QUARTZ.isEnabled()){
this.addOreSpawn(InitBlocks.blockMisc, TheMiscBlocks.ORE_QUARTZ.ordinal(), Blocks.stone, world, random, x, z, MathHelper.getRandomIntegerInRange(random, 5, 8), 10, QUARTZ_MIN, QUARTZ_MAX);
2015-06-28 12:42:38 +02: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);
}
}
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
}
}