Package org.bukkit

Examples of org.bukkit.ChunkSnapshot


public class DungeonPopulator extends BlockPopulator {

    @Override
    public void populate(World world, Random random, Chunk source) {
        SimplexNoiseGenerator noise = new SimplexNoiseGenerator(world);
        ChunkSnapshot snapshot = source.getChunkSnapshot();

        // Randomly turn exposed stone to treasure
        for (int x = 0; x < 16; x++) {
            for (int z = 0; z < 16; z++) {
                int y = snapshot.getHighestBlockYAt(x, z);
                Block block = source.getBlock(x, y - 1, z);

                if (block.getType() == Material.STONE
                        && random.nextInt(1024) == 0) {
                    placeChest(random, block);
View Full Code Here


    public void populate(World world, Random random, Chunk source) {
        if (random.nextInt(10) > 1) {
            return;
        }

        ChunkSnapshot snapshot = source.getChunkSnapshot();

        int rx16 = random.nextInt(16);
        int rx = (source.getX() << 4) + rx16;
        int rz16 = random.nextInt(16);
        int rz = (source.getZ() << 4) + rz16;
        if (snapshot.getHighestBlockYAt(rx16, rz16) < 4) {
            return;
        }
        int ry = 6 + random.nextInt(snapshot.getHighestBlockYAt(rx16, rz16) - 3);
        int radius = 2 + random.nextInt(3);

        Material liquidMaterial = Material.LAVA;
        Material solidMaterial = Material.OBSIDIAN;

        if (random.nextInt(10) < 3) {
            ry = snapshot.getHighestBlockYAt(rx16, rz16) - 1;
        }
        if (random.nextInt(96) < ry && world.getEnvironment() != Environment.NETHER) {
            liquidMaterial = Material.WATER;
            solidMaterial = Material.WATER;
        } else if (world.getBlockAt(rx, ry, rz).getBiome() == Biome.FOREST) {
View Full Code Here

    @Override
    public void populate(World world, Random random, Chunk source) {
        int chunkX = source.getX() * 16;
        int chunkZ = source.getZ() * 16;
        ChunkSnapshot snapshot = source.getChunkSnapshot();
        for (int x = 0; x < 16; x++) {
            for (int z = 0; z < 16; z++) {
                Biome biome = world.getBiome(x + chunkX, z + chunkZ);
                if (biome != Biome.TAIGA) {
                    continue;
                }

                int y = snapshot.getHighestBlockYAt(x, z);
                if (source.getBlock(x, y, z).getType() == Material.AIR) {
                    y--;
                }

                Block block = source.getBlock(x, y, z);
View Full Code Here

      {
        consume(master.snapshots.take());
      }

      // Finish off by listening to special value
      ChunkSnapshot snap;
      while ((snap = master.snapshots.poll()) != null)
      {
        consume(snap);
      }
    }
View Full Code Here

                        break;
                    }
                }
            }
            /* Check if cached chunk snapshot found */
            ChunkSnapshot ss = null;
            long inhabited_ticks = 0;
            DynIntHashMap tileData = null;
            SnapshotRec ssr = DynmapPlugin.plugin.sscache.getSnapshot(dw.getName(), chunk.x, chunk.z, blockdata, biome, biomeraw, highesty);
            if(ssr != null) {
                ss = ssr.ss;
                inhabited_ticks = ssr.inhabitedTicks;
                if(!vis) {
                    if(hidestyle == HiddenChunkStyle.FILL_STONE_PLAIN)
                        ss = STONE;
                    else if(hidestyle == HiddenChunkStyle.FILL_OCEAN)
                        ss = OCEAN;
                    else
                        ss = EMPTY;
                }
                int idx = (chunk.x-x_min) + (chunk.z - z_min)*x_dim;
                snaparray[idx] = ss;
                snaptile[idx] = ssr.tileData;
                inhabitedTicks[idx] = inhabited_ticks;
               
                endChunkLoad(startTime, ChunkStats.CACHED_SNAPSHOT_HIT);
                continue;
            }
            boolean wasLoaded = w.isChunkLoaded(chunk.x, chunk.z);
            boolean didload = false;
            boolean isunloadpending = false;
            if (queue != null) {
                isunloadpending = helper.isInUnloadQueue(queue, chunk.x, chunk.z);
            }
            if (isunloadpending) {  /* Workaround: can't be pending if not loaded */
                wasLoaded = true;
            }
            try {
                didload = w.loadChunk(chunk.x, chunk.z, false);
            } catch (Throwable t) { /* Catch chunk error from Bukkit */
                Log.warning("Bukkit error loading chunk " + chunk.x + "," + chunk.z + " on " + w.getName());
                if(!wasLoaded) {    /* If wasn't loaded, we loaded it if it now is */
                    didload = w.isChunkLoaded(chunk.x, chunk.z);
                }
            }
            /* If it did load, make cache of it */
            if(didload) {
                tileData = new DynIntHashMap();

                Chunk c = w.getChunkAt(chunk.x, chunk.z);   /* Get the chunk */
                /* Get inhabited ticks count */
                inhabited_ticks = helper.getInhabitedTicks(c);
                if(!vis) {
                    if(hidestyle == HiddenChunkStyle.FILL_STONE_PLAIN)
                        ss = STONE;
                    else if(hidestyle == HiddenChunkStyle.FILL_OCEAN)
                        ss = OCEAN;
                    else
                        ss = EMPTY;
                }
                else {
                    if(blockdata || highesty) {
                        ss = c.getChunkSnapshot(highesty, biome, biomeraw);
                        /* Get tile entity data */
                        List<Object> vals = new ArrayList<Object>();
                        Map<?,?> tileents = helper.getTileEntitiesForChunk(c);
                        for(Object t : tileents.values()) {
                            int te_x = helper.getTileEntityX(t);
                            int te_y = helper.getTileEntityY(t);
                            int te_z = helper.getTileEntityZ(t);
                            int cx = te_x & 0xF;
                            int cz = te_z & 0xF;
                            int blkid = ss.getBlockTypeId(cx, te_y, cz);
                            int blkdat = ss.getBlockData(cx, te_y, cz);
                            String[] te_fields = HDBlockModels.getTileEntityFieldsNeeded(blkid,  blkdat);
                            if(te_fields != null) {
                                Object nbtcompound = helper.readTileEntityNBT(t);
                               
                                vals.clear();
View Full Code Here

            for(int i = 0; i < x_size; i++) {
                sameneighborbiomecnt[i] = new byte[z_size];
                biomemap[i] = new BiomeMap[z_size];
            }
            Object[] biomebase = null;
            ChunkSnapshot biome_css = null;
            for(int i = 0; i < x_size; i++) {
                for(int j = 0; j < z_size; j++) {
                    BiomeMap bm;
                    if (j == 0) {
                        initialize(i + x_base, 64, z_base);
View Full Code Here

        if(ongeneratechunk) {
            Listener chunkTrigger = new Listener() {
                @EventHandler(priority=EventPriority.MONITOR, ignoreCancelled=true)
                public void onChunkPopulate(ChunkPopulateEvent event) {
                    Chunk c = event.getChunk();
                    ChunkSnapshot cs = c.getChunkSnapshot();
                    int ymax = 0;
                    for(int i = 0; i < c.getWorld().getMaxHeight() / 16; i++) {
                        if(!cs.isSectionEmpty(i)) {
                            ymax = (i+1)*16;
                        }
                    }
                    /* Touch extreme corners */
                    int x = c.getX() << 4;
View Full Code Here

    regenUndo.add(snapshot);
  }
 
  public void regenUndo () {
    if (regenUndo.size() > 0) {
      ChunkSnapshot snapshot = regenUndo.get(regenUndo.size()-1);
      regenUndo.remove(snapshot);
     
      TownyRegenAPI.regenUndo(snapshot, this);
     
    }
View Full Code Here

TOP

Related Classes of org.bukkit.ChunkSnapshot

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.