本文整理匯總了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);
}
}
}
}
}
}
}
示例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);
}
}
}
}
}
示例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);
}
}
示例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;
}
}
}
示例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();
}
}
}
}
}
}
示例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;
}
示例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;
}
示例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);
}
}
示例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();
}
}
}
}
}
示例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());
}
}
}
}
示例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;
}
示例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());
}
}
}
}
示例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);
}
}
}
示例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;
}
}
}
}
}
示例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.
}