Search in sources :

Example 1 with EntityBloodLight

use of WayofTime.bloodmagic.entity.projectile.EntityBloodLight in project BloodMagic by WayofTime.

the class ItemSigilBloodLight method onItemRightClick.

@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
    ItemStack stack = player.getHeldItem(hand);
    if (stack.getItem() instanceof ISigil.Holding)
        stack = ((Holding) stack.getItem()).getHeldItem(stack, player);
    if (PlayerHelper.isFakePlayer(player))
        return ActionResult.newResult(EnumActionResult.FAIL, stack);
    RayTraceResult mop = this.rayTrace(world, player, false);
    if (getCooldownRemainder(stack) > 0)
        return super.onItemRightClick(world, player, hand);
    if (mop != null && mop.typeOfHit == RayTraceResult.Type.BLOCK) {
        BlockPos blockPos = mop.getBlockPos().offset(mop.sideHit);
        if (world.isAirBlock(blockPos)) {
            world.setBlockState(blockPos, RegistrarBloodMagicBlocks.BLOOD_LIGHT.getDefaultState());
            if (!world.isRemote) {
                SoulNetwork network = NetworkHelper.getSoulNetwork(getBinding(stack));
                network.syphonAndDamage(player, getLpUsed());
            }
            resetCooldown(stack);
            player.swingArm(hand);
            return super.onItemRightClick(world, player, hand);
        }
    } else {
        if (!world.isRemote) {
            SoulNetwork network = NetworkHelper.getSoulNetwork(getBinding(stack));
            world.spawnEntity(new EntityBloodLight(world, player));
            network.syphonAndDamage(player, getLpUsed());
        }
        resetCooldown(stack);
    }
    return super.onItemRightClick(world, player, hand);
}
Also used : SoulNetwork(WayofTime.bloodmagic.core.data.SoulNetwork) RayTraceResult(net.minecraft.util.math.RayTraceResult) BlockPos(net.minecraft.util.math.BlockPos) EntityBloodLight(WayofTime.bloodmagic.entity.projectile.EntityBloodLight) ItemStack(net.minecraft.item.ItemStack)

Aggregations

SoulNetwork (WayofTime.bloodmagic.core.data.SoulNetwork)1 EntityBloodLight (WayofTime.bloodmagic.entity.projectile.EntityBloodLight)1 ItemStack (net.minecraft.item.ItemStack)1 BlockPos (net.minecraft.util.math.BlockPos)1 RayTraceResult (net.minecraft.util.math.RayTraceResult)1