Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.mightydanp.eot.common.world.gen.feature;
- import java.util.Random;
- import com.mightydanp.eot.common.block.ModBlocks;
- import com.mightydanp.eot.common.lib.Reference;
- import com.mightydanp.eot.common.logger.EoTLogger;
- 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.minecraftforge.fml.common.IWorldGenerator;
- public class WorldGenTwigs implements IWorldGenerator {
- @Override
- public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider) {
- if (!world.provider.isSurfaceWorld()) {
- return;
- }
- if (random.nextInt(7) == 0) {
- int posX = (chunkX *16)+8;
- int posY = (world.getActualHeight());
- int posZ = (chunkZ *16)+8;
- for (int i = 0; i < (random.nextInt(8)) + 8; i++) {
- BlockPos pos = new BlockPos(posX + offset(8, random), posY, posZ + offset(8, random));
- if (world.isAirBlock(new BlockPos(posX + offset(8, random), posY, posZ + offset(8, random))) && (!world.provider.getHasNoSky() || pos.getY() < 255) && ModBlocks.twigs.canPlaceBlockAt(world, new BlockPos(posX, posY, posZ))) {
- EoTLogger.logInfoMessage(Reference.MODID + ":" + "Generating Twigs:"+ " X:" + pos.getX() + " Y:" + pos.getY() + " Z:" + pos.getZ());
- world.setBlockState(pos, ModBlocks.twigs.getDefaultState());
- }
- }
- }
- }
- public int offset(int bound, Random rand) {
- return rand.nextInt(bound * 2) - bound;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement