本文整理匯總了Java中net.minecraft.entity.monster.EntityMob.setTarget方法的典型用法代碼示例。如果您正苦於以下問題:Java EntityMob.setTarget方法的具體用法?Java EntityMob.setTarget怎麽用?Java EntityMob.setTarget使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類net.minecraft.entity.monster.EntityMob
的用法示例。
在下文中一共展示了EntityMob.setTarget方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onUpdate
import net.minecraft.entity.monster.EntityMob; //導入方法依賴的package包/類
@Override
public void onUpdate(ItemStack is, World w, Entity e, int i, boolean isHeld) {
if (w.isRemote || is.getItemDamage() > 0)
return;
if (e instanceof EntityLivingBase) {
final EntityLivingBase sucker = (EntityLivingBase) e;
if ((sucker.getAge() & 127) == 0)
if (sucker.getCreatureAttribute() != EnumCreatureAttribute.UNDEAD) {
final List li = w.getEntitiesWithinAABBExcludingEntity(sucker,
AxisAlignedBB.getBoundingBox(sucker.posX - 32, sucker.posY - 8, sucker.posZ - 32,
sucker.posX + 32, sucker.posY + 24, sucker.posZ + 32));
for (final Object ent : li)
if (ent instanceof EntityMob) {
final EntityMob joker = (EntityMob) ent;
if (joker.getCreatureAttribute() == EnumCreatureAttribute.UNDEAD)
if (ent instanceof IIaSMobGetters) {
((IIaSMobGetters) ent).setSearchTarget(sucker);
} else if (!joker.isInvisible() && joker.getAttackTarget() == null) {
joker.setTarget(sucker);
}
}
}
}
super.onUpdate(is, w, e, i, isHeld);
}
示例2: onImpact
import net.minecraft.entity.monster.EntityMob; //導入方法依賴的package包/類
/**
* Called when this EntityThrowable hits a block or entity.
*/
@Override
protected void onImpact(MovingObjectPosition pom) {
if (pom.typeOfHit == MovingObjectType.BLOCK) {
final Block bl = worldObj.getBlock(pom.blockX, pom.blockY, pom.blockZ);
if (bl.getMaterial() == Material.leaves)
return;
if (bl.isReplaceable(worldObj, pom.blockX, pom.blockY, pom.blockZ))
return;
worldObj.playSoundAtEntity(this, "IceAndShadow2:mob_nyxwight_tele_arrive", 0.8F,
rand.nextFloat() * 0.1F + 0.9F);
if (!worldObj.isRemote) {
final EntityMob spawn = new EntityNyxWightToxic(worldObj);
final ForgeDirection dir = ForgeDirection.getOrientation(pom.sideHit);
final int posBlockX = pom.blockX + dir.offsetX;
final int posBlockY = pom.blockY + (dir.offsetY == 1 ? 0 : -2 + dir.offsetY);
final int posBlockZ = pom.blockZ + dir.offsetZ;
Block bl0 = worldObj.getBlock(posBlockX, posBlockY, posBlockZ);
Block bl1 = worldObj.getBlock(posBlockX, posBlockY + 1, posBlockZ);
Block bl2 = worldObj.getBlock(posBlockX, posBlockY + 2, posBlockZ);
if (!IaSBlockHelper.isAir(bl0) && IaSBlockHelper.isAir(bl1) && IaSBlockHelper.isAir(bl2)) {
pom.blockX = posBlockX;
pom.blockY = posBlockY;
pom.blockZ = posBlockZ;
} else {
boolean rise = false;
if (dir.offsetY == 0) {
final int posBlockY2 = posBlockY + 1;
bl0 = worldObj.getBlock(posBlockX, posBlockY2, posBlockZ);
bl1 = worldObj.getBlock(posBlockX, posBlockY2 + 1, posBlockZ);
bl2 = worldObj.getBlock(posBlockX, posBlockY2 + 2, posBlockZ);
if (!IaSBlockHelper.isAir(bl0) && IaSBlockHelper.isAir(bl1) && IaSBlockHelper.isAir(bl2)) {
rise = true;
pom.blockX = posBlockX;
pom.blockY = posBlockY2;
pom.blockZ = posBlockZ;
}
}
if (rise) {
bl1 = worldObj.getBlock(pom.blockX, pom.blockY + 1, pom.blockZ);
bl2 = worldObj.getBlock(pom.blockX, pom.blockY + 2, pom.blockZ);
while (!IaSBlockHelper.isAir(bl1) && !IaSBlockHelper.isAir(bl2)) {
pom.blockY += 1;
bl1 = worldObj.getBlock(pom.blockX, pom.blockY + 1, pom.blockZ);
bl2 = worldObj.getBlock(pom.blockX, pom.blockY + 2, pom.blockZ);
}
}
}
spawn.setPositionAndRotation(pom.blockX + 0.5, pom.blockY + 1, pom.blockZ + 0.5,
worldObj.rand.nextFloat() * 360F, 0.0F);
if (target != null && !target.isDead) {
spawn.setTarget(target);
}
worldObj.spawnEntityInWorld(spawn);
}
setDead();
}
}