Created
March 12, 2012 14:28
-
-
Save s1mpl3x/2022289 to your computer and use it in GitHub Desktop.
ChunkGen
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package eu.over9000.equinox.generator; | |
import java.util.Random; | |
import org.bukkit.Material; | |
import org.bukkit.World; | |
import org.bukkit.generator.ChunkGenerator; | |
public class Equinox_ChunkGenerator extends ChunkGenerator { | |
private void setMaterialAt(byte[][] chunk_data, int x, int y, int z, Material material) { | |
int sec_id = (y >> 4); | |
int yy = y & 0xF; | |
if (chunk_data[sec_id] == null) { | |
chunk_data[sec_id] = new byte[4096]; | |
} | |
chunk_data[sec_id][(yy << 8) | (z << 4) | x] = (byte) material.getId(); | |
} | |
@Override | |
public byte[][] generateBlockSections(World world, Random random, int x_chunk, int z_chunk, BiomeGrid biomes) { | |
byte[][] chunk_data = new byte[16][]; | |
for (int x_coord = 0; x_coord < 16; x_coord++) { | |
for (int z_coord = 0; z_coord < 16; z_coord++) { | |
setMaterialAt(chunk_data, x_coord, 0, z_coord, Material.BEDROCK); | |
setMaterialAt(chunk_data, x_coord, 1, z_coord, Material.BEDROCK); | |
setMaterialAt(chunk_data, x_coord, 2, z_coord, random.nextBoolean() ? Material.BEDROCK : Material.STONE); | |
} | |
} | |
return chunk_data; | |
} | |
@Override | |
public boolean canSpawn(World world, int x, int z) { | |
return true; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment