Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public final class RoadWorldGenerator implements IWorldGenerator
- {
- private static final Material[] allowedMaterials = new Material[]
- { Material.CLAY, Material.GRASS, Material.GROUND, Material.ICE, Material.PACKED_ICE, Material.SAND, Material.SNOW };
- private static boolean materialIsAllowed(Material material)
- {
- for(Material i : allowedMaterials)
- if(material == i)
- return true;
- return false;
- }
- @Override
- public void generate(Random random,
- int chunkX,
- int chunkZ,
- World world,
- IChunkGenerator chunkGenerator,
- IChunkProvider chunkProvider)
- {
- RoadMap roadmap = RoadMapRegistry.get(world.provider.getDimension());
- if(roadmap == null)
- return;
- int blockX = chunkX * 16;
- int blockZ = chunkZ * 16;
- Set<BlockPos> blockPositions = new HashSet<BlockPos>();
- for(int x = blockX; x < (blockX + 16); x++)
- for(int z = blockZ; z < (blockZ + 16); z++)
- {
- if(!roadmap.getAt(x, z))
- continue;
- blockPositions.addAll(RoadStyle.grassy.getRoadBlocks(new BlockPos(x, 255, z)));
- }
- for(BlockPos i : blockPositions)
- {
- BlockPos topBlock = world.getTopSolidOrLiquidBlock(i).down();
- if(!materialIsAllowed(world.getBlockState(topBlock).getMaterial()))
- continue;
- RoadStyle.grassy.drawRoadBlockAt(world, topBlock);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment