Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package me.sebagius7110.sebcraft.minigame.MyOwnPlanetWorldGnerator.Generation;
- import java.util.*;
- import java.util.Random;
- import me.sebagius7110.sebcraft.minigame.MyOwnPlanetWorldGenerator.main.MyOwnPlanetWorldGenerator;
- import org.bukkit.Location;
- import org.bukkit.Material;
- import org.bukkit.World;
- import org.bukkit.generator.BlockPopulator;
- import org.bukkit.generator.ChunkGenerator;
- public class PlanetWorldGenerator extends ChunkGenerator{
- MyOwnPlanetWorldGenerator plugin;
- public PlanetWorldGenerator(MyOwnPlanetWorldGenerator instance) {
- plugin = instance;
- }
- public Location getFixedSpawnLocation(World world, Random random) {
- return new Location(world, 0, 0, 0);
- }
- public List<BlockPopulator> getDefaultPopulators(World world) {
- return new ArrayList<BlockPopulator>();
- }
- @SuppressWarnings("deprecation")
- public byte[][] generatorBlockSections(World world, Random random, int chunkX, int chunkY, BiomeGrid biomeGrid) {
- byte[][] result = new byte[256 / 16][];
- int x, y, z;
- for (x = 0; x<16;x++) {
- for (z = 0; z<16;z++) {
- setBlock(result, x, 0, z, (byte) Material.AIR.getId());
- }
- }
- for (x = 0; x<16;x++) {
- for (z = 0; z<16;z++) {
- for (y = 1; y<=2;y++) {
- setBlock(result, x, y, z, (byte) Material.AIR.getId());
- }
- }
- }
- return result;
- }
- @Override
- public short[][] generateExtBlockSections(World world, Random random, int ChunkX,
- int ChunkZ, BiomeGrid biomes) {
- short[][] result = new short[256 / 16][];
- int x, y, z;
- for (x = 0; x<16;x++) {
- for (z = 0; z<16;z++) {
- setBlock(result, x, 0, z, (short) Material.AIR.getId());
- }
- }
- for (x = 0; x<16;x++) {
- for (z = 0; z<16;z++) {
- for (y = 1; y<=2;y++) {
- setBlock(result, x, y, z, (short) Material.AIR.getId());
- }
- }
- }
- return result;
- }
- private void setBlock(byte[][] result, int x, int y, int z, byte blockId) {
- if(result[y >> 4] == null) {
- result[y >> 4] = new byte[4096];
- }
- result[y >> 4][((y&0xF) << 8) | (z << 4) | x] = blockId;
- }
- private void setBlock(short[][] result, int x, int y, int z, short blockId) {
- if(result[y >> 4] == null) {
- result[y >> 4] = new short[4096];
- }
- result[y >> 4][((y&0xF) << 8) | (z << 4) | x] = blockId;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement