use of net.minecraft.util.DamageSource in project BaseMetals by MinecraftModDevelopmentMods.
the class AquariumToolProperty method apply.
@Override
public void apply(ItemStack stack, EntityLivingBase ent) {
if (hasEffect(stack, ent)) {
if (ent.canBreatheUnderwater()) {
final DamageSource extraDamage = DamageSource.GENERIC;
ent.attackEntityFrom(extraDamage, 4f);
}
}
}
use of net.minecraft.util.DamageSource in project BaseMetals by MinecraftModDevelopmentMods.
the class ColdIronToolProperty method apply.
@Override
public void apply(ItemStack stack, EntityLivingBase ent) {
if (hasEffect(stack, ent)) {
final DamageSource extraDamage = DamageSource.GENERIC;
ent.attackEntityFrom(extraDamage, 3f);
}
}
use of net.minecraft.util.DamageSource in project minecolonies by Minecolonies.
the class EntityAIMeleeGuard method attackEntity.
private boolean attackEntity(@NotNull final EntityLivingBase entityToAttack, final float baseDamage) {
double damgeToBeDealt = baseDamage;
if (worker.getHealth() <= 2) {
damgeToBeDealt *= 2;
}
damgeToBeDealt += ((AbstractBuildingGuards) getOwnBuilding()).getOffenceBonus();
final ItemStack heldItem = worker.getHeldItem(EnumHand.MAIN_HAND);
if (heldItem != null) {
if (ItemStackUtils.doesItemServeAsWeapon(heldItem)) {
if (heldItem.getItem() instanceof ItemSword) {
damgeToBeDealt += ((ItemSword) heldItem.getItem()).getAttackDamage();
} else {
damgeToBeDealt += TinkersWeaponHelper.getDamage(heldItem);
}
}
damgeToBeDealt += EnchantmentHelper.getModifierForCreature(heldItem, targetEntity.getCreatureAttribute());
}
targetEntity.attackEntityFrom(new DamageSource(worker.getName()), (float) damgeToBeDealt);
targetEntity.setRevengeTarget(worker);
final int fireAspectModifier = EnchantmentHelper.getFireAspectModifier(worker);
if (fireAspectModifier > 0) {
targetEntity.setFire(fireAspectModifier * FIRE_CHANCE_MULTIPLIER);
}
boolean killedEnemy = false;
if (targetEntity.getHealth() <= 0.0F) {
this.onKilledEntity(targetEntity);
killedEnemy = true;
}
worker.faceEntity(entityToAttack, (float) TURN_AROUND, (float) TURN_AROUND);
worker.getLookHelper().setLookPositionWithEntity(entityToAttack, (float) TURN_AROUND, (float) TURN_AROUND);
final double xDiff = targetEntity.posX - worker.posX;
final double zDiff = targetEntity.posZ - worker.posZ;
final double goToX = xDiff > 0 ? MOVE_MINIMAL : -MOVE_MINIMAL;
final double goToZ = zDiff > 0 ? MOVE_MINIMAL : -MOVE_MINIMAL;
worker.move(MoverType.SELF, goToX, 0, goToZ);
worker.swingArm(EnumHand.MAIN_HAND);
worker.playSound(SoundEvents.ENTITY_PLAYER_ATTACK_SWEEP, (float) BASIC_VOLUME, (float) getRandomPitch());
worker.damageItemInHand(1);
return killedEnemy;
}
use of net.minecraft.util.DamageSource in project minecolonies by Minecolonies.
the class AbstractEntityAIHerder method butcherAnimal.
/**
* Butcher an animal.
*
* @param animal the {@link EntityAnimal} we are butchering
*/
private void butcherAnimal(@Nullable final EntityAnimal animal) {
worker.setLatestStatus(new TextComponentTranslation(TranslationConstants.COM_MINECOLONIES_COREMOD_STATUS_HERDER_BUTCHERING));
if (animal != null && !walkingToAnimal(animal) && !ItemStackUtils.isEmpty(worker.getHeldItemMainhand())) {
worker.swingArm(EnumHand.MAIN_HAND);
animal.attackEntityFrom(new DamageSource(worker.getName()), (float) BUTCHERING_ATTACK_DAMAGE);
worker.getHeldItemMainhand().damageItem(1, animal);
}
}
use of net.minecraft.util.DamageSource in project Minestuck by mraof.
the class ItemRandomWeapon method hitEntity.
@Override
public boolean hitEntity(ItemStack itemStack, EntityLivingBase target, EntityLivingBase player) {
DamageSource source;
if (player instanceof EntityPlayer) {
source = DamageSource.causePlayerDamage((EntityPlayer) player);
} else {
source = DamageSource.causeMobDamage(player);
}
target.attackEntityFrom(source, (float) (player.getRNG().nextInt(6) + 1) * (player.getRNG().nextInt(6) + 1));
return super.hitEntity(itemStack, target, player);
}
Aggregations