Search in sources :

Example 1 with IMixinGriefer

use of org.spongepowered.common.interfaces.entity.IMixinGriefer in project SpongeCommon by SpongePowered.

the class MixinEntityWitherSkull method onExplode.

@Redirect(method = "onImpact", at = @At(value = "INVOKE", target = EXPLOSION_TARGET))
protected net.minecraft.world.Explosion onExplode(net.minecraft.world.World worldObj, Entity self, double x, double y, double z, float strength, boolean flaming, boolean smoking) {
    boolean griefer = ((IMixinGriefer) this).canGrief();
    try (final CauseStackManager.StackFrame frame = Sponge.getCauseStackManager().pushCauseFrame()) {
        Sponge.getCauseStackManager().pushCause(this);
        Sponge.getCauseStackManager().addContext(EventContextKeys.THROWER, getShooter());
        Sponge.getCauseStackManager().pushCause(getShooter());
        return detonate(Explosion.builder().location(new Location<>((World) worldObj, new Vector3d(x, y, z))).sourceExplosive(this).radius(this.explosionRadius).canCauseFire(flaming).shouldPlaySmoke(smoking && griefer).shouldBreakBlocks(smoking && griefer)).orElse(null);
    }
}
Also used : Vector3d(com.flowpowered.math.vector.Vector3d) IMixinGriefer(org.spongepowered.common.interfaces.entity.IMixinGriefer) CauseStackManager(org.spongepowered.api.event.CauseStackManager) Location(org.spongepowered.api.world.Location) Redirect(org.spongepowered.asm.mixin.injection.Redirect)

Aggregations

Vector3d (com.flowpowered.math.vector.Vector3d)1 CauseStackManager (org.spongepowered.api.event.CauseStackManager)1 Location (org.spongepowered.api.world.Location)1 Redirect (org.spongepowered.asm.mixin.injection.Redirect)1 IMixinGriefer (org.spongepowered.common.interfaces.entity.IMixinGriefer)1