Java Code Examples for net.minecraft.util.DamageSource#isMagicDamage()

The following examples show how to use net.minecraft.util.DamageSource#isMagicDamage() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CraftDamageSource.java    From Kettle with GNU General Public License v3.0 6 votes vote down vote up
public static DamageSource copyOf(final DamageSource original) {
    CraftDamageSource newSource = new CraftDamageSource(original.damageType);

    // Check ignoresArmor
    if (original.isUnblockable()) {
        newSource.setDamageBypassesArmor();
    }

    // Check magic
    if (original.isMagicDamage()) {
        newSource.setMagicDamage();
    }

    // Check fire
    if (original.isExplosion()) {
        newSource.setExplosion();
    }

    return newSource;
}
 
Example 2
Source File: EntitySpiritBlight.java    From Wizardry with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public boolean attackEntityFrom(@Nonnull DamageSource source, float amount) {
	if (source.isMagicDamage()) {
		super.attackEntityFrom(source, amount);
		ClientRunnable.run(new ClientRunnable() {
			@Override
			@SideOnly(Side.CLIENT)
			public void runIfClient() {
				LibParticles.SPIRIT_WIGHT_HURT(world, getPositionVector());
			}
		});
		return true;
	} else return false;
}
 
Example 3
Source File: EntitySpiritWight.java    From Wizardry with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public boolean attackEntityFrom(@Nonnull DamageSource source, float amount) {
	if (source.isMagicDamage() || source == DamageSource.OUT_OF_WORLD) {
		super.attackEntityFrom(source, amount);
		ClientRunnable.run(new ClientRunnable() {
			@Override
			@SideOnly(Side.CLIENT)
			public void runIfClient() {
				LibParticles.SPIRIT_WIGHT_HURT(world, getPositionVector());
			}
		});
		return true;
	} else return false;
}
 
Example 4
Source File: EntityMage.java    From ToroQuest with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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;
}
 
Example 5
Source File: EntityWitherWitch.java    From EnderZoo with Creative Commons Zero v1.0 Universal 5 votes vote down vote up
@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;
}