本文整理汇总了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.
}