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