Search in sources :

Example 1 with SacrificeKnifeUsedEvent

use of WayofTime.alchemicalWizardry.api.event.SacrificeKnifeUsedEvent in project BloodMagic by WayofTime.

the class CreativeDagger method onItemRightClick.

public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
    if (this.canUseForSacrifice(stack)) {
        player.setItemInUse(stack, this.getMaxItemUseDuration(stack));
        return stack;
    }
    if (!player.capabilities.isCreativeMode) {
        SacrificeKnifeUsedEvent evt = new SacrificeKnifeUsedEvent(player, true, true, 2);
        if (MinecraftForge.EVENT_BUS.post(evt)) {
            return stack;
        }
        if (evt.shouldDrainHealth) {
            player.setHealth(player.getHealth() - 2);
        }
        if (!evt.shouldFillAltar) {
            return stack;
        }
    }
    if (player instanceof FakePlayer) {
        return stack;
    }
    double posX = player.posX;
    double posY = player.posY;
    double posZ = player.posZ;
    world.playSoundEffect((double) ((float) posX + 0.5F), (double) ((float) posY + 0.5F), (double) ((float) posZ + 0.5F), "random.fizz", 0.5F, 2.6F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.8F);
    float f = 1.0F;
    float f1 = f * 0.6F + 0.4F;
    float f2 = f * f * 0.7F - 0.5F;
    float f3 = f * f * 0.6F - 0.7F;
    for (int l = 0; l < 8; ++l) {
        world.spawnParticle("reddust", posX + Math.random() - Math.random(), posY + Math.random() - Math.random(), posZ + Math.random() - Math.random(), f1, f2, f3);
    }
    if (!world.isRemote && SpellHelper.isFakePlayer(world, player)) {
        return stack;
    }
    findAndFillAltar(world, player, Integer.MAX_VALUE);
    return stack;
}
Also used : SacrificeKnifeUsedEvent(WayofTime.alchemicalWizardry.api.event.SacrificeKnifeUsedEvent) FakePlayer(net.minecraftforge.common.util.FakePlayer)

Example 2 with SacrificeKnifeUsedEvent

use of WayofTime.alchemicalWizardry.api.event.SacrificeKnifeUsedEvent in project BloodMagic by WayofTime.

the class SacrificialDagger method onItemRightClick.

@Override
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
    if (this.canUseForSacrifice(stack)) {
        player.setItemInUse(stack, this.getMaxItemUseDuration(stack));
        return stack;
    }
    if (!player.capabilities.isCreativeMode) {
        SacrificeKnifeUsedEvent evt = new SacrificeKnifeUsedEvent(player, true, true, 2);
        if (MinecraftForge.EVENT_BUS.post(evt)) {
            return stack;
        }
        if (evt.shouldDrainHealth) {
            player.setHealth(player.getHealth() - 2);
        }
        if (!evt.shouldFillAltar) {
            return stack;
        }
    }
    if (player instanceof FakePlayer) {
        return stack;
    }
    double posX = player.posX;
    double posY = player.posY;
    double posZ = player.posZ;
    world.playSoundEffect((double) ((float) posX + 0.5F), (double) ((float) posY + 0.5F), (double) ((float) posZ + 0.5F), "random.fizz", 0.5F, 2.6F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.8F);
    float f = 1.0F;
    float f1 = f * 0.6F + 0.4F;
    float f2 = f * f * 0.7F - 0.5F;
    float f3 = f * f * 0.6F - 0.7F;
    for (int l = 0; l < 8; ++l) {
        world.spawnParticle("reddust", posX + Math.random() - Math.random(), posY + Math.random() - Math.random(), posZ + Math.random() - Math.random(), f1, f2, f3);
    }
    if (!world.isRemote && SpellHelper.isFakePlayer(world, player)) {
        return stack;
    }
    if (player.isPotionActive(AlchemicalWizardry.customPotionSoulFray)) {
        findAndFillAltar(world, player, 20);
    } else {
        findAndFillAltar(world, player, 200);
    }
    if (player.getHealth() <= 0.001f) {
        player.onDeath(DamageSource.generic);
    }
    return stack;
}
Also used : SacrificeKnifeUsedEvent(WayofTime.alchemicalWizardry.api.event.SacrificeKnifeUsedEvent) FakePlayer(net.minecraftforge.common.util.FakePlayer)

Aggregations

SacrificeKnifeUsedEvent (WayofTime.alchemicalWizardry.api.event.SacrificeKnifeUsedEvent)2 FakePlayer (net.minecraftforge.common.util.FakePlayer)2