Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.JohnnyMccrum.JohnnyBaseMod.Structure;
- import com.JohnnyMccrum.JohnnyBaseMod.init.ModBlocks;
- import java.util.Random;
- import net.minecraft.block.Block;
- import net.minecraft.block.material.Material;
- import net.minecraft.init.Blocks;
- import net.minecraft.world.World;
- import net.minecraft.world.gen.feature.WorldGenerator;
- public class StructureJohnnyFaceCave extends WorldGenerator
- {
- protected Block[] GetValidSpawnBlocks()
- {
- return new Block[]
- {
- Blocks.grass,
- Blocks.dirt,
- Blocks.stone,
- };
- }
- public boolean LocationIsValidSpawn(World world, int x, int y, int z)
- {
- int distanceToAir = 0;
- Block checkBlock = world.getBlock(x, y, z);
- while (checkBlock != Blocks.air)
- {
- distanceToAir++;
- checkBlock = world.getBlock(x, y + distanceToAir, z);
- }
- if (distanceToAir > 1)
- {
- return false;
- }
- y += distanceToAir - 1;
- Block block = world.getBlock(x, y, z);
- Block blockAbove = world.getBlock(x, y + 1, z);
- Block blockBelow = world.getBlock(x, y - 1, z);
- for (Block i : GetValidSpawnBlocks())
- {
- if (blockAbove != Blocks.air)
- {
- return false;
- }
- if (block == i)
- {
- return true;
- }
- else if (block == Blocks.snow_layer && blockBelow == i) {
- return true;
- }
- else if (block.getMaterial() == Material.plants && blockBelow == i)
- {
- return true;
- }
- }
- return false;
- }
- public boolean generate(World world, Random rand, int x, int y, int z)
- {
- if (!LocationIsValidSpawn(world, x, y, z) || !LocationIsValidSpawn(world, x + 12, y, z) || !LocationIsValidSpawn(world, x + 12, y, z + 20) || !LocationIsValidSpawn(world, x, y, z + 20)) {
- return false;
- }
- world.setBlock(x + 0, y + 0, z + 0, Blocks.stone, 0, 3);
- world.setBlock(x + 1, y + 0, z + 0, Blocks.dirt, 0, 3);
- <snip>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement