//Schematic to java Structure by jajo_11 | inspired by "MITHION'S .SCHEMATIC TO JAVA CONVERTING TOOL"
package ,,.mod.worldgen.feature;
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 StructureDeadTree extends WorldGenerator
{
protected Block[] GetValidSpawnBlocks()
{
return new Block[]
{
Blocks.grass,
};
}
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 + 0, y, z) || !LocationIsValidSpawn(world, x + 0, y, z + 0) || !LocationIsValidSpawn(world, x, y, z + 0))
{
return false;
}
тут структура
return true;
}
}