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