类net.minecraft.util.EntityDamageSourceIndirect源码实例Demo

下面列出了怎么用net.minecraft.util.EntityDamageSourceIndirect的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: ToroQuest   文件: EntityMonolithEye.java
public boolean attackEntityFrom(DamageSource source, float amount) {
	if (this.isEntityInvulnerable(source)) {
		return false;
	}

	if (!world.isRemote) {
		if (source instanceof EntityDamageSourceIndirect) {
			redirectArrowAtAttacker(source);
		} else {
			redirectAttack(source, amount);
		}
	}

	return false;
}
 
源代码2 项目: ToroQuest   文件: EntityMage.java
public boolean attackEntityFrom(DamageSource source, float amount) {
	if (this.isEntityInvulnerable(source)) {
		return false;
	}

	if (source instanceof EntityDamageSourceIndirect) {
		redirectArrowAtAttacker(source);
		return false;
	} else {
		amount = redirectAttack(source, amount);
	}

	return super.attackEntityFrom(source, amount);
}
 
源代码3 项目: ToroQuest   文件: EntityBas.java
public boolean attackEntityFrom(DamageSource source, float amount) {
	if (this.isEntityInvulnerable(source)) {
		return false;
	}

	if (source instanceof EntityDamageSourceIndirect) {
		attackDistantAttackerWithBats(source);
	}

	return super.attackEntityFrom(source, amount);
}
 
源代码4 项目: Cyberware   文件: ItemSkinUpgrade.java
@SubscribeEvent
public void handleHurt(LivingHurtEvent event)
{
	EntityLivingBase e = event.getEntityLiving();

	if (CyberwareAPI.isCyberwareInstalled(e, new ItemStack(this, 1, 1)))
	{
		if (event.getSource() instanceof EntityDamageSource && !(event.getSource() instanceof EntityDamageSourceIndirect))
		{
			for (ItemStack stack : e.getArmorInventoryList())
			{
				if (stack != null && stack.getItem() instanceof ItemArmor)
				{
					if (((ItemArmor) stack.getItem()).getArmorMaterial().getDamageReductionAmount(EntityEquipmentSlot.CHEST) > 4)
					{
						return;
					}
				}
				else if (stack != null && stack.getItem() instanceof ISpecialArmor)
				{
					if (((ISpecialArmor) stack.getItem()).getProperties(e, stack, event.getSource(), event.getAmount(), 1).AbsorbRatio * 25D > 4)
					{
						return;
					}
				}
			}
			
			Random random = e.getRNG();
			Entity attacker = ((EntityDamageSource) event.getSource()).getSourceOfDamage();
			int level = 2;
			if (EnchantmentThorns.shouldHit(3, random))
			{
				if (attacker != null)
				{
					attacker.attackEntityFrom(DamageSource.causeThornsDamage(e), (float) EnchantmentThorns.getDamage(2, random));
				}
			}
		}
	}
}
 
源代码5 项目: Et-Futurum   文件: ServerEventHandler.java
@SubscribeEvent
public void livingAttack(LivingAttackEvent event) {
	if (event.source instanceof EntityDamageSourceIndirect) {
		EntityDamageSourceIndirect dmgSrc = (EntityDamageSourceIndirect) event.source;
		if (dmgSrc.getSourceOfDamage() instanceof EntityTippedArrow) {
			EntityTippedArrow tippedArrow = (EntityTippedArrow) dmgSrc.getSourceOfDamage();
			if (!tippedArrow.worldObj.isRemote)
				event.entityLiving.addPotionEffect(tippedArrow.getEffect());
		}
	}
}
 
源代码6 项目: ToroQuest   文件: EntityMonolithEye.java
private boolean hitByRangedAttack(DamageSource source) {
	return source instanceof EntityDamageSourceIndirect;
}
 
源代码7 项目: ToroQuest   文件: EntityToro.java
protected boolean ignoreableAttack(DamageSource source) {
	return !this.isEntityInvulnerable(source) && !(source instanceof EntityDamageSourceIndirect);
}
 
源代码8 项目: Cyberware   文件: ItemMuscleUpgrade.java
@SubscribeEvent
public void handleHurt(LivingHurtEvent event)
{
	EntityLivingBase e = event.getEntityLiving();

	ItemStack test = new ItemStack(this, 1, 0);
	int rank = CyberwareAPI.getCyberwareRank(e, test);
	if (!event.isCanceled() && e instanceof EntityPlayer && (rank > 1) && EnableDisableHelper.isEnabled(CyberwareAPI.getCyberware(e, test)) && getLastBoostSpeed(e))
	{
		EntityPlayer p = (EntityPlayer) e;
		if (event.getSource() instanceof EntityDamageSource && !(event.getSource() instanceof EntityDamageSourceIndirect))
		{
			EntityDamageSource source = (EntityDamageSource) event.getSource();
			Entity attacker = source.getEntity();
			int lastAttacked = ReflectionHelper.getPrivateValue(CombatTracker.class, p.getCombatTracker(), 2);
			
			if (p.ticksExisted - lastAttacked > 120)
			{
				ItemStack weapon = p.getHeldItemMainhand();
				int loc = -1;
				if (weapon != null)
				{
					if (p.getItemInUseCount() > 0 || weapon.getItem() instanceof ItemSword || weapon.getItem().getAttributeModifiers(EntityEquipmentSlot.MAINHAND, weapon).containsKey(SharedMonsterAttributes.ATTACK_DAMAGE.getAttributeUnlocalizedName()))
					{
						loc = p.inventory.currentItem;
					}
				}
				
				if (loc == -1)
				{
					double mostDamage = 0F;
					
					for (int i = 0; i < 10; i++)
					{
						if (i != p.inventory.currentItem)
						{
							ItemStack potentialWeapon = p.inventory.mainInventory[i];
							if (potentialWeapon != null)
							{
								Multimap<String, AttributeModifier> modifiers = potentialWeapon.getItem().getAttributeModifiers(EntityEquipmentSlot.MAINHAND, potentialWeapon);
								if (modifiers.containsKey(SharedMonsterAttributes.ATTACK_DAMAGE.getAttributeUnlocalizedName()))
								{
									double damage = modifiers.get(SharedMonsterAttributes.ATTACK_DAMAGE.getAttributeUnlocalizedName()).iterator().next().getAmount();
									
									if (damage > mostDamage || loc == -1)
									{
										mostDamage = damage;
										loc = i;
									}
								}
							}
						}
					}
				}
				
				if (loc != -1)
				{
					//System.out.println("LOC " + loc);

					p.inventory.currentItem = loc;

		
					CyberwarePacketHandler.INSTANCE.sendTo(new SwitchHeldItemAndRotationPacket(loc, p.getEntityId(), rank > 2 ? attacker.getEntityId() : -1), (EntityPlayerMP) p);
					
					WorldServer world = (WorldServer) p.worldObj;
					
					for (EntityPlayer trackingPlayer : world.getEntityTracker().getTrackingPlayers(p))
					{
						CyberwarePacketHandler.INSTANCE.sendTo(new SwitchHeldItemAndRotationPacket(loc, p.getEntityId(), rank > 2 ? attacker.getEntityId() : -1), (EntityPlayerMP) trackingPlayer);
					}
					
				}
			}

		}

	}
}
 
源代码9 项目: EnderZoo   文件: EntityEnderminy.java
/**
 * Called when the entity is attacked.
 */
@Override
public boolean attackEntityFrom(DamageSource damageSource, float p_70097_2_) {

  if(isEntityInvulnerable(damageSource)) {
    return false;
  }

  setScreaming(true);

  if(damageSource instanceof EntityDamageSourceIndirect) {
    isAggressive = false;
    for (int i = 0; i < 64; ++i) {
      if(teleportRandomly()) {
        return true;
      }
    }
    return super.attackEntityFrom(damageSource, p_70097_2_);
  }

  boolean res = super.attackEntityFrom(damageSource, p_70097_2_);
  if(damageSource instanceof EntityDamageSource && damageSource.getTrueSource() instanceof EntityPlayer &&
      getHealth() > 0
  //&& !ItemDarkSteelSword.isEquippedAndPowered((EntityPlayer) damageSource.getEntity(), 1)) {
  ) {
    isAggressive = true;
    if(rand.nextInt(3) == 0) {
      for (int i = 0; i < 64; ++i) {
        if(teleportRandomly(16)) {
          setAttackTarget((EntityPlayer) damageSource.getTrueSource());
          doGroupArgo();
          return true;
        }
      }
    }
  }

  if(res) {
    doGroupArgo();
  }
  return res;

}
 
 类所在包
 同包方法