use of net.minecraft.entity.damage.DamageSource in project MCDungeonsWeapons by chronosacaria.
the class AOEHelper method electrocute.
public static void electrocute(LivingEntity attacker, LivingEntity victim, float damageAmount) {
createVisualLightningBoltOnEntity(victim);
DamageSource electricShockDamageSource = new ElectricShockDamageSource(attacker).setUsesMagic();
victim.damage(electricShockDamageSource, damageAmount);
}
use of net.minecraft.entity.damage.DamageSource in project MCDoom by AzureDoom.
the class EnergyCellEntity method onEntityHit.
@Override
protected void onEntityHit(EntityHitResult entityHitResult) {
Entity entity = entityHitResult.getEntity();
if (entityHitResult.getType() != HitResult.Type.ENTITY || !((EntityHitResult) entityHitResult).getEntity().isPartOf(entity)) {
if (!this.world.isClient) {
this.remove(Entity.RemovalReason.DISCARDED);
}
}
Entity entity2 = this.getOwner();
DamageSource damageSource2;
if (entity2 == null) {
damageSource2 = DamageSource.arrow(this, this);
} else {
damageSource2 = DamageSource.arrow(this, entity2);
if (entity2 instanceof LivingEntity) {
((LivingEntity) entity2).onAttacking(entity);
}
}
if (entity.damage(damageSource2, projectiledamage)) {
if (entity instanceof LivingEntity) {
LivingEntity livingEntity = (LivingEntity) entity;
if (!this.world.isClient && entity2 instanceof LivingEntity) {
EnchantmentHelper.onUserDamaged(livingEntity, entity2);
EnchantmentHelper.onTargetDamaged((LivingEntity) entity2, livingEntity);
this.remove(Entity.RemovalReason.DISCARDED);
}
this.onHit(livingEntity);
if (entity2 != null && livingEntity != entity2 && livingEntity instanceof PlayerEntity && entity2 instanceof ServerPlayerEntity && !this.isSilent()) {
((ServerPlayerEntity) entity2).networkHandler.sendPacket(new GameStateChangeS2CPacket(GameStateChangeS2CPacket.PROJECTILE_HIT_PLAYER, 0.0F));
}
}
} else {
if (!this.world.isClient) {
this.remove(Entity.RemovalReason.DISCARDED);
}
}
}
use of net.minecraft.entity.damage.DamageSource in project MCDoom by AzureDoom.
the class UnmaykrBoltEntity method onEntityHit.
@Override
protected void onEntityHit(EntityHitResult entityHitResult) {
Entity entity = entityHitResult.getEntity();
if (entityHitResult.getType() != HitResult.Type.ENTITY || !((EntityHitResult) entityHitResult).getEntity().isPartOf(entity)) {
if (!this.world.isClient) {
this.remove(Entity.RemovalReason.DISCARDED);
}
}
Entity entity2 = this.getOwner();
DamageSource damageSource2;
if (entity2 == null) {
damageSource2 = DamageSource.magic(this, this);
} else {
damageSource2 = DamageSource.magic(this, entity2);
if (entity2 instanceof LivingEntity) {
((LivingEntity) entity2).onAttacking(entity);
}
}
if (entity.damage(damageSource2, projectiledamage)) {
if (entity instanceof LivingEntity) {
LivingEntity livingEntity = (LivingEntity) entity;
if (!this.world.isClient && entity2 instanceof LivingEntity) {
EnchantmentHelper.onUserDamaged(livingEntity, entity2);
EnchantmentHelper.onTargetDamaged((LivingEntity) entity2, livingEntity);
this.remove(Entity.RemovalReason.DISCARDED);
}
this.onHit(livingEntity);
if (entity2 != null && livingEntity != entity2 && livingEntity instanceof PlayerEntity && entity2 instanceof ServerPlayerEntity && !this.isSilent()) {
((ServerPlayerEntity) entity2).networkHandler.sendPacket(new GameStateChangeS2CPacket(GameStateChangeS2CPacket.PROJECTILE_HIT_PLAYER, 0.0F));
}
}
} else {
if (!this.world.isClient) {
this.remove(Entity.RemovalReason.DISCARDED);
}
}
}
use of net.minecraft.entity.damage.DamageSource in project MCDoom by AzureDoom.
the class ArgentBoltEntity method onEntityHit.
@Override
protected void onEntityHit(EntityHitResult entityHitResult) {
Entity entity = entityHitResult.getEntity();
if (entityHitResult.getType() != HitResult.Type.ENTITY || !((EntityHitResult) entityHitResult).getEntity().isPartOf(entity)) {
if (!this.world.isClient) {
this.remove(Entity.RemovalReason.DISCARDED);
}
}
Entity entity2 = this.getOwner();
DamageSource damageSource2;
if (entity2 == null) {
damageSource2 = DamageSource.arrow(this, this);
} else {
damageSource2 = DamageSource.arrow(this, entity2);
if (entity2 instanceof LivingEntity) {
((LivingEntity) entity2).onAttacking(entity);
}
}
if (entity.damage(damageSource2, DoomMod.config.weapons.argent_bolt_damage)) {
if (entity instanceof LivingEntity) {
LivingEntity livingEntity = (LivingEntity) entity;
if (!this.world.isClient && entity2 instanceof LivingEntity) {
EnchantmentHelper.onUserDamaged(livingEntity, entity2);
EnchantmentHelper.onTargetDamaged((LivingEntity) entity2, livingEntity);
this.world.createExplosion(this, this.getX(), this.getBodyY(0.0625D), this.getZ(), 1.5F, Explosion.DestructionType.NONE);
}
this.remove(Entity.RemovalReason.DISCARDED);
this.onHit(livingEntity);
if (entity2 != null && livingEntity != entity2 && livingEntity instanceof PlayerEntity && entity2 instanceof ServerPlayerEntity && !this.isSilent()) {
((ServerPlayerEntity) entity2).networkHandler.sendPacket(new GameStateChangeS2CPacket(GameStateChangeS2CPacket.PROJECTILE_HIT_PLAYER, 0.0F));
}
}
} else {
if (!this.world.isClient) {
this.remove(Entity.RemovalReason.DISCARDED);
}
}
}
use of net.minecraft.entity.damage.DamageSource in project MCDoom by AzureDoom.
the class BulletEntity method onEntityHit.
@Override
protected void onEntityHit(EntityHitResult entityHitResult) {
Entity entity = entityHitResult.getEntity();
if (entityHitResult.getType() != HitResult.Type.ENTITY || !((EntityHitResult) entityHitResult).getEntity().isPartOf(entity)) {
if (!this.world.isClient) {
this.remove(Entity.RemovalReason.DISCARDED);
}
}
Entity entity2 = this.getOwner();
DamageSource damageSource2;
if (entity2 == null) {
damageSource2 = DamageSource.arrow(this, this);
} else {
damageSource2 = DamageSource.arrow(this, entity2);
if (entity2 instanceof LivingEntity) {
((LivingEntity) entity2).onAttacking(entity);
}
}
if (entity.damage(damageSource2, projectiledamage)) {
if (entity instanceof LivingEntity) {
LivingEntity livingEntity = (LivingEntity) entity;
if (!this.world.isClient && entity2 instanceof LivingEntity) {
EnchantmentHelper.onUserDamaged(livingEntity, entity2);
EnchantmentHelper.onTargetDamaged((LivingEntity) entity2, livingEntity);
this.remove(Entity.RemovalReason.DISCARDED);
}
this.onHit(livingEntity);
if (entity2 != null && livingEntity != entity2 && livingEntity instanceof PlayerEntity && entity2 instanceof ServerPlayerEntity && !this.isSilent()) {
((ServerPlayerEntity) entity2).networkHandler.sendPacket(new GameStateChangeS2CPacket(GameStateChangeS2CPacket.PROJECTILE_HIT_PLAYER, 0.0F));
}
}
} else {
if (!this.world.isClient) {
this.remove(Entity.RemovalReason.DISCARDED);
}
}
}
Aggregations