当前位置: 首页>>代码示例>>Java>>正文


Java EntityMob.setTarget方法代码示例

本文整理汇总了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);
}
 
开发者ID:TheDaemoness,项目名称:IceAndShadow2,代码行数:26,代码来源:NyxItemAlabaster.java

示例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();
	}
}
 
开发者ID:TheDaemoness,项目名称:IceAndShadow2,代码行数:61,代码来源:EntityWightTeleport.java


注:本文中的net.minecraft.entity.monster.EntityMob.setTarget方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。