當前位置: 首頁>>代碼示例>>Java>>正文


Java Chunk類代碼示例

本文整理匯總了Java中org.bukkit.Chunk的典型用法代碼示例。如果您正苦於以下問題:Java Chunk類的具體用法?Java Chunk怎麽用?Java Chunk使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Chunk類屬於org.bukkit包,在下文中一共展示了Chunk類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: disableAI

import org.bukkit.Chunk; //導入依賴的package包/類
public void disableAI() {
    for (World world : getServer().getWorlds()) {
        if (config.ignored_world.contains(world.getName())) {
            continue;
        }
        if (world.getLivingEntities().size() >= this.config.world_entity) {
            if (!disableAIWorlds.contains(world.getName())) {
                disableAIWorlds.add(world.getName());
                getLogger().info("disable entity ai in " + world.getName());
            }
            for (Chunk chunk : world.getLoadedChunks()) {
                int entityCount = getLivingEntityCount(chunk);
                if (entityCount >= this.config.chunk_entity) {
                    for (Entity entity : chunk.getEntities()) {
                        if (entity instanceof LivingEntity) {
                            setFromMobSpawner((LivingEntity) entity, true);
                        }
                    }
                }
            }
        }
    }
}
 
開發者ID:NyaaCat,項目名稱:Yasui,代碼行數:24,代碼來源:Main.java

示例2: enableAI

import org.bukkit.Chunk; //導入依賴的package包/類
public void enableAI() {
    for (World world : getServer().getWorlds()) {
        if (!disableAIWorlds.contains(world.getName())) {
            continue;
        } else {
            disableAIWorlds.remove(world.getName());
        }
        getLogger().info("enable entity ai in " + world.getName());
        for (Chunk chunk : world.getLoadedChunks()) {
            for (Entity entity : chunk.getEntities()) {
                if (entity instanceof LivingEntity) {
                    setFromMobSpawner((LivingEntity) entity, false);
                }
            }
        }
    }
}
 
開發者ID:NyaaCat,項目名稱:Yasui,代碼行數:18,代碼來源:Main.java

示例3: run

import org.bukkit.Chunk; //導入依賴的package包/類
/**
 * Clean the cache
 */
@Override
public void run()
{
    long currentTime = System.currentTimeMillis();

    List<Map.Entry<Chunk, Long>> temp = new ArrayList<>();
    temp.addAll(this.lastChunkCleanUp.entrySet());

    for (Map.Entry<Chunk, Long> entry : temp)
    {
        Chunk chunk = entry.getKey();

        if (!chunk.isLoaded() || (currentTime - entry.getValue() <= 60000))
            continue;

        for (Entity entity : chunk.getEntities())
            if (!(entity instanceof Item || entity instanceof HumanEntity || entity instanceof Minecart))
                entity.remove();

        this.lastChunkCleanUp.remove(chunk);
    }
}
 
開發者ID:SamaGames,項目名稱:SurvivalAPI,代碼行數:26,代碼來源:ChunkListener.java

示例4: setBiome

import org.bukkit.Chunk; //導入依賴的package包/類
public void setBiome(int x, int z, Biome bio) {
    net.minecraft.world.biome.BiomeGenBase bb = CraftBlock.biomeToBiomeBase(bio);
    if (this.world.blockExists(x, 0, z)) {
        net.minecraft.world.chunk.Chunk chunk = this.world.getChunkFromBlockCoords(x, z);

        if (chunk != null) {
            byte[] biomevals = chunk.getBiomeArray();
            biomevals[((z & 0xF) << 4) | (x & 0xF)] = (byte)bb.biomeID;
        }
    }
}
 
開發者ID:UraniumMC,項目名稱:Uranium,代碼行數:12,代碼來源:CraftWorld.java

示例5: handleChunkLoadSync

import org.bukkit.Chunk; //導入依賴的package包/類
public void handleChunkLoadSync(Chunk loadedChunk) {
	if (loadedChunk.getTileEntities() != null) {
		for (BlockState bs : loadedChunk.getTileEntities()) {
			if (isIdContainerBlock(bs.getTypeId())) {

				updateDuctNeighborBlockSync(bs.getBlock(), true);

				Map<BlockLoc, TransportPipesContainer> containerMap = TransportPipes.instance.getContainerMap(loadedChunk.getWorld());
				synchronized (containerMap) {
					BlockLoc bl = BlockLoc.convertBlockLoc(bs.getLocation());
					TransportPipesContainer tpc = containerMap.get(bl);
					if (tpc instanceof BlockContainer) {
						((BlockContainer) tpc).updateBlock();
					}
				}
			}
		}
	}
}
 
開發者ID:RoboTricker,項目名稱:Transport-Pipes,代碼行數:20,代碼來源:ContainerBlockUtils.java

示例6: getHandle

import org.bukkit.Chunk; //導入依賴的package包/類
public net.minecraft.world.chunk.Chunk getHandle() {
    net.minecraft.world.chunk.Chunk c = null;
    if (weakChunk != null) {
        c = weakChunk.get();
    }

    if (c == null) {
        c = worldServer.getChunkFromChunkCoords(x, z);

        if (!(c instanceof net.minecraft.world.chunk.EmptyChunk)) {
            weakChunk = new WeakReference<net.minecraft.world.chunk.Chunk>(c);
        }
    }

    return c;
}
 
開發者ID:UraniumMC,項目名稱:Uranium,代碼行數:17,代碼來源:CraftChunk.java

示例7: getEntities

import org.bukkit.Chunk; //導入依賴的package包/類
public Entity[] getEntities() {
    int count = 0, index = 0;
    net.minecraft.world.chunk.Chunk chunk = getHandle();

    for (int i = 0; i < 16; i++) {
        count += chunk.entityLists[i].size();
    }

    Entity[] entities = new Entity[count];

    for (int i = 0; i < 16; i++) {
        for (Object obj : chunk.entityLists[i].toArray()) {
            if (!(obj instanceof net.minecraft.entity.Entity)) {
                continue;
            }

            entities[index++] = ((net.minecraft.entity.Entity) obj).getBukkitEntity();
        }
    }

    return entities;
}
 
開發者ID:UraniumMC,項目名稱:Uranium,代碼行數:23,代碼來源:CraftChunk.java

示例8: populate

import org.bukkit.Chunk; //導入依賴的package包/類
@Override
public void populate(World world, Random random, Chunk chunk)
{
    if (this.bukkitWorld == null)
    {
        this.bukkitWorld = new BukkitWorld(world);
        this.es = WorldEdit.getInstance().getEditSessionFactory().getEditSession(this.bukkitWorld, -1);
        this.es.setFastMode(false);
    }

    if (MathHelper.nextInt(random, 0, 100) == 0)
    {
        int xFortress = chunk.getX() * 16 + random.nextInt(15);
        int zFortress = chunk.getZ() * 16 + random.nextInt(15);

        this.generateBlazeFortress(world, xFortress, zFortress);
    }
}
 
開發者ID:SamaGames,項目名稱:SurvivalAPI,代碼行數:19,代碼來源:FortressPopulator.java

示例9: onSpawn

import org.bukkit.Chunk; //導入依賴的package包/類
@EventHandler
public void onSpawn(CreatureSpawnEvent event) {
	if (ConfigOptimize.NoCrowdedEntityenable) {
		Chunk chunk = event.getEntity().getLocation().getChunk();
		Entity[] entities = chunk.getEntities();

		for (Entity e : entities) {
			EntityType type = e.getType();
			int count = 0;
			if (ConfigOptimize.NoCrowdedEntityTypeList.contains("*")
					|| ConfigOptimize.NoCrowdedEntityTypeList.contains(type.name())) {
				count++;
				if (count > ConfigOptimize.NoCrowdedEntityPerChunkLimit && e.getType() != EntityType.PLAYER) {
					e.remove();
				}
			}
		}
	}
}
 
開發者ID:GelandiAssociation,項目名稱:EscapeLag,代碼行數:20,代碼來源:NoCrowdEntity.java

示例10: WaterFowLimitor

import org.bukkit.Chunk; //導入依賴的package包/類
@EventHandler
  public void WaterFowLimitor(BlockFromToEvent event) {
if(ConfigOptimize.WaterFlowLimitorenable == true){
	Block block = event.getBlock();
	Chunk chunk = block.getChunk();
       if (block.getType() == Material.STATIONARY_WATER || block.getType() == Material.STATIONARY_LAVA) {
           if(CheckFast(block.getChunk())){
           	if(CheckedTimes.get(chunk) == null){
       			CheckedTimes.put(chunk, 0);
       		}
       		CheckedTimes.put(chunk, CheckedTimes.get(chunk) + 1);
       		if(CheckedTimes.get(chunk) > ConfigOptimize.WaterFlowLimitorPerChunkTimes){
       			event.setCancelled(true);
       		}
           }else{
               ChunkLastTime.put(block.getChunk(), System.currentTimeMillis());
           }
       }
}
  }
 
開發者ID:GelandiAssociation,項目名稱:EscapeLag,代碼行數:21,代碼來源:WaterFlowLimitor.java

示例11: getChunks

import org.bukkit.Chunk; //導入依賴的package包/類
/**
 * Get a list of the chunks which are fully or partially contained in this cuboid.
 *
 * @return A list of Chunk objects
 */
public List<Chunk> getChunks() {
    List<Chunk> res = new ArrayList<Chunk>();

    World w = this.getWorld();
    int x1 = this.getLowerX() & ~0xf;
    int x2 = this.getUpperX() & ~0xf;
    int z1 = this.getLowerZ() & ~0xf;
    int z2 = this.getUpperZ() & ~0xf;
    for (int x = x1; x <= x2; x += 16) {
        for (int z = z1; z <= z2; z += 16) {
            res.add(w.getChunkAt(x >> 4, z >> 4));
        }
    }
    return res;
}
 
開發者ID:ijoeleoli,項目名稱:ZorahPractice,代碼行數:21,代碼來源:Cuboid.java

示例12: refreshCache

import org.bukkit.Chunk; //導入依賴的package包/類
private static void refreshCache(BlockStorage storage, Location l, String key, String value, boolean updateTicker) {
	Config cfg = storage.cache_blocks.containsKey(key) ? storage.cache_blocks.get(key): new Config(path_blocks + l.getWorld().getName() + "/" + key + ".sfb");
	cfg.setValue(serializeLocation(l), value);
	storage.cache_blocks.put(key, cfg);
	
	if (updateTicker) {
		SlimefunItem item = SlimefunItem.getByID(key);
		if (item != null && item.isTicking()) {
			Chunk chunk = l.getChunk();
			if (value != null) {
				Set<Block> blocks = ticking_chunks.containsKey(chunk.toString()) ? ticking_chunks.get(chunk.toString()): new HashSet<Block>();
				blocks.add(l.getBlock());
				ticking_chunks.put(chunk.toString(), blocks);
				if (!loaded_tickers.contains(chunk.toString())) loaded_tickers.add(chunk.toString());
			}
		}
	}
}
 
開發者ID:StarWishsama,項目名稱:Slimefun4-Chinese-Version,代碼行數:19,代碼來源:BlockStorage.java

示例13: populate

import org.bukkit.Chunk; //導入依賴的package包/類
@Override
public void populate(World world, Random random, Chunk chunk)
{
    if (chunk == null)
        return;

    CraftWorld handle = (CraftWorld) world;
    int xr = this.randInt(random, -200, 200);

    if (xr >= 50)
        new WorldGenCaves().a(handle.getHandle().chunkProviderServer, handle.getHandle(), chunk.getX(), chunk.getZ(), new ChunkSnapshot());
    else if (xr <= -50)
        new WorldGenCanyon().a(handle.getHandle().chunkProviderServer, handle.getHandle(), chunk.getX(), chunk.getZ(), new ChunkSnapshot());

    for (Rule bloc : this.rules)
    {
        for (int i = 0; i < bloc.round; i++)
        {
            int x = chunk.getX() * 16 + random.nextInt(16);
            int y = bloc.minY + random.nextInt(bloc.maxY - bloc.minY);
            int z = chunk.getZ() * 16 + random.nextInt(16);
            this.generate(world, random, x, y, z, bloc.size, bloc);
        }
    }

}
 
開發者ID:SamaGames,項目名稱:SurvivalAPI,代碼行數:27,代碼來源:OrePopulator.java

示例14: autoClean

import org.bukkit.Chunk; //導入依賴的package包/類
private void autoClean(Chunk chunk) {
	if (chunk == null) {
		return;
	}
	for (BlockState tiles : chunk.getTileEntities()) {
		if (tiles instanceof CreatureSpawner) {
			CreatureSpawner spawner = (CreatureSpawner) tiles;
			// 非法類型檢測
			if (cm.illegalSpawnerType.contains(spawner.getCreatureTypeName().toLowerCase())) {
				switch (cm.illegalTypeSpawnerCleanMode) {
				case 0:
					spawner.getBlock().setType(Material.AIR);
					break;
				case 1:
					spawner.setCreatureType(RND_ENTITYTYPE[(int) (Math.random() * RND_ENTITYTYPE.length)]);
					break;
				default:
					break;
				}
			}
		}
	}
}
 
開發者ID:jiongjionger,項目名稱:NeverLag,代碼行數:24,代碼來源:AutoCleanIllegalTypeSpawner.java

示例15: unloadChunk

import org.bukkit.Chunk; //導入依賴的package包/類
public static void unloadChunk(Chunk chunk) {
	long chunk_id = ((long) chunk.getX() << 32L) + (long) chunk.getZ();
	UUID world_uuid = chunk.getWorld().getUID();
	//CropControl.getPlugin().debug("Registering unload for chunk {0}:{1}", world_uuid, chunk_id);
	Map<Long, WorldChunk> chunks = chunkCacheLoc.get(world_uuid);
	if (chunks == null) {
		return;
	}
	WorldChunk cacheChunk = chunks.get(chunk_id);
	if (cacheChunk != null) {
		unloadQueue.offer(cacheChunk);
	}
	// note we do not actually remove it here.
}
 
開發者ID:DevotedMC,項目名稱:CropControl,代碼行數:15,代碼來源:WorldChunk.java


注:本文中的org.bukkit.Chunk類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。