use of net.minecraft.util.EntityDamageSourceIndirect in project NetherEx by LogicTechCorp.
the class EntityGhastQueenFireball method onImpact.
@Override
protected void onImpact(RayTraceResult result) {
if (!world.isRemote) {
if (result.entityHit != null) {
result.entityHit.attackEntityFrom(new EntityDamageSourceIndirect("ghastQueenFireball", this, shootingEntity).setFireDamage().setProjectile(), 24.0F);
applyEnchantments(shootingEntity, result.entityHit);
}
boolean flag = world.getGameRules().getBoolean("mobGriefing");
world.newExplosion(null, posX, posY, posZ, (float) explosionPower, flag, flag);
setDead();
}
}
use of net.minecraft.util.EntityDamageSourceIndirect in project SpongeCommon by SpongePowered.
the class DamageEventHandler method generateCauseFor.
public static void generateCauseFor(DamageSource damageSource) {
if (damageSource instanceof EntityDamageSourceIndirect) {
net.minecraft.entity.Entity source = damageSource.getTrueSource();
if (!(source instanceof EntityPlayer) && source != null) {
final IMixinEntity mixinEntity = EntityUtil.toMixin(source);
mixinEntity.getNotifierUser().ifPresent(notifier -> Sponge.getCauseStackManager().addContext(EventContextKeys.NOTIFIER, notifier));
mixinEntity.getCreatorUser().ifPresent(owner -> Sponge.getCauseStackManager().addContext(EventContextKeys.OWNER, owner));
}
} else if (damageSource instanceof EntityDamageSource) {
net.minecraft.entity.Entity source = damageSource.getTrueSource();
if (!(source instanceof EntityPlayer) && source != null) {
final IMixinEntity mixinEntity = EntityUtil.toMixin(source);
// TODO only have a UUID, want a user
mixinEntity.getNotifierUser().ifPresent(notifier -> Sponge.getCauseStackManager().addContext(EventContextKeys.NOTIFIER, notifier));
mixinEntity.getCreatorUser().ifPresent(creator -> Sponge.getCauseStackManager().addContext(EventContextKeys.CREATOR, creator));
}
} else if (damageSource instanceof BlockDamageSource) {
Location<org.spongepowered.api.world.World> location = ((BlockDamageSource) damageSource).getLocation();
BlockPos blockPos = ((IMixinLocation) (Object) location).getBlockPos();
final IMixinChunk mixinChunk = (IMixinChunk) ((net.minecraft.world.World) location.getExtent()).getChunkFromBlockCoords(blockPos);
mixinChunk.getBlockNotifier(blockPos).ifPresent(notifier -> Sponge.getCauseStackManager().addContext(EventContextKeys.NOTIFIER, notifier));
mixinChunk.getBlockOwner(blockPos).ifPresent(owner -> Sponge.getCauseStackManager().addContext(EventContextKeys.CREATOR, owner));
}
Sponge.getCauseStackManager().pushCause(damageSource);
}
use of net.minecraft.util.EntityDamageSourceIndirect in project takumicraft by TNTModders.
the class EntityTakumiArrow method onHit.
@Override
protected void onHit(RayTraceResult raytraceResultIn) {
if (raytraceResultIn.typeOfHit == Type.ENTITY) {
if (raytraceResultIn.entityHit == this.shootingEntity) {
return;
}
raytraceResultIn.entityHit.attackEntityFrom(new EntityDamageSourceIndirect("explosion.player", this.shootingEntity, this), 15.0f);
}
TakumiUtils.takumiCreateExplosion(world, this, this.posX, this.posY, this.posZ, power, false, false);
pierce--;
if (pierce <= 0) {
this.setDead();
}
}
use of net.minecraft.util.EntityDamageSourceIndirect in project BetterRain by OreCruncher.
the class DamageEffectHandler method onLivingHurt.
@SubscribeEvent(priority = EventPriority.LOW)
public void onLivingHurt(final LivingHurtEvent event) {
if (event == null || event.entity == null || event.entity.worldObj == null || event.entity.worldObj.isRemote)
return;
// Living heal should handle heals - I think..
if (event.ammount <= 0 || event.entityLiving == null)
return;
// A bit hokey - may work.
boolean isCrit = false;
if (event.source instanceof EntityDamageSourceIndirect) {
final EntityDamageSourceIndirect dmgSource = (EntityDamageSourceIndirect) event.source;
if (dmgSource.getSourceOfDamage() instanceof EntityArrow) {
final EntityArrow arrow = (EntityArrow) dmgSource.getSourceOfDamage();
isCrit = arrow.getIsCritical();
}
} else if (event.source instanceof EntityDamageSource) {
final EntityDamageSource dmgSource = (EntityDamageSource) event.source;
if (dmgSource.getSourceOfDamage() instanceof EntityPlayer) {
final EntityPlayer player = (EntityPlayer) dmgSource.getSourceOfDamage();
isCrit = isCritical(player, event.entityLiving);
}
}
final HealthData data = new HealthData(event.entityLiving, isCrit, (int) event.ammount);
Network.sendHealthUpdate(data, event.entity.worldObj.provider.getDimensionId());
}
use of net.minecraft.util.EntityDamageSourceIndirect in project NetherEx by LogicTechCorp.
the class EntityGhastlingFireball method onImpact.
@Override
protected void onImpact(RayTraceResult result) {
if (!world.isRemote) {
if (result.entityHit != null && !(result.entityHit instanceof EntityGhastQueen)) {
result.entityHit.attackEntityFrom(new EntityDamageSourceIndirect("ghastlingFireball", this, shootingEntity).setFireDamage().setProjectile(), 6.0F);
applyEnchantments(shootingEntity, result.entityHit);
}
boolean flag = world.getGameRules().getBoolean("mobGriefing");
world.newExplosion(null, posX, posY, posZ, (float) explosionPower, flag, flag);
setDead();
}
}
Aggregations