Java Code Examples for net.minecraft.world.gen.feature.WorldGenMinable#generate()

The following examples show how to use net.minecraft.world.gen.feature.WorldGenMinable#generate() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OreGenerator.java    From EmergingTechnology with MIT License 6 votes vote down vote up
public void addOreSpawn(Block block, byte blockMeta, Block targetBlock, World world, Random random, int blockXPos,
        int blockZPos, int minVeinSize, int maxVeinSize, int chancesToSpawn, int minY, int maxY, boolean restrictBiome) {
    WorldGenMinable minable = new WorldGenMinable(block.getStateFromMeta(blockMeta),
            (minVeinSize + random.nextInt(maxVeinSize - minVeinSize + 1)), BlockStateMatcher.forBlock(targetBlock));
    for (int i = 0; i < chancesToSpawn; i++) {
        int posX = blockXPos + random.nextInt(16);
        int posY = minY + random.nextInt(maxY - minY);
        int posZ = blockZPos + random.nextInt(16);

        BlockPos plannedPosition = new BlockPos(posX, posY, posZ);

        Biome blockBiome = world.getBiome(plannedPosition);

        for (Biome biome : validBiomes) {
            if (biome == blockBiome || !restrictBiome) {
                minable.generate(world, random, new BlockPos(posX, posY, posZ));
                break;
            }
        }
    }
}
 
Example 2
Source File: GTOreGenerator.java    From GT-Classic with GNU Lesser General Public License v3.0 6 votes vote down vote up
/** rare ore generator **/
public static void generateRareVein(Block block, boolean generate, int blockAmount, int chancesToSpawn,
		int minHeight, int maxHeight, Block blockToReplace, World world, Random rand, int chunkX, int chunkZ) {
	if (generate) {
		WorldGenMinable generator = new WorldGenMinable(block.getDefaultState(), blockAmount, BlockMatcher.forBlock(blockToReplace));
		int heightdiff = maxHeight - minHeight + 1;
		for (int i = 0; i < chancesToSpawn; i++) {
			int var1 = rand.nextInt(1024);
			if (var1 == 0) {
				int x = chunkX * 16 + rand.nextInt(16);
				int y = minHeight + rand.nextInt(heightdiff);
				int z = chunkZ * 16 + rand.nextInt(16);
				generator.generate(world, rand, new BlockPos(x, y, z));
			}
		}
	}
}
 
Example 3
Source File: GTOreGenerator.java    From GT-Classic with GNU Lesser General Public License v3.0 5 votes vote down vote up
/** default ore generator **/
public static void generateBasicVein(Block block, boolean generate, int blockAmount, int chancesToSpawn,
		int minHeight, int maxHeight, Block blockToReplace, World world, Random rand, int chunkX, int chunkZ) {
	if (generate) {
		WorldGenMinable generator = new WorldGenMinable(block.getDefaultState(), blockAmount, BlockMatcher.forBlock(blockToReplace));
		int heightdiff = maxHeight - minHeight + 1;
		for (int i = 0; i < chancesToSpawn; i++) {
			int x = chunkX * 16 + rand.nextInt(16);
			int y = minHeight + rand.nextInt(heightdiff);
			int z = chunkZ * 16 + rand.nextInt(16);
			generator.generate(world, rand, new BlockPos(x, y, z));
		}
	}
}
 
Example 4
Source File: OreGenerator.java    From YouTubeModdingTutorial with MIT License 5 votes vote down vote up
public void addOreSpawn(Block block, byte blockMeta, Block targetBlock, World world, Random random, int blockXPos, int blockZPos, int minVeinSize, int maxVeinSize, int chancesToSpawn, int minY, int maxY) {
    WorldGenMinable minable = new WorldGenMinable(block.getStateFromMeta(blockMeta), (minVeinSize + random.nextInt(maxVeinSize - minVeinSize + 1)), BlockMatcher.forBlock(targetBlock));
    for (int i = 0 ; i < chancesToSpawn ; i++) {
        int posX = blockXPos + random.nextInt(16);
        int posY = minY + random.nextInt(maxY - minY);
        int posZ = blockZPos + random.nextInt(16);
        minable.generate(world, random, new BlockPos(posX, posY, posZ));
    }
}
 
Example 5
Source File: GeneratorChisel.java    From Chisel-2 with GNU General Public License v2.0 5 votes vote down vote up
protected void genStandardOre(WorldGenMinable gen, WorldGenInfo info, World world, Random random, int x, int z) {
	for (int l = 0; l < info.amount; ++l) {
		if (random.nextDouble() < info.chance) {
			int avgX = x + random.nextInt(16);
			int avgY = info.minY + random.nextInt(info.maxY - info.minY) + 1;
			int avgZ = z + random.nextInt(16);
			gen.generate(world, random, avgX, avgY, avgZ);
		}
	}
}