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

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

源代码1 项目: TofuCraftReload   文件: EntityTofuGandlem.java
@Override
public boolean attackEntityFrom(DamageSource source, float amount) {
    if (this.isEntityInvulnerable(source)) {
        return false;
    } else if (source.getImmediateSource() instanceof EntityFukumame) {
        return false;
    } else {
        if (isSleep()) {
            setSleep(false);

           /* if(source.getImmediateSource() instanceof EntityPlayerMP) {
                this.bossInfo.addPlayer((EntityPlayerMP) source.getImmediateSource());
            }*/
        }
        if (source.getImmediateSource() instanceof EntityArrow) {
            return super.attackEntityFrom(source, amount * 0.8F);
        } else {
            return super.attackEntityFrom(source, amount);
        }
    }
}
 
源代码2 项目: ExNihiloAdscensio   文件: ProjectileStone.java
@Override
protected void onImpact(RayTraceResult result)
{
    if (result.entityHit != null)
    {
        result.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, getThrower()), (int) (Math.random() * (4.0F / 3.0F)));
    }
    else if (!world.isRemote)
    {
        setDead();
        
        if(stack != null)
        {
            world.spawnEntity(new EntityItem(world, posX, posY, posZ, stack));
        }
    }
    
    for (int j = 0; j < 8; ++j)
    {
        world.spawnParticle(EnumParticleTypes.BLOCK_CRACK, posX, posY, posZ, 0.0D, 0.0D, 0.0D, new int[] { Block.getStateId(Blocks.STONE.getDefaultState()) });
    }
}
 
源代码3 项目: TofuCraftReload   文件: EntityTofunian.java
public void onDeath(DamageSource cause) {
    if (this.village != null) {
        Entity entity = cause.getTrueSource();

        if (entity != null) {
            if (entity instanceof EntityPlayer) {
                this.village.modifyPlayerReputation(entity.getUniqueID(), -2);
            } else if (entity instanceof IMob) {
                this.village.endMatingSeason();
            }
        } else {
            EntityPlayer entityplayer = this.world.getClosestPlayerToEntity(this, 16.0D);

            if (entityplayer != null) {
                this.village.endMatingSeason();
            }
        }
    }

    super.onDeath(cause);
}
 
源代码4 项目: TofuCraftReload   文件: EntityFukumame.java
/**
 * Called when this EntityThrowable hits a block or entity.
 */
@Override
protected void onImpact(RayTraceResult par1MovingObjectPosition) {
    Entity entityHit = par1MovingObjectPosition.entityHit;
    if (entityHit == this.ignoreEntity && this.age < 5) {
        return;
    }
    if (par1MovingObjectPosition.entityHit != null) {
        double d = this.getDamage();
        d *= this.isCrit ? 2.5D : 1.0D;


        entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), (float) d);
        if (entityHit instanceof EntityLivingBase) {
            EntityLivingBase entityLivivng = (EntityLivingBase) entityHit;
            entityLivivng.hurtResistantTime = entityLivivng.maxHurtResistantTime / 2;
        }
        for (int i = 0; i < 3; ++i) {
            this.world.spawnParticle(EnumParticleTypes.SNOWBALL, this.posX, this.posY, this.posZ, 0.0D, 0.0D, 0.0D);
        }
    }

    if (!this.world.isRemote) {
        this.setDead();
    }
}
 
源代码5 项目: mocreaturesdev   文件: MoCEntityWyvern.java
@Override
protected void attackEntity(Entity entity, float f)
{
    
    if (attackTime <= 0 && (f < 3.0D) && (entity.boundingBox.maxY > boundingBox.minY) && (entity.boundingBox.minY < boundingBox.maxY))
    {
        attackTime = 20;
        boolean flag = (rand.nextInt(3) == 0);
        if (flag)
        {
            if (entity instanceof EntityPlayer) 
            {
            	MoCreatures.poisonPlayer((EntityPlayer) entity);
            }
            ((EntityLiving) entity).addPotionEffect(new PotionEffect(Potion.poison.id, 200, 0));
            MoCTools.playCustomSound(this, "wyvernpoisoning", worldObj);
        }
        
        int dmg = 5;
        if (getType() >= 5) dmg = 10;
        entity.attackEntityFrom(DamageSource.causeMobDamage(this), dmg);
        openMouth();
    }
}
 
源代码6 项目: mocreaturesdev   文件: MoCEntityPetScorpion.java
@Override
public boolean attackEntityFrom(DamageSource damagesource, int i)
{
    if (super.attackEntityFrom(damagesource, i))
    {
        Entity entity = damagesource.getEntity();
        if ((entity != null) && (entity instanceof EntityPlayer) && getIsTamed()) { return false; }

        if ((entity != null) && (entity != this) && (worldObj.difficultySetting > 0) && getIsAdult())
        {
            entityToAttack = entity;
        }
        return true;
    }
    else
    {
        return false;
    }
}
 
源代码7 项目: mocreaturesdev   文件: MoCTools.java
public static void buckleMobs(EntityLiving entityattacker, Double dist, World worldObj)
{
    List list = worldObj.getEntitiesWithinAABBExcludingEntity(entityattacker, entityattacker.boundingBox.expand(dist, 2D, dist));
    for (int i = 0; i < list.size(); i++)
    {
        Entity entitytarget = (Entity) list.get(i);
        if (!(entitytarget instanceof EntityLiving) || (entityattacker.riddenByEntity != null && entitytarget == entityattacker.riddenByEntity))
        {
            continue;
        }
        //EntityMob entitymob = (EntityMob) entity;
        entitytarget.attackEntityFrom(DamageSource.causeMobDamage(entityattacker), 2);
        bigsmack(entityattacker, entitytarget, 0.6F);
        playCustomSound(entityattacker, "tud", worldObj);
        //todo tuck sound!!
    }
}
 
源代码8 项目: mocreaturesdev   文件: MoCEntityDolphin.java
@Override
public boolean attackEntityFrom(DamageSource damagesource, int i)
{
    if (super.attackEntityFrom(damagesource, i) && (worldObj.difficultySetting > 0))
    {
        Entity entity = damagesource.getEntity();
        if ((riddenByEntity == entity) || (ridingEntity == entity)) { return true; }
        if (entity != this)
        {
            entityToAttack = entity;
        }
        return true;
    }
    else
    {
        return false;
    }
}
 
源代码9 项目: Gadomancy   文件: RegisteredFamiliarAI_Old.java
@Override
public void tick(int ticksSoFar, World world, EntityPlayer parent, ItemStack itemStack) {
    int rangeInc = ((ItemFamiliar_Old) itemStack.getItem()).getAttackRangeIncrease(itemStack);

    List<EntityLivingBase> lastTargetters = getPotentialTargets(world, parent, rangeInc);
    if(lastTargetters.size() == 0) {
        FamiliarAIController_Old.cleanTargetterList(parent);
        return;
    }
    EntityLivingBase mob = lastTargetters.get(world.rand.nextInt(lastTargetters.size()));
    if(mob.isDead || mob instanceof EntityPlayer) {
        FamiliarAIController_Old.cleanTargetterList(parent);
        return;
    }

    mob.attackEntityFrom(DamageSource.magic, ((ItemFamiliar_Old) itemStack.getItem()).getAttackStrength(itemStack));

    world.playSoundEffect(mob.posX + 0.5, mob.posY + 0.5, mob.posZ + 0.5, "thaumcraft:zap", 0.8F, 1.0F);

    PacketFamiliarBolt bolt = new PacketFamiliarBolt(parent.getCommandSenderName(), (float) mob.posX, (float) mob.posY, (float) mob.posZ, 6, true);
    PacketHandler.INSTANCE.sendToAllAround(bolt, new NetworkRegistry.TargetPoint(mob.worldObj.provider.dimensionId, mob.posX, mob.posY, mob.posZ, 32));
    FamiliarAIController_Old.cleanTargetterList(parent);
}
 
源代码10 项目: mocreaturesdev   文件: MoCEntityShark.java
@Override
public boolean attackEntityFrom(DamageSource damagesource, int i)
{
    if (super.attackEntityFrom(damagesource, i) && (worldObj.difficultySetting > 0))
    {
        Entity entity = damagesource.getEntity();
        if ((riddenByEntity == entity) || (ridingEntity == entity)) { return true; }
        if (entity != this)
        {
            entityToAttack = entity;
        }
        return true;
    }
    else
    {
        return false;
    }
}
 
源代码11 项目: mocreaturesdev   文件: MoCEntityWyvern.java
@Override
public boolean attackEntityFrom(DamageSource damagesource, int i)
{
    if (super.attackEntityFrom(damagesource, i))
    {
        Entity entity = damagesource.getEntity();
     
        
        if (entity != null && getIsTamed() && entity instanceof EntityPlayer) { return false; }
        

        if ((riddenByEntity != null) && (entity == riddenByEntity)) { return false; }
        
        if ((entity != this) && (worldObj.difficultySetting > 0))
        {
            entityToAttack = entity;
        }
        return true;
    }
    return false;
}
 
源代码12 项目: mocreaturesdev   文件: MoCEntityScorpion.java
@Override
public boolean attackEntityFrom(DamageSource damagesource, int i)
{
    if (super.attackEntityFrom(damagesource, i))
    {
        Entity entity = damagesource.getEntity();
        //if ((entity != null) && (entity instanceof EntityPlayer) && getIsTamed()) { return false; }

        if ((entity != null) && (entity != this) && (worldObj.difficultySetting > 0) && getIsAdult())
        {
            entityToAttack = entity;
        }
        return true;
    }
    else
    {
        return false;
    }
}
 
源代码13 项目: archimedes-ships   文件: EntityShip.java
@Override
public boolean attackEntityFrom(DamageSource source, float damage)
{
	/*if (source.isExplosion())
	{
		if (source.getEntity() != null && source.getEntity().getClass().getName().equals("ckathode.weaponmod.entity.projectile.EntityCannonBall"))
		{
			double dx = source.getEntity().posX - posX;
			double dy = source.getEntity().posY - posY;
			double dz = source.getEntity().posZ - posZ;
			
			Vec3 vec = worldObj.getWorldVec3Pool().getVecFromPool(dx, dy, dz);
			vec.rotateAroundY((float) Math.toRadians(-rotationYaw));
			
			worldObj.createExplosion(source.getEntity(), source.getEntity().posX, source.getEntity().posY, source.getEntity().posZ, 4F, false);
			source.getEntity().setDead();
		}
	}*/
	return false;
}
 
源代码14 项目: mocreaturesdev   文件: MoCEntityFlameWraith.java
@Override
protected void attackEntity(Entity entity, float f)
{
    if (attackTime <= 0 && (f < 2.5D) && (entity.boundingBox.maxY > boundingBox.minY) && (entity.boundingBox.minY < boundingBox.maxY))
    {
        attackTime = 20;
        entity.attackEntityFrom(DamageSource.causeMobDamage(this), 2);

        if (MoCreatures.isServer() && !worldObj.provider.isHellWorld)
        {
            ((EntityLiving) entity).setFire(burningTime);
        }

        //entity.fire = burningTime;
    }
}
 
源代码15 项目: 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;
}
 
源代码16 项目: Gadomancy   文件: TileExtendedNode.java
private boolean handleGrowingNodeSecond(boolean needUpdate) {
    if(extendedNodeType == null || extendedNodeType != ExtendedNodeType.GROWING) return needUpdate;

    if(worldObj.difficultySetting == EnumDifficulty.PEACEFUL) return needUpdate;
    if(worldObj.isRemote) return needUpdate;
    if(ticksExisted % 8 != 0) return needUpdate;

    List livingEntities = worldObj.getEntitiesWithinAABB(EntityLivingBase.class, AxisAlignedBB.getBoundingBox(xCoord, yCoord, zCoord, xCoord + 1, yCoord + 1, zCoord + 1).expand(6.0D, 6.0D, 6.0D));
    if ((livingEntities != null) && (livingEntities.size() > 0)) {
        for (Object e : livingEntities) {
            EntityLivingBase livingEntity = (EntityLivingBase) e;
            if ((livingEntity.isEntityAlive()) && (!livingEntity.isEntityInvulnerable())) {
                if(livingEntity instanceof EntityPlayer && ((EntityPlayer) livingEntity).capabilities.isCreativeMode) continue;
                if(!behavior.mayZapNow()) continue;

                ResearchHelper.distributeResearch(Gadomancy.MODID.toUpperCase() + ".GROWING_AGGRESSION", worldObj, xCoord, yCoord, zCoord, 6);

                livingEntity.attackEntityFrom(DamageSource.magic, behavior.getZapDamage());

                worldObj.playSoundEffect(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5, "thaumcraft:zap", 0.8F, 1.0F);

                PacketTCNodeBolt packet = new PacketTCNodeBolt(xCoord + 0.5F, yCoord + 0.5F, zCoord + 0.5F, (float) livingEntity.posX, (float) (livingEntity.posY + livingEntity.height), (float) livingEntity.posZ, 0, false);
                PacketHandler.INSTANCE.sendToAllAround(packet, new NetworkRegistry.TargetPoint(worldObj.provider.dimensionId, xCoord, yCoord, zCoord, 32.0D));
            }
        }
    }

    return needUpdate;
}
 
源代码17 项目: TofuCraftReload   文件: EntityTofunian.java
@Override
public boolean attackEntityAsMob(Entity entityIn) {
    boolean flag = entityIn.attackEntityFrom(DamageSource.causeMobDamage(this), (float) ((int) this.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).getAttributeValue()));

    if (flag) {
        this.applyEnchantments(this, entityIn);
    }

    return flag;
}
 
源代码18 项目: mocreaturesdev   文件: MoCEntityBee.java
@Override
protected void attackEntity(Entity entity, float f)
{

    if (this.attackTime <= 0 && (f < 2.0D) && (entity.boundingBox.maxY > boundingBox.minY) && (entity.boundingBox.minY < boundingBox.maxY))
    {
        attackTime = 20;
        entity.attackEntityFrom(DamageSource.causeMobDamage(this), 2);
    }
}
 
源代码19 项目: EnderZoo   文件: EntityFallenMount.java
@Override
public boolean attackEntityAsMob(Entity target) {
  if(isRidden() || isDead) {
    return false;
  }
  super.attackEntityAsMob(target);
  if(!isRearing()) {
    makeMad();
  }
  float damage = (float) getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).getAttributeValue();
  return target.attackEntityFrom(DamageSource.causeMobDamage(this), damage);
}
 
源代码20 项目: 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);
}
 
源代码21 项目: ToroQuest   文件: EntityBas.java
@Override
public void onDeath(DamageSource cause) {
	super.onDeath(cause);
	if (!world.isRemote) {
		dropLoot();
		achievement(cause);
	}
}
 
源代码22 项目: mocreaturesdev   文件: MoCEntityBigCat.java
@Override
public void onDeath(DamageSource damagesource)
{
	if (MoCreatures.isServer())
    {
    	if (getIsTamed())
    	{
    		MoCTools.dropCustomItem(this, this.worldObj, new ItemStack(MoCreatures.medallion, 1));
    	}
    }
	super.onDeath(damagesource);
}
 
源代码23 项目: mocreaturesdev   文件: MoCEntityKitty.java
@Override
public void onDeath(DamageSource damagesource)
{
	if (MoCreatures.isServer())
    {
    	if (getIsTamed())
    	{
    		MoCTools.dropCustomItem(this, this.worldObj, new ItemStack(MoCreatures.medallion, 1));
    	}
    }
	super.onDeath(damagesource);
}
 
源代码24 项目: mocreaturesdev   文件: MoCEntityCrocodile.java
@Override
public void onDeath(DamageSource damagesource)
{

    unMount();
    MoCTools.checkForTwistedEntities(worldObj);
    super.onDeath(damagesource);
}
 
源代码25 项目: Cyberware   文件: CyberwareDataHandler.java
private boolean shouldDropWare(DamageSource source)
{
	if (source == EssentialsMissingHandler.noessence) return true;
	if (source == EssentialsMissingHandler.heartless) return true;
	if (source == EssentialsMissingHandler.brainless) return true;
	if (source == EssentialsMissingHandler.nomuscles) return true;
	if (source == EssentialsMissingHandler.spineless) return true;

	return false;
}
 
源代码26 项目: 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;
}
 
源代码27 项目: SimplyJetpacks   文件: ItemPack.java
@Override
public ArmorProperties getProperties(EntityLivingBase player, ItemStack armor, DamageSource source, double damage, int slot) {
    T pack = this.getPack(armor);
    if (pack != null && pack.isArmored && !source.isUnblockable()) {
        if (pack.isFluxBased && source.damageType.equals("flux")) {
            return new ArmorProperties(0, 0.5D, Integer.MAX_VALUE);
        }
        int energyPerDamage = this.getFuelPerDamage(armor, pack);
        int maxAbsorbed = energyPerDamage > 0 ? 25 * (this.getFuelStored(armor) / energyPerDamage) : 0;
        return new ArmorProperties(0, 0.85D * (pack.armorReduction / 20.0D), maxAbsorbed);
    }
    return new ArmorProperties(0, 1, 0);
}
 
源代码28 项目: Wizardry   文件: LightningTracker.java
@SubscribeEvent
public void tick(TickEvent.WorldTickEvent event) {
	newEntries.forEach(e -> entityToEntry.put(e.getTarget(), e));
	newEntries.clear();
	
	entityToEntry.keySet().removeIf(entity -> {
		TrackingEntry entry = entityToEntry.get(entity);
		Entity caster = entry.getCaster();
		int ticks = entry.getTicks();
		double potency = entry.getPotency();
		double duration = entry.getDuration();
		
		if (ticks > 0) {
			entry.setTicks(ticks - 1);
			return false;
		}

		entity.setFire((int) duration);
	
		int invTime = entity.hurtResistantTime;
		entity.hurtResistantTime = 0;
		if (caster instanceof EntityPlayer)
			entity.attackEntityFrom(new EntityDamageSource("lightningbolt", caster), (float) potency);
		else entity.attackEntityFrom(DamageSource.LIGHTNING_BOLT, (float) potency);
		entity.hurtResistantTime = invTime;
		return true;
	});
}
 
源代码29 项目: ForbiddenMagic   文件: BloodStaffUpdate.java
public boolean syphonHealth(EntityPlayer player){
    if(player.getHealth() > 3){
        player.setHealth(player.getHealth() - 3);
        return true;
    }
    else if(player.getHealth() > 0){
        player.func_110142_aN().func_94547_a(new DamageSource("blooderp"), 3, 3);
        player.setHealth(0);
        player.onDeath(new DamageSource("blooderp"));
        return true;
    }
    else
        return false;
}
 
源代码30 项目: HexxitGear   文件: AbilityKnockback.java
@Override
public void start(EntityPlayer player) {
    List<EntityLiving> entities = player.worldObj.getEntitiesWithinAABB(EntityLiving.class, AxisAlignedBB.getBoundingBox(player.posX - 5, player.posY, player.posZ - 5, player.posX + 5, player.posY + 3, player.posZ + 5));

    for (EntityLiving entity : entities) {
        double relX = player.posX - entity.posX;
        double relZ = player.posZ - entity.posZ;

        if (!entity.equals(player)) {
            entity.attackEntityFrom(DamageSource.causePlayerDamage(player), 2);
            entity.addVelocity((relX * 0.25) * -1, 0.2, (relZ * 0.25) * -1);
        }
    }
}
 
 类所在包
 同包方法