use of org.spongepowered.api.event.entity.AttackEntityEvent in project SpongeCommon by SpongePowered.
the class MixinEntityMinecartTNT method onAttackEntityFrom.
@Inject(method = "attackEntityFrom", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/item/EntityMinecartTNT;explodeCart(D)V"))
private void onAttackEntityFrom(DamageSource source, float amount, CallbackInfoReturnable<Boolean> cir) {
try (CauseStackManager.StackFrame frame = Sponge.getCauseStackManager().pushCauseFrame()) {
frame.pushCause(source);
AttackEntityEvent event = SpongeEventFactory.createAttackEntityEvent(frame.getCurrentCause(), new ArrayList(), this, 0, amount);
SpongeImpl.postEvent(event);
if (event.isCancelled()) {
cir.setReturnValue(true);
}
}
}
Aggregations