/**
* This figures out if the gun's ammo is in the entity's inventory.
*
* @param entity the entity to check
* @return the Bullet type found that is valid for this gun, or null.
*/
public Bullet getAmmo(LivingEntity entity) {
if (entity == null || !enabled)
return null;
ItemStack[] inv;
if (entity instanceof InventoryHolder) {
// complex inventory
InventoryHolder holder = (InventoryHolder) entity;
inv = holder.getInventory().getContents();
} else {
// simple inventory
inv = entity.getEquipment().getArmorContents();
}
if (inv != null) {
for (ItemStack item : inv) {
Bullet bullet = AddGun.getPlugin().getAmmo().findBullet(item);
if (bullet != null && this.allBullets.contains(bullet.getName())) {
return bullet;
}
}
}
return null;
}
StandardGun.java 文件源码
java
阅读 30
收藏 0
点赞 0
评论 0
项目:AddGun
作者:
评论列表
文章目录