本文整理汇总了Java中org.bukkit.Chunk.getEntities方法的典型用法代码示例。如果您正苦于以下问题:Java Chunk.getEntities方法的具体用法?Java Chunk.getEntities怎么用?Java Chunk.getEntities使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.Chunk
的用法示例。
在下文中一共展示了Chunk.getEntities方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: CheckCrowd
import org.bukkit.Chunk; //导入方法依赖的package包/类
@EventHandler
public void CheckCrowd(ChunkLoadEvent evt) {
if (ConfigOptimize.NoCrowdedEntityenable) {
Chunk chunk = evt.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();
}
}
}
}
}
示例4: 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();
}
}
}
}
}
示例5: 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);
}
}
示例6: getLivingEntityCount
import org.bukkit.Chunk; //导入方法依赖的package包/类
public int getLivingEntityCount(Chunk chunk) {
int entityCount = 0;
for (Entity entity : chunk.getEntities()) {
if (entity instanceof LivingEntity && !(entity instanceof ArmorStand)) {
entityCount++;
}
}
return entityCount;
}
示例7: onChunkLoad
import org.bukkit.Chunk; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true)
public void onChunkLoad(ChunkLoadEvent event) {
Chunk chunk = event.getChunk();
if (!plugin.disableAIWorlds.contains(chunk.getWorld().getName())) {
return;
}
for (Entity entity : chunk.getEntities()) {
if (entity instanceof LivingEntity && plugin.noAIMobs.contains(entity.getUniqueId())) {
plugin.setFromMobSpawner((LivingEntity) entity, true);
}
}
}
示例8: ChunkloadClear
import org.bukkit.Chunk; //导入方法依赖的package包/类
@EventHandler
public void ChunkloadClear(ChunkUnloadEvent event) {
if (ConfigOptimize.UnloadClearenable != true) {
return;
}
Chunk chunk = event.getChunk();
boolean noclearitemchunk = false;
int dcs = DeathChunk.size();
for (int i = 0; i < dcs; i++) {
Chunk deathchunk = DeathChunk.get(i);
if (Utils.isSameChunk(chunk, deathchunk)) {
DeathChunk.remove(chunk);
noclearitemchunk = true;
break;
}
}
Entity[] entities = chunk.getEntities();
for (int i = 0; i < entities.length; i++) {
Entity ent = entities[i];
if (ent.getType() == EntityType.DROPPED_ITEM && noclearitemchunk == false && ConfigOptimize.UnloadClearDROPPED_ITEMenable) {
ent.remove();
}
if(ConfigOptimize.UnloadCleartype.contains(ent.getType().name())||ConfigOptimize.UnloadCleartype.contains("*")) {
ent.remove();
}
}
}
示例9: getNearbyEntities
import org.bukkit.Chunk; //导入方法依赖的package包/类
public static ArrayList<Entity> getNearbyEntities(Location loc, double radius) {
ArrayList<Entity> list = new ArrayList<Entity>();
ArrayList<Chunk> chunkList = new ArrayList<Chunk>();
int baseX, baseZ;
baseX = loc.getChunk().getX();
baseZ = loc.getChunk().getZ();
for (int dx = -1; dx <= 1; dx++)
for (int dz = -1; dz <= 1; dz++)
chunkList.add(loc.getWorld().getChunkAt(baseX + dx, baseZ + dz));
for (Chunk chunk : chunkList) {
for (Entity e : chunk.getEntities()) {
Location eLoc = e.getLocation();
if (e instanceof LivingEntity)
eLoc = eLoc.add(0, ((LivingEntity) e).getEyeHeight() * 0.75, 0);
double x1 = eLoc.getX();
double y1 = eLoc.getY();
double z1 = eLoc.getZ();
double x2 = loc.getX();
double y2 = loc.getY();
double z2 = loc.getZ();
double xdiff = x1 - x2;
double ydiff = Math.abs(y1 - y2) - 0.7;
if (ydiff < 0)
ydiff = 0;
double zdiff = z1 - z2;
double sq = xdiff * xdiff + ydiff * ydiff + zdiff * zdiff;
if (sq <= radius * radius)
list.add(e);
}
}
return list;
}
示例10: getNearbyEntitiesCylinder
import org.bukkit.Chunk; //导入方法依赖的package包/类
public static ArrayList<Entity> getNearbyEntitiesCylinder(Location loc, double radius, double vertical) {
ArrayList<Entity> list = new ArrayList<Entity>();
ArrayList<Chunk> chunkList = new ArrayList<Chunk>();
int baseX, baseZ;
baseX = loc.getChunk().getX();
baseZ = loc.getChunk().getZ();
for (int dx = -1; dx <= 1; dx++)
for (int dz = -1; dz <= 1; dz++)
chunkList.add(loc.getWorld().getChunkAt(baseX + dx, baseZ + dz));
for (Chunk chunk : chunkList) {
for (Entity e : chunk.getEntities()) {
Location eLoc = e.getLocation();
if (e instanceof LivingEntity)
eLoc = eLoc.add(0, ((LivingEntity) e).getEyeHeight() * 0.75, 0);
double x1 = eLoc.getX();
double y1 = eLoc.getY();
double z1 = eLoc.getZ();
double x2 = loc.getX();
double y2 = loc.getY();
double z2 = loc.getZ();
double xdiff = x1 - x2;
double ydiff = Math.abs(y1 - y2);
if (ydiff > vertical)
continue;
double zdiff = z1 - z2;
double sq = xdiff * xdiff + zdiff * zdiff;
if (sq <= radius * radius)
list.add(e);
}
}
return list;
}
示例11: getCraftEntities
import org.bukkit.Chunk; //导入方法依赖的package包/类
public ArrayList<Entity> getCraftEntities(boolean removeItems) {
ArrayList<Entity> checkEntities = new ArrayList<Entity>();
Chunk firstChunk = world.getChunkAt(new Location(world, minX, minY, minZ));
Chunk lastChunk = world.getChunkAt(new Location(world, minX + sizeX, minY + sizeY, minZ + sizeZ));
int targetX = 0;
int targetZ = 0;
Chunk addChunk;
Entity[] ents;
for(int x = 0; Math.abs(firstChunk.getX() - lastChunk.getX()) >= x; x++) {
targetX = 0;
if(firstChunk.getX() < lastChunk.getX()) {
targetX = firstChunk.getX() + x;
} else {
targetX = firstChunk.getX() - x;
}
for(int z = 0; Math.abs(firstChunk.getZ() - lastChunk.getZ()) >= z; z++) {
targetZ = 0;
if(firstChunk.getZ() < lastChunk.getZ()) {
targetZ = firstChunk.getZ() + z;
} else {
targetZ = firstChunk.getZ() - z;
}
addChunk = world.getChunkAt(targetX, targetZ);
try {
ents = addChunk.getEntities();
for(Entity e : ents) {
if(!(e instanceof Item) && this.isOnCraft(e, false)) {
checkEntities.add(e);
}else if( e instanceof Item && (this.sinking||removeItems) && this.isOnCraft(e, false) )
{
e.remove();
}
}
}
catch (Exception ex) {
}
}
}
return checkEntities;
}