Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package blacksmith.world.gen;
- import java.util.Random;
- import net.minecraft.block.Block;
- import net.minecraft.world.World;
- import net.minecraft.world.chunk.IChunkProvider;
- import net.minecraft.world.gen.feature.WorldGenMinable;
- import blacksmith.BlacksmithMod;
- import blacksmith.block.Ore;
- import cpw.mods.fml.common.IWorldGenerator;
- public class WorldGeneratorManager implements IWorldGenerator {
- @Override
- public void generate(Random random, int chunkX, int chunkZ, World world,
- IChunkProvider chunkGenerator, IChunkProvider chunkProvider) {
- switch (world.provider.dimensionId) {
- case -1:
- generateNether(world, random, chunkX * 16, chunkZ * 16);
- case 0:
- generateOverworld(world, random, chunkX * 16, chunkZ * 16);
- case 1:
- generateEnd(world, random, chunkX * 16, chunkZ * 16);
- }
- }
- private void generateEnd(World world, Random random, int chunkX, int chunkZ) {
- // TODO Auto-generated method stub
- }
- private void generateNether(World world, Random random, int chunkX, int chunkZ) {
- // TODO Auto-generated method stub
- }
- private void generateOverworld(World world, Random random, int chunkX, int chunkZ) {
- this.addOreSpawn(BlacksmithMod.ores, 5, world, random, chunkX, chunkZ, 16, 16,
- 4 + random.nextInt(3), 5, 15, 50);
- }
- public void addOreSpawn(Block block, World world, Random random, int blockXPos,
- int blockZPos, int maxX, int maxZ, int maxVeinSize, int chancesToSpawn,
- int minY, int maxY) {
- int maxPosY = minY + (maxY - 1);
- assert maxY > minY : "The maximum Y must be greater than the Minimum Y";
- assert maxX > 0 && maxX <= 16 : "addOreSpawn: The Maximum X must be greater than 0 and less than 16";
- assert minY > 0 : "addOreSpawn: The Minimum Y must be greater than 0";
- assert maxY < 256 && maxY > 0 : "addOreSpawn: The Maximum Y must be less than 256 but greater than 0";
- assert maxZ > 0 && maxZ <= 16 : "addOreSpawn: The Maximum Z must be greater than 0 and less than 16";
- for (int x = 0; x < chancesToSpawn; x++) {
- int posX = blockXPos + random.nextInt(maxX);
- int posY = minY + random.nextInt(maxY - minY);
- int posZ = blockZPos + random.nextInt(maxZ);
- (new WorldGenMinable(block.blockID, maxVeinSize)).generate(world, random,
- posX, posY, posZ);
- }
- }
- public void addOreSpawn(Block multiBlock, int subBlockId, World world, Random random,
- int blockXPos, int blockZPos, int maxX, int maxZ, int maxVeinSize,
- int chancesToSpawn, int minY, int maxY) {
- Block subBlock = BlacksmithMod.ores;
- addOreSpawn(subBlock, world, random, blockXPos, blockZPos, maxX, maxZ, maxVeinSize,
- chancesToSpawn, minY, maxY);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement