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


Java Item.getNearbyEntities方法代碼示例

本文整理匯總了Java中org.bukkit.entity.Item.getNearbyEntities方法的典型用法代碼示例。如果您正苦於以下問題:Java Item.getNearbyEntities方法的具體用法?Java Item.getNearbyEntities怎麽用?Java Item.getNearbyEntities使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.bukkit.entity.Item的用法示例。


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

示例1: run

import org.bukkit.entity.Item; //導入方法依賴的package包/類
@Override
public void run() {
    for(Item item : Bukkit.getWorlds().get(0).getEntitiesByClass(Item.class)) {
        if(item.getItemStack().getType() != Material.GHAST_TEAR) continue;
        UUID skip = Gizmos.gunGizmo.items.get(item);

        for(Entity entity : item.getNearbyEntities(0.5d, 0.5d, 0.5d)) {
            if(entity instanceof Player && !entity.getUniqueId().equals(skip)) {
                Player player = (Player) entity;
                if(player.hasPermission("gizmo.immunity")) continue;
                player.damage(0d, item);
                Gizmos.gunGizmo.gifts.add(player.getUniqueId());
                item.remove();
                break;
            }
        }

        if(item.getTicksLived() >= 6000) item.remove();
    }
}
 
開發者ID:OvercastNetwork,項目名稱:ProjectAres,代碼行數:21,代碼來源:GunGizmo.java

示例2: trigger

import org.bukkit.entity.Item; //導入方法依賴的package包/類
@Override
public void trigger(Player player, Item grenade) {
	grenade.getWorld().createExplosion(grenade.getLocation(), 0);
	List<Entity> entities = grenade.getNearbyEntities(radius, radius, radius);
	for(Entity ent: entities){
		if(ent instanceof Player){
			Player pl = (Player) ent;
			pl.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 100, 1));
		}
	}
	
	grenade.remove();
}
 
開發者ID:viktorstrate,項目名稱:mcAssault,代碼行數:14,代碼來源:Flashbang.java

示例3: onItemSpawn

import org.bukkit.entity.Item; //導入方法依賴的package包/類
/**
 * Concentrate stacks
 *
 * @param event Event
 */
@EventHandler
public void onItemSpawn(ItemSpawnEvent event)
{
    if (event.getEntityType() != EntityType.DROPPED_ITEM)
        return;

    Item newEntity = event.getEntity();
    List<Entity> entityList = newEntity.getNearbyEntities(this.radius, 1, this.radius);
    int maxSize = newEntity.getItemStack().getMaxStackSize();

    for (Entity anEntityList : entityList)
    {
        if (anEntityList instanceof Item)
        {
            Item curEntity = (Item) anEntityList;

            if (!curEntity.isDead()
                    && curEntity.getItemStack().getType().equals(newEntity.getItemStack().getType())
                    && curEntity.getItemStack().getData().getData() == newEntity.getItemStack().getData().getData()
                    && curEntity.getItemStack().getDurability() == newEntity.getItemStack().getDurability()
                    && Math.abs(curEntity.getLocation().getX() - newEntity.getLocation().getX()) <= this.radius
                    && Math.abs(curEntity.getLocation().getY() - newEntity.getLocation().getY()) <= this.radius
                    && Math.abs(curEntity.getLocation().getZ() - newEntity.getLocation().getZ()) <= this.radius)
            {
                int newAmount = newEntity.getItemStack().getAmount();
                int curAmount = curEntity.getItemStack().getAmount();
                int more = Math.min(newAmount, maxSize - curAmount);

                curAmount += more;
                newAmount -= more;
                curEntity.getItemStack().setAmount(curAmount);
                newEntity.getItemStack().setAmount(newAmount);

                if (newAmount <= 0)
                    event.setCancelled(true);

                return;
            }
        }
    }
}
 
開發者ID:SamaGames,項目名稱:SurvivalAPI,代碼行數:47,代碼來源:OptimizationListener.java


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