net.minecraft.util.DamageSource#getTrueSource ( )源码实例Demo

下面列出了net.minecraft.util.DamageSource#getTrueSource ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: CommunityMod   文件: EntityGnomeWood.java
/**
 * Called when another entity attacks this gnome
 */
@Override
public boolean attackEntityFrom(DamageSource damage, float f)
{
	boolean superflag = super.attackEntityFrom(damage, f);
	if (superflag && !this.isDead && damage.getTrueSource() != null)
	{
		if (this.job != null)
		{
			this.job.finishJob(false);
			this.job = null;
		}
		if (this.gnode != null)
		{	// if home is closer than 4 tiles, gtfo
			if (this.getDistanceSq(this.gnode.getPos().down(2)) < 16.0D) // if distance < 4
			{
				this.gnode.selfDestruct();
			}
		}
		this.panic = true;
	}
	return superflag;
}
 
源代码2 项目: EnderZoo   文件: EntityWitherCat.java
@Override
public boolean attackEntityFrom(DamageSource source, float amount) {
  if (owner != null && source.getTrueSource() == owner) {
    return false;
  }
  boolean res = super.attackEntityFrom(source, amount);
  if (!world.isRemote) {
    if (source.getTrueSource() instanceof EntityLivingBase) {
      if (owner != null) {
        EntityLivingBase ownerHitBy = owner.getRevengeTarget();
        if (ownerHitBy == null) {
          owner.setRevengeTarget((EntityLivingBase) source.getTrueSource());
        }
      } else if (owner == null) {
        setAttackTarget((EntityLivingBase) source.getTrueSource());
      }
    }
  }
  return res;
}
 
源代码3 项目: EnderZoo   文件: EntityDireSlime.java
@Override
public void onDeath(DamageSource damageSource) {
  super.onDeath(damageSource);
  if (!world.isRemote && damageSource != null && damageSource.getTrueSource() instanceof EntityPlayer) {
    SlimeConf nextConf = SlimeConf.getConfForSize(getSlimeSize()).bigger();
    if (nextConf != null && world.rand.nextFloat() <= nextConf.chance) {
      EntityDireSlime spawn = new EntityDireSlime(world);
      spawn.setSlimeSize(nextConf.size,true);
      spawn.setLocationAndAngles(posX, posY, posZ, rotationYaw, 0);
      spawn.onInitialSpawn(world.getDifficultyForLocation(new BlockPos(this)), null);
      if (SpawnUtil.isSpaceAvailableForSpawn(world, spawn, false)) {
        world.spawnEntity(spawn);
      }
    }
  }
}
 
源代码4 项目: Moo-Fluids   文件: EntityFluidCow.java
@Override
public boolean attackEntityFrom(final DamageSource damageSource, final float damageAmount) {
  if (damageSource instanceof EntityDamageSource) {
    EntityDamageSource entityDamageSource = (EntityDamageSource)damageSource;
    if (entityDamageSource.getTrueSource() instanceof EntityPlayer) {
      final EntityPlayer entityPlayer = (EntityPlayer) damageSource.getTrueSource();
      if (entityPlayer.getHeldItem(EnumHand.MAIN_HAND).isEmpty()) {
        applyDamagesToEntity(entityPlayer);
      }
    }
  }
  return super.attackEntityFrom(damageSource, damageAmount);
}
 
源代码5 项目: YouTubeModdingTutorial   文件: EntitySphere.java
@Override
public boolean attackEntityFrom(DamageSource source, float amount) {
    if (this.isEntityInvulnerable(source)) {
        return false;
    } else {
        this.markVelocityChanged();

        if (source.getTrueSource() != null) {
            Vec3d vec3d = source.getTrueSource().getLookVec();

            if (vec3d != null) {
                this.motionX = vec3d.x;
                this.motionY = vec3d.y;
                this.motionZ = vec3d.z;
                this.accelerationX = this.motionX * 0.1D;
                this.accelerationY = this.motionY * 0.1D;
                this.accelerationZ = this.motionZ * 0.1D;
            }

            if (source.getTrueSource() instanceof EntityLivingBase) {
                this.shootingEntity = (EntityLivingBase) source.getTrueSource();
            }

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

	dropRepTo(source.getTrueSource());

	if (source.getTrueSource() instanceof EntityLivingBase) {
		callForHelp((EntityLivingBase) source.getTrueSource());
	}

	return super.attackEntityFrom(source, amount);
}
 
源代码7 项目: ToroQuest   文件: EntityVillageLord.java
protected void achievement(DamageSource cause) {
	if (world.isRemote) {
		return;
	}
	Entity entity = cause.getTrueSource();
	//TODO
	/*
	if (entity != null && entity instanceof EntityPlayer) {
		((EntityPlayer) entity).addStat(LORD_ACHIEVEMNT);
	}
	*/
}
 
源代码8 项目: ToroQuest   文件: EntityFugitive.java
protected void achievement(DamageSource cause) {
	if (world.isRemote) {
		return;
	}
	Entity entity = cause.getTrueSource();
	if (entity != null && entity instanceof EntityPlayer) {
		//((EntityPlayer) entity).addStat(BOUNTY_HUNTER_ACHIEVEMNT);
	}
}
 
源代码9 项目: ToroQuest   文件: EntityMonolithEye.java
protected void redirectArrowAtAttacker(DamageSource source) {
	if ("arrow".equals(source.getDamageType())) {

		if (source.getTrueSource() != null && source.getTrueSource() instanceof EntityLivingBase) {
			attackWithArrow((EntityLivingBase) source.getTrueSource());
		}

		if (source.getImmediateSource() != null) {
			source.getImmediateSource().setDead();
		}

	}
}
 
源代码10 项目: ToroQuest   文件: EntityMage.java
protected void achievement(DamageSource cause) {
	if (world.isRemote) {
		return;
	}
	Entity entity = cause.getTrueSource();
	if (entity != null && entity instanceof EntityPlayer) {
		//TODO
		//((EntityPlayer) entity).addStat(MAGE_ACHIEVEMNT);
	}
}
 
源代码11 项目: ToroQuest   文件: EntityMage.java
/**
 * Reduces damage, depending on potions
 */
protected float applyPotionDamageCalculations(DamageSource source, float damage) {
	damage = super.applyPotionDamageCalculations(source, damage);

	if (source.getTrueSource() == this) {
		damage = 0.0F;
	}

	if (source.isMagicDamage()) {
		damage = (float) ((double) damage * 0.15D);
	}

	return damage;
}
 
源代码12 项目: ToroQuest   文件: EntityMage.java
protected float redirectAttack(DamageSource source, float amount) {
	float reflectFactor = rand.nextFloat();

	float reflectAmount = amount * reflectFactor;
	float passAmount = amount - reflectAmount;

	reflectAmount *= ToroQuestConfiguration.bossAttackDamageMultiplier;

	Entity attacker = source.getTrueSource();
	if (attacker != null) {
		attacker.attackEntityFrom(source, reflectAmount);
	}
	this.world.setEntityState(this, (byte) 15);
	return passAmount;
}
 
源代码13 项目: EnderZoo   文件: EntityWitherWitch.java
@Override
protected float applyPotionDamageCalculations(DamageSource damageSource, float damage) {
  //same as a vanilla witch
  damage = super.applyPotionDamageCalculations(damageSource, damage);
  if(damageSource.getTrueSource() == this) {
    damage = 0.0F;
  }
  if(damageSource.isMagicDamage()) {
    damage = (float) (damage * 0.15D);
  }
  return damage;
}
 
源代码14 项目: ToroQuest   文件: EntityGuard.java
public boolean attackEntityFrom(DamageSource source, float amount) {
	if (!super.attackEntityFrom(source, amount)) {
		return false;
	}

	EntityLivingBase attacker = this.getAttackTarget();
	if (attacker == null && source.getTrueSource() instanceof EntityLivingBase) {
		setAttackTarget((EntityLivingBase) source.getTrueSource());
		callForHelp((EntityLivingBase) source.getTrueSource());
	}
	return true;
}
 
源代码15 项目: ToroQuest   文件: EntityBas.java
protected void attackDistantAttackerWithBats(DamageSource source) {
	if (!(source.getTrueSource() instanceof EntityLivingBase)) {
		return;
	}
	EntityLivingBase distantAttacker = (EntityLivingBase) source.getTrueSource();
	spawnBats(distantAttacker);
}
 
源代码16 项目: ToroQuest   文件: EntityBas.java
protected void achievement(DamageSource cause) {
	if (world.isRemote) {
		return;
	}
	Entity entity = cause.getTrueSource();
	if (entity != null && entity instanceof EntityPlayer) {
		//TODO
		//((EntityPlayer) entity).addStat(BASTION_ACHIEVEMNT);
	}
}
 
源代码17 项目: ToroQuest   文件: EntityRainbowGuard.java
public boolean attackEntityFrom(DamageSource source, float amount) {
	if (!super.attackEntityFrom(source, amount)) {
		return false;
	}

	if (isAtAttention()) {
		setAtAttention(false);
	}

	EntityLivingBase attacker = this.getAttackTarget();
	if (attacker == null && source.getTrueSource() instanceof EntityLivingBase) {
		setAttackTarget((EntityLivingBase) source.getTrueSource());
	}
	return true;
}
 
源代码18 项目: ToroQuest   文件: EntityToro.java
private EntityLivingBase getAttacker(DamageSource source) {
	try {
		return (EntityLivingBase) source.getTrueSource();
	} catch (Exception e) {
		return null;
	}
}
 
源代码19 项目: ToroQuest   文件: EntityMonolithEye.java
protected void redirectAttack(DamageSource source, float amount) {
	Entity attacker = source.getTrueSource();
	if (attacker != null) {
		attacker.attackEntityFrom(source, amount);
	}
}
 
源代码20 项目: 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;

}