use of org.spongepowered.common.accessor.world.level.ExplosionAccessor in project SpongeCommon by SpongePowered.
the class DamageSourceMixin method onSetExplosionSource.
@Inject(method = "explosion(Lnet/minecraft/world/level/Explosion;)Lnet/minecraft/world/damagesource/DamageSource;", at = @At("HEAD"), cancellable = true)
private static void onSetExplosionSource(@Nullable final Explosion explosion, final CallbackInfoReturnable<net.minecraft.world.damagesource.DamageSource> cir) {
if (explosion != null) {
final Entity entity = ((ExplosionAccessor) explosion).accessor$source();
if (entity != null && !((LevelBridge) ((ExplosionAccessor) explosion).accessor$level()).bridge$isFake()) {
if (explosion.getSourceMob() == null && entity instanceof CreatorTrackedBridge) {
// check creator
final CreatorTrackedBridge creatorBridge = (CreatorTrackedBridge) entity;
creatorBridge.tracker$getCreatorUUID().flatMap(x -> Sponge.server().player(x)).ifPresent(player -> {
final IndirectEntityDamageSource damageSource = new IndirectEntityDamageSource("explosion.player", entity, (Entity) player);
damageSource.setScalesWithDifficulty().setExplosion();
cir.setReturnValue(damageSource);
});
}
}
}
}
use of org.spongepowered.common.accessor.world.level.ExplosionAccessor in project SpongeCommon by SpongePowered.
the class ExplosionContext method isRunaway.
@Override
protected boolean isRunaway(final PhaseContext<?> phaseContext) {
if (phaseContext.getClass() != ExplosionContext.class) {
return false;
}
final ExplosionAccessor otherExplosion = (ExplosionAccessor) ((ExplosionContext) phaseContext).explosion;
final ExplosionAccessor thisExplosion = (ExplosionAccessor) this.explosion;
return otherExplosion.accessor$level() == thisExplosion.accessor$level() && otherExplosion.accessor$x() == thisExplosion.accessor$x() && otherExplosion.accessor$y() == thisExplosion.accessor$y() && otherExplosion.accessor$z() == thisExplosion.accessor$z();
}
Aggregations