Java 类org.bukkit.util.noise.SimplexOctaveGenerator 实例源码
项目:BukkitPopulators
文件:CavePopulator.java
@Override
public void populate(World world, Random random, Chunk source) {
int worldChunkX = source.getX() * 16;
int worldChunkZ = source.getZ() * 16;
int x, y, z;
SimplexOctaveGenerator noiseGenerator = new SimplexOctaveGenerator(world, 8);
noiseGenerator.setScale(1 / 32.0);
for (x = worldChunkX; x < worldChunkX + 16; x++) {
for (z = worldChunkZ; z < worldChunkZ + 16; z++) {
for (y = world.getMaxHeight() - caveCentre; y > world.getMaxHeight() - (caveCentre + (noiseGenerator.noise(x, z, 0.5, 0.5) * (maxCaveHeight / 2))); y--) {
if (world.getBlockAt(x, y, z).getType() != Material.AIR) {
world.getBlockAt(x, y, z).setType(Material.AIR);
}
}
for (y = world.getMaxHeight() - caveCentre; y < world.getMaxHeight() - (caveCentre - (noiseGenerator.noise(x, z, 0.5, 0.5) * (maxCaveHeight / 2))); y++) {
if (world.getBlockAt(x, y, z).getType() != Material.AIR) {
world.getBlockAt(x, y, z).setType(Material.AIR);
}
}
}
}
}
项目:BukkitPopulators
文件:NetherSoulSandPopulator.java
public void populate(World world, Random rand, Chunk chunk){
int chunkX = chunk.getX();
int chunkZ = chunk.getZ();
SimplexOctaveGenerator soulSandNoise = new SimplexOctaveGenerator(world, 8);
soulSandNoise.setScale(1 / 32.0);
for (int x = 0; x < 16; ++x){
for (int z = 0; z < 16; ++z){
int blockX = x + chunkX * 16;
int blockZ = z + chunkZ * 16;
if (soulSandNoise.noise(blockX, blockZ, 0.5, 0.5) > 0.25D){
for (int y = 128; y > 0; --y){
Block block = world.getBlockAt(blockX, y, blockZ);
if (block.getType() == Material.NETHERRACK && block.getRelative(BlockFace.UP).getType() == Material.AIR){
block.setType(Material.SOUL_SAND);
}
}
}
}
}
}
项目:tregmine
文件:ChristmasChunkGenerator.java
@SuppressWarnings("deprecation")
public byte[] generate(World world, Random random, int chunkX, int chunkZ) {
byte[] b = new byte[16*16*128];
Random seed = new Random(world.getSeed());
SimplexOctaveGenerator gen = new SimplexOctaveGenerator(seed, 8);
gen.setScale(1/40.0);
for (int x=0; x<16; x++){
for (int z=0; z<16; z++){
int multiplier = 5;
double noise = gen.noise(x+chunkX*16, z+chunkZ*16, 0.5, 0.5)*multiplier;
for(int y=0; y<32+noise; y++){
if(b[xyzToByte(x,y,z)] ==0)
if(y == 0)
b[xyzToByte(x,y,z)] = (byte) (Material.BEDROCK).getId();
else
b[xyzToByte(x,y,z)] = (byte) (Material.SNOW_BLOCK).getId();
}
for(int y=0; y<20; y++)
{
if(b[xyzToByte(x,y,z)] == 0)
b[xyzToByte(x,y,z)] = (byte) (Material.STATIONARY_WATER).getId();
}
b[xyzToByte(x,0,z)] = (byte) (Material.BEDROCK).getId();
}
}
return b;
}
项目:Wayward
文件:CavePopulator.java
@Override
public void populate(World world, Random random, Chunk source) {
int worldChunkX = source.getX() * 16;
int worldChunkZ = source.getZ() * 16;
int x, y, z;
SimplexOctaveGenerator noiseGenerator = new SimplexOctaveGenerator(world, 8);
noiseGenerator.setScale(1 / 32.0);
for (x = worldChunkX; x < worldChunkX + 16; x++) {
for (z = worldChunkZ; z < worldChunkZ + 16; z++) {
for (y = world.getMaxHeight() - caveCentre; y > world.getMaxHeight() - (caveCentre + (noiseGenerator.noise(x, z, 0.5, 0.5) * (maxCaveHeight / 2))); y--) {
if (world.getBlockAt(x, y, z).getType() != Material.AIR) {
world.getBlockAt(x, y, z).setType(source.getX() % 4 == 0 && source.getZ() % 4 == 0 && (x - worldChunkX == 12 || x - worldChunkX == 15) && (z - worldChunkZ == 12 || z - worldChunkZ == 15) ? Material.LOG : Material.AIR);
}
}
for (y = world.getMaxHeight() - caveCentre; y < world.getMaxHeight() - (caveCentre - (noiseGenerator.noise(x, z, 0.5, 0.5) * (maxCaveHeight / 2))); y++) {
if (world.getBlockAt(x, y, z).getType() != Material.AIR) {
world.getBlockAt(x, y, z).setType(source.getX() % 4 == 0 && source.getZ() % 4 == 0 && (x - worldChunkX == 12 || x - worldChunkX == 15) && (z - worldChunkZ == 12 || z - worldChunkZ == 15) && y < 144 ? Material.LOG : Material.AIR);
}
}
}
}
if (source.getX() % 4 == 0) {
y = 144;
for (x = worldChunkX + 12; x < worldChunkX + 16; x++) {
for (z = worldChunkZ; z < worldChunkZ + 16; z++) {
if (world.getBlockAt(x, y, z).getType() == Material.AIR) {
world.getBlockAt(x, y, z).setType(Material.WOOD);
}
}
}
}
if (source.getZ() % 4 == 0) {
y = 112;
for (x = worldChunkX; x < worldChunkX + 16; x++) {
for (z = worldChunkZ + 12; z < worldChunkZ + 16; z++) {
if (world.getBlockAt(x, y, z).getType() == Material.AIR) {
world.getBlockAt(x, y, z).setType(Material.WOOD);
}
}
}
}
}