-
-
Save saxbophone/0454b154806dd2d16b10fd2aa604335b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 y = minHeight + rand.nextInt(heightDiff); | |
generator.generate(world, rand, new BlockPos(chunk_X * 16, y, chunk_Z * 16)); | |
} | |
} | |
@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