Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package me.jtjj222.BasicTerrain;
- import java.util.ArrayList;
- import java.util.List;
- import java.util.Random;
- import org.bukkit.Material;
- import org.bukkit.World;
- import org.bukkit.block.Biome;
- import org.bukkit.generator.*;
- public class BasicChunkGenerator extends ChunkGenerator {
- void setBlock(int x, int y, int z, byte[][] chunk, Material material) {
- try {
- chunk[y >> 4][((y & 0xF) << 8) | (z << 4) | x] = (byte) material
- .getId();
- } catch (Exception e) {
- // do nothing
- }
- }
- @Override
- public byte[][] generateBlockSections(World world, Random rand, int chunkXlocationInWorld,
- int chunkZLocationInWorld, BiomeGrid biomeGrid) {
- byte[][] chunk = new byte[world.getMaxHeight()/16][16*16*16];
- for (int inChunkX = 0; inChunkX < 16; inChunkX++) {
- for (int inChunkZ = 0; inChunkZ < 16; inChunkZ++) {
- //in-chunk to world co-ordinates; Used for the noise generator
- int worldX = chunkXlocationInWorld * 16 + inChunkX;
- int worldZ = chunkZLocationInWorld * 16 + inChunkZ;
- /*
- * Get the PROPOSED biome for this location.
- * If you want to control biome generation, update the biomes here using setBiome(x,z);
- *
- * These values will be sent to the client to control weather and whatnot.
- */
- Biome currentBiome = biomeGrid.getBiome(inChunkX, inChunkZ);
- Material topBlockType = getTopBlockType(currentBiome);
- setBlock(inChunkX, 64, inChunkZ, chunk, topBlockType);
- for (int y = 0; y < 64; y++) setBlock(inChunkX, y, inChunkZ, chunk, Material.STONE);
- }
- }
- return chunk;
- }
- public Material getTopBlockType(Biome b) {
- Material topBlockType;
- switch (b) {
- case BEACH: topBlockType = Material.SAND;
- break;
- case DESERT: topBlockType = Material.SAND;
- break;
- case DESERT_HILLS: topBlockType = Material.SAND;
- break;
- case EXTREME_HILLS: topBlockType = Material.GRAVEL;
- break;
- case FOREST: topBlockType = Material.GRASS;
- break;
- case FOREST_HILLS: topBlockType = Material.GRASS;
- break;
- case FROZEN_OCEAN: topBlockType = Material.ICE;
- break;
- case FROZEN_RIVER: topBlockType = Material.ICE;
- break;
- case HELL: topBlockType = Material.NETHERRACK;
- break;
- case ICE_MOUNTAINS: topBlockType = Material.SNOW_BLOCK;
- break;
- case ICE_PLAINS: topBlockType = Material.SNOW_BLOCK;
- break;
- case JUNGLE: topBlockType = Material.GRASS;
- break;
- case JUNGLE_HILLS: topBlockType = Material.GRASS;
- break;
- case MUSHROOM_ISLAND: topBlockType = Material.MYCEL;
- break;
- case MUSHROOM_SHORE: topBlockType = Material.MYCEL;
- break;
- case OCEAN: topBlockType = Material.WATER;
- break;
- case PLAINS: topBlockType = Material.GRASS;
- break;
- case RIVER: topBlockType = Material.WATER;
- break;
- case SKY: topBlockType = Material.AIR;
- break;
- case SMALL_MOUNTAINS: topBlockType = Material.WATER;
- break;
- case SWAMPLAND: topBlockType = Material.MYCEL;
- break;
- case TAIGA: topBlockType = Material.GRASS;
- break;
- case TAIGA_HILLS: topBlockType = Material.GRASS;
- break;
- default: topBlockType = Material.GRASS;
- }
- return topBlockType;
- }
- @Override
- public List<BlockPopulator> getDefaultPopulators(World world) {
- ArrayList<BlockPopulator> pops = new ArrayList<BlockPopulator>();
- //Add Block populators here
- return pops;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement