Skip to content

Instantly share code, notes, and snippets.

@ThexXTURBOXx
Created June 2, 2017 20:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ThexXTURBOXx/c4ed6ab9920b2d9bddd75645c1df218a to your computer and use it in GitHub Desktop.
Save ThexXTURBOXx/c4ed6ab9920b2d9bddd75645c1df218a to your computer and use it in GitHub Desktop.
package de.Femtopedia.XYCraftRL;
import java.util.Random;
import net.minecraft.block.state.pattern.BlockMatcher;
import net.minecraft.init.Blocks;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.chunk.IChunkGenerator;
import net.minecraft.world.chunk.IChunkProvider;
import net.minecraft.world.gen.feature.WorldGenMinable;
import net.minecraft.world.gen.feature.WorldGenerator;
import net.minecraftforge.fml.common.IWorldGenerator;
public class WorldGeneratorXYCraftRL implements IWorldGenerator {
private WorldGenMinable gen_black_xy_ore;
private WorldGenMinable gen_blue_xy_ore;
private WorldGenMinable gen_green_xy_ore;
private WorldGenMinable gen_red_xy_ore;
private WorldGenMinable gen_white_xy_ore;
private WorldGenMinable gen_aluminum_ore;
private WorldGenMinable gen_draconite_ore;
private WorldGenMinable gen_draconite_ore_end;
private WorldGenMinable gen_draconite_ore_nether;
public WorldGeneratorXYCraftRL() {
gen_black_xy_ore = new WorldGenMinable(Main.blockBlackOreCrystal.getDefaultState(), 3);
gen_blue_xy_ore = new WorldGenMinable(Main.blockBlueOreCrystal.getDefaultState(), 3);
gen_green_xy_ore = new WorldGenMinable(Main.blockGreenOreCrystal.getDefaultState(), 3);
gen_red_xy_ore = new WorldGenMinable(Main.blockRedOreCrystal.getDefaultState(), 3);
gen_white_xy_ore = new WorldGenMinable(Main.blockWhiteOreCrystal.getDefaultState(), 3);
gen_aluminum_ore = new WorldGenMinable(Main.blockWhiteOreCrystal.getDefaultState(), 3);
gen_draconite_ore = new WorldGenMinable(Main.blockDraconiteOre.getDefaultState(), 3);
gen_draconite_ore_end = new WorldGenMinable(Main.blockDraconiteOre.getDefaultState(), 3, BlockMatcher.forBlock(Blocks.END_STONE));
gen_draconite_ore_nether = new WorldGenMinable(Main.blockDraconiteOre.getDefaultState(), 3, BlockMatcher.forBlock(Blocks.NETHERRACK));
}
private void runGenerator(WorldGenerator generator, World world, Random rand, int chunk_X, int chunk_Z, int chancesToSpawn, int minHeight, int maxHeight) {
if (minHeight < 0 || maxHeight > 256 || minHeight > maxHeight)
throw new IllegalArgumentException("Illegal Height Arguments for WorldGenerator");
int heightDiff = maxHeight - minHeight + 1;
for (int i = 0; i < chancesToSpawn; i ++) {
int x = chunk_X * 16 + rand.nextInt(16);
int y = minHeight + rand.nextInt(heightDiff);
int z = chunk_Z * 16 + rand.nextInt(16);
generator.generate(world, rand, new BlockPos(x, y, z));
}
}
@Override
public void generate(Random rand, int chunk_X, int chunk_Z, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider) {
switch (world.provider.getDimensionType()) {
case NETHER:
runGenerator(gen_draconite_ore_nether, world, rand, chunk_X, chunk_Z, 75, 10, 128);
break;
case OVERWORLD:
runGenerator(gen_black_xy_ore, world, rand, chunk_X, chunk_Z, 75, 10, 128);
runGenerator(gen_blue_xy_ore, world, rand, chunk_X, chunk_Z, 75, 10, 128);
runGenerator(gen_green_xy_ore, world, rand, chunk_X, chunk_Z, 75, 10, 128);
runGenerator(gen_red_xy_ore, world, rand, chunk_X, chunk_Z, 75, 10, 128);
runGenerator(gen_white_xy_ore, world, rand, chunk_X, chunk_Z, 75, 10, 128);
runGenerator(gen_aluminum_ore, world, rand, chunk_X, chunk_Z, 15, 10, 128);
runGenerator(gen_draconite_ore, world, rand, chunk_X, chunk_Z, 5, 10, 128);
break;
case THE_END:
runGenerator(gen_draconite_ore_end, world, rand, chunk_X, chunk_Z, 75, 10, 128);
break;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment