本文整理匯總了Java中net.minecraft.entity.passive.EntityTameable.heal方法的典型用法代碼示例。如果您正苦於以下問題:Java EntityTameable.heal方法的具體用法?Java EntityTameable.heal怎麽用?Java EntityTameable.heal使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類net.minecraft.entity.passive.EntityTameable
的用法示例。
在下文中一共展示了EntityTameable.heal方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onWornTick
import net.minecraft.entity.passive.EntityTameable; //導入方法依賴的package包/類
@Override
public boolean onWornTick(World world, ItemStack stack, EntityLivingBase entity) {
if (entity instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer) entity;
double x = player.posX;
double y = player.posY;
double z = player.posZ;
List<EntityTameable> entities = player.worldObj.getEntitiesWithinAABB(EntityTameable.class, AxisAlignedBB.getBoundingBox(x - 8, y - 8, z - 8, x + 8, y + 8, z + 8));
for (EntityTameable entityTame : entities) {
if (!player.worldObj.isRemote) {
if (player.worldObj.rand.nextInt(60) == 0 && entityTame.isTamed()) {
entityTame.heal(1);
return true;
}
}
}
}
return false;
}
示例2: onWornTick
import net.minecraft.entity.passive.EntityTameable; //導入方法依賴的package包/類
@Override
public int onWornTick(ItemStack stack, EntityLivingBase entity, ITrinket item) {
if (!entity.worldObj.isRemote) {
List<EntityTameable> entities = getEntitiesAround(entity, 8, EntityTameable.class);
for (EntityTameable entityTame : entities) {
if (entity.worldObj.rand.nextInt(60) == 0 && entityTame.isTamed() && hasEnergy(item, stack, getUsage())) {
entityTame.heal(1);
return getUsage();
}
}
}
return 0;
}