本文整理匯總了Java中org.bukkit.entity.Entity.isValid方法的典型用法代碼示例。如果您正苦於以下問題:Java Entity.isValid方法的具體用法?Java Entity.isValid怎麽用?Java Entity.isValid使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.bukkit.entity.Entity
的用法示例。
在下文中一共展示了Entity.isValid方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: damageEntity
import org.bukkit.entity.Entity; //導入方法依賴的package包/類
public static boolean damageEntity(Entity e, int damage, Entity damager, boolean isSpell, boolean crit) {
if (e == null || !e.isValid())
return false;
if (!((damager instanceof Player) || (e instanceof Player))) // Player must be involved
return false;
if (e instanceof Player) {
Player p2 = (Player) e;
if (damager instanceof Player && PartyManager.sameParty(p2, (Player) damager))
return false;
if (Spell.plugin.getPD(p2) != null) {
if (!Spell.plugin.getPD(p2).damage(damage, damager, isSpell ? DamageType.NORMAL_SPELL : DamageType.NORMAL, crit))
return false;
if (crit)
Spell.plugin.getPD(p2).playCrit();
}
return true;
} else if (MobManager.spawnedMobs_onlyMain.containsKey(e.getUniqueId())) {
MobData md = MobManager.spawnedMobs_onlyMain.get(e.getUniqueId());
if (!md.damage(damage, damager, isSpell ? DamageType.NORMAL_SPELL : DamageType.NORMAL, crit))
return false;
if (crit)
md.playCrit();
return true;
}
return false;
}
示例2: getSource
import org.bukkit.entity.Entity; //導入方法依賴的package包/類
public Entity getSource() {
net.minecraft.entity.EntityLivingBase source = getHandle().getTntPlacedBy();
if (source != null) {
Entity bukkitEntity = source.getBukkitEntity();
if (bukkitEntity.isValid()) {
return bukkitEntity;
}
}
return null;
}
示例3: damageNearby
import org.bukkit.entity.Entity; //導入方法依賴的package包/類
public static ArrayList<Entity> damageNearby(int damage, Entity damager, Location loc, double radius, ArrayList<Entity> ignore, boolean isSpell, boolean crit, boolean playersOnly) {
ArrayList<Entity> hit = new ArrayList<Entity>();
if (damager == null || !damager.isValid())
return hit;
for (Entity e : RMath.getNearbyEntities(loc, radius)) {
if (playersOnly && !(e instanceof Player))
continue;
if ((ignore != null && ignore.contains(e)) || e == damager)
continue;
if (damageEntity(e, damage, damager, isSpell, crit))
hit.add(e);
}
return hit;
}
示例4: tick
import org.bukkit.entity.Entity; //導入方法依賴的package包/類
protected void tick(Block b)
throws Exception
{
for(Iterator iterator = me.mrCookieSlime.Slimefun.holograms.XPCollector.getArmorStand(b).getNearbyEntities(4D, 4D, 4D).iterator(); iterator.hasNext();)
{
Entity n = (Entity)iterator.next();
if(n instanceof ExperienceOrb)
{
if(ChargableBlock.getCharge(b) < getEnergyConsumption())
return;
if(n.isValid())
{
int xp = getEXP(b) + ((ExperienceOrb)n).getExperience();
ChargableBlock.addCharge(b, -getEnergyConsumption());
n.remove();
int withdrawn = 0;
for(int level = 0; level < getEXP(b); level += 10)
if(fits(b, new ItemStack[] {
new CustomItem(Material.EXP_BOTTLE, "&a\u5B66\u8BC6\u4E4B\u74F6", 0)
}))
{
withdrawn += 10;
pushItems(b, new ItemStack[] {
new CustomItem(Material.EXP_BOTTLE, "&a\u5B66\u8BC6\u4E4B\u74F6", 0)
});
}
BlockStorage.addBlockInfo(b, "stored-exp", String.valueOf(xp - withdrawn));
return;
}
}
}
}