本文整理了Java中org.bukkit.Chunk.getEntities()
方法的一些代码示例,展示了Chunk.getEntities()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Chunk.getEntities()
方法的具体详情如下:
包路径:org.bukkit.Chunk
类名称:Chunk
方法名:getEntities
[英]Get a list of all entities in the chunk.
[中]获取区块中所有实体的列表。
代码示例来源:origin: GlowstoneMC/Glowstone
private GlowItem getFirstDroppedItem(Location location) {
for (Entity entity : location.getChunk().getEntities()) {
if (location.getBlockX() != entity.getLocation().getBlockX()
|| location.getBlockY() != entity.getLocation().getBlockY()
|| location.getBlockZ() != entity.getLocation().getBlockZ()) {
continue;
}
if (entity.getType() != EntityType.DROPPED_ITEM) {
continue;
}
return ((GlowItem) entity);
}
return null;
}
代码示例来源:origin: EngineHub/CommandHelper
@Override
public MCEntity[] getEntities() {
Entity[] entities = c.getEntities();
MCEntity[] r = new MCEntity[entities.length];
for(int i = 0; i < r.length; i++) {
r[i] = new BukkitMCEntity(entities[i]);
}
return r;
}
代码示例来源:origin: Co0sh/BetonQuest
@EventHandler
public void onChunkUnload(ChunkUnloadEvent e) {
for (Entity entity : e.getChunk().getEntities()) {
removeEntity(entity, false);
}
}
代码示例来源:origin: zDevelopers/ImageOnMap
@EventHandler
public void onChunkLoad(ChunkLoadEvent event)
{
for (Entity entity : event.getChunk().getEntities())
{
if (entity instanceof ItemFrame)
{
initMap(((ItemFrame)entity).getItem());
}
}
}
代码示例来源:origin: EngineHub/WorldGuard
@EventHandler
public void onChunkLoad(ChunkLoadEvent event) {
ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
if (cfg.activityHaltToggle) {
int removed = 0;
for (Entity entity : event.getChunk().getEntities()) {
if (Entities.isIntensiveEntity(BukkitAdapter.adapt(entity))) {
entity.remove();
removed++;
}
}
if (removed > 50) {
log.info("Halt-Act: " + removed + " entities (>50) auto-removed from " + event.getChunk().toString());
}
}
}
代码示例来源:origin: libraryaddict/LibsDisguises
@EventHandler
public void onChunkUnload(ChunkUnloadEvent event) {
if (!DisguiseConfig.isSaveEntityDisguises())
return;
for (Entity entity : event.getChunk().getEntities()) {
Disguise[] disguises = DisguiseAPI.getDisguises(entity);
if (disguises.length <= 0)
continue;
DisguiseUtilities.saveDisguises(entity.getUniqueId(), disguises);
}
}
代码示例来源:origin: TheBusyBiscuit/Slimefun4
public static Item findItem(Block b) {
for (Entity n: b.getChunk().getEntities()) {
if (n instanceof Item) {
if (b.getLocation().add(0.5, 1.2, 0.5).distanceSquared(n.getLocation()) < 0.5D && n.getCustomName() != null) return (Item) n;
}
}
return null;
}
代码示例来源:origin: filoghost/HolographicDisplays
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onChunkUnload(ChunkUnloadEvent event) {
for (Entity entity : event.getChunk().getEntities()) {
if (!entity.isDead()) {
NMSEntityBase entityBase = nmsManager.getNMSEntityBase(entity);
if (entityBase != null) {
((CraftHologram) entityBase.getHologramLine().getParent()).despawnEntities();
}
}
}
}
代码示例来源:origin: eccentricdevotion/TARDIS
public static List<Entity> getNearbyEntities(Location l, int radius) {
int chunkRadius = radius < 16 ? 1 : (radius - (radius % 16)) / 16;
List<Entity> radiusEntities = new ArrayList<>();
for (int chX = 0 - chunkRadius; chX <= chunkRadius; chX++) {
for (int chZ = 0 - chunkRadius; chZ <= chunkRadius; chZ++) {
int x = (int) l.getX(), y = (int) l.getY(), z = (int) l.getZ();
for (Entity e : new Location(l.getWorld(), x + (chX * 16), y, z + (chZ * 16)).getChunk().getEntities()) {
if (e.getLocation().distance(l) <= radius && e.getLocation().getBlock() != l.getBlock()) {
radiusEntities.add(e);
}
}
}
}
return radiusEntities;
}
代码示例来源:origin: zDevelopers/ImageOnMap
static public ItemFrame getEmptyFrameAt(Location location, BlockFace facing)
{
Entity entities[] = location.getChunk().getEntities();
for(Entity entity : entities)
{
if(!(entity instanceof ItemFrame)) continue;
if(!WorldUtils.blockEquals(location, entity.getLocation())) continue;
ItemFrame frame = (ItemFrame) entity;
if(frame.getFacing() != facing) continue;
ItemStack item = frame.getItem();
if(item.getType() != Material.AIR) continue;
return frame;
}
return null;
}
}
代码示例来源:origin: libraryaddict/LibsDisguises
@EventHandler
public void onChunkLoad(ChunkLoadEvent event) {
if (!DisguiseConfig.isSaveEntityDisguises())
return;
for (Entity entity : event.getChunk().getEntities()) {
Disguise[] disguises = DisguiseUtilities.getSavedDisguises(entity.getUniqueId(), true);
if (disguises.length <= 0)
continue;
DisguiseUtilities.resetPluginTimer();
for (Disguise disguise : disguises) {
disguise.setEntity(entity);
disguise.startDisguise();
}
}
}
代码示例来源:origin: TheBusyBiscuit/Slimefun4
public static ArmorStand getArmorStand(Block projector) {
String nametag = ChatColor.translateAlternateColorCodes('&', BlockStorage.getLocationInfo(projector.getLocation(), "text"));
double offset = Double.valueOf(BlockStorage.getLocationInfo(projector.getLocation(), "offset"));
Location l = new Location(projector.getWorld(), projector.getX() + 0.5, projector.getY() + offset, projector.getZ() + 0.5);
for (Entity n: l.getChunk().getEntities()) {
if (n instanceof ArmorStand) {
if (n.getCustomName() != null && n.getCustomName().equals(nametag) && l.distanceSquared(n.getLocation()) < 0.4D) return (ArmorStand) n;
}
}
ArmorStand hologram = ArmorStandFactory.createHidden(l);
hologram.setCustomName(nametag);
return hologram;
}
代码示例来源:origin: TheBusyBiscuit/Slimefun4
private static ArmorStand getArmorStand(Block b) {
Location l = new Location(b.getWorld(), b.getX() + 0.5, b.getY() - 0.7F, b.getZ() + 0.5);
for (Entity n: l.getChunk().getEntities()) {
if (n instanceof ArmorStand) {
if (n.getCustomName() != null && l.distanceSquared(n.getLocation()) < 0.4D) return (ArmorStand) n;
}
}
ArmorStand hologram = ArmorStandFactory.createHidden(l);
return hologram;
}
代码示例来源:origin: TheBusyBiscuit/Slimefun4
private static ArmorStand getArmorStand(Block b) {
Location l = new Location(b.getWorld(), b.getX() + 0.5, b.getY() - 0.7F, b.getZ() + 0.5);
for (Entity n: l.getChunk().getEntities()) {
if (n instanceof ArmorStand) {
if (n.getCustomName() != null && l.distanceSquared(n.getLocation()) < 0.4D) return (ArmorStand) n;
}
}
ArmorStand hologram = ArmorStandFactory.createHidden(l);
return hologram;
}
代码示例来源:origin: TheBusyBiscuit/Slimefun4
public static ArmorStand getArmorStand(Location reactor) {
Location l = new Location(reactor.getWorld(), reactor.getX() + 0.5, reactor.getY(), reactor.getZ() + 0.5);
for (Entity n : l.getChunk().getEntities()) {
if (n instanceof ArmorStand) {
if (l.distanceSquared(n.getLocation()) < 0.4D) return (ArmorStand) n;
}
}
ArmorStand hologram = ArmorStandFactory.createHidden(l);
hologram.setCustomNameVisible(false);
hologram.setCustomName(null);
return hologram;
}
代码示例来源:origin: TheBusyBiscuit/Slimefun4
public static ArmorStand getArmorStand(Block hopper) {
Location l = new Location(hopper.getWorld(), hopper.getX() + 0.5, hopper.getY(), hopper.getZ() + 0.5);
for (Entity n: l.getChunk().getEntities()) {
if (n instanceof ArmorStand) {
if (n.getCustomName() == null && l.distanceSquared(n.getLocation()) < 0.4D) return (ArmorStand) n;
}
}
ArmorStand hologram = ArmorStandFactory.createHidden(l);
hologram.setCustomNameVisible(false);
hologram.setCustomName(null);
return hologram;
}
代码示例来源:origin: TheBusyBiscuit/Slimefun4
public static ArmorStand getArmorStand(Block hopper) {
Location l = new Location(hopper.getWorld(), hopper.getX() + 0.5, hopper.getY() + offset, hopper.getZ() + 0.5);
for (Entity n: l.getChunk().getEntities()) {
if (n instanceof ArmorStand) {
if (n.getCustomName() == null && l.distanceSquared(n.getLocation()) < 0.4D) return (ArmorStand) n;
}
}
ArmorStand hologram = ArmorStandFactory.createHidden(l);
hologram.setCustomNameVisible(false);
hologram.setCustomName(null);
return hologram;
}
代码示例来源:origin: TheBusyBiscuit/Slimefun4
public static ArmorStand getArmorStand(Block hopper) {
Location l = new Location(hopper.getWorld(), hopper.getX() + 0.5, hopper.getY() + offset, hopper.getZ() + 0.5);
for (Entity n: l.getChunk().getEntities()) {
if (n instanceof ArmorStand) {
if (n.getCustomName() == null && l.distanceSquared(n.getLocation()) < 0.4D) return (ArmorStand) n;
}
}
ArmorStand hologram = ArmorStandFactory.createHidden(l);
hologram.setCustomNameVisible(false);
hologram.setCustomName(null);
return hologram;
}
代码示例来源:origin: TheBusyBiscuit/Slimefun4
private static ArmorStand getArmorStand(Block b) {
Location l = new Location(b.getWorld(), b.getX() + 0.5, b.getY() + offset, b.getZ() + 0.5);
for (Entity n: l.getChunk().getEntities()) {
if (n instanceof ArmorStand) {
if (n.getCustomName() == null && l.distanceSquared(n.getLocation()) < 0.4D) return (ArmorStand) n;
}
}
ArmorStand hologram = ArmorStandFactory.createHidden(l);
hologram.setCustomNameVisible(false);
hologram.setCustomName(null);
return hologram;
}
代码示例来源:origin: TheBusyBiscuit/Slimefun4
public static ArmorStand getArmorStand(Block hopper, boolean createIfNoneFound) {
Location l = new Location(hopper.getWorld(), hopper.getX() + 0.5, hopper.getY() + offset, hopper.getZ() + 0.5);
for (Entity n: l.getChunk().getEntities()) {
if (n instanceof ArmorStand) {
if (n.getCustomName() == null && l.distanceSquared(n.getLocation()) < 0.4D) return (ArmorStand) n;
}
}
if (!createIfNoneFound) {
return null;
}
ArmorStand hologram = ArmorStandFactory.createHidden(l);
hologram.setCustomNameVisible(false);
hologram.setCustomName(null);
return hologram;
}
内容来源于网络,如有侵权,请联系作者删除!