Search in sources :

Example 1 with EntityBlastemFruit

use of lykrast.defiledlands.common.entity.projectile.EntityBlastemFruit in project DefiledLands by Lykrast.

the class ItemBlastemFruit method onItemRightClick.

/**
 * Called when the equipped item is right clicked.
 */
public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn) {
    ItemStack itemstack = playerIn.getHeldItem(handIn);
    if (!playerIn.capabilities.isCreativeMode) {
        itemstack.shrink(1);
    }
    worldIn.playSound((EntityPlayer) null, playerIn.posX, playerIn.posY, playerIn.posZ, SoundEvents.ENTITY_SNOWBALL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
    playerIn.getCooldownTracker().setCooldown(this, 20);
    if (!worldIn.isRemote) {
        EntityBlastemFruit projectile = new EntityBlastemFruit(worldIn, playerIn);
        projectile.setHeadingFromThrower(playerIn, playerIn.rotationPitch, playerIn.rotationYaw, 0.0F, 1.5F, 1.0F);
        worldIn.spawnEntity(projectile);
    }
    playerIn.addStat(StatList.getObjectUseStats(this));
    return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, itemstack);
}
Also used : ActionResult(net.minecraft.util.ActionResult) EnumActionResult(net.minecraft.util.EnumActionResult) ItemStack(net.minecraft.item.ItemStack) EntityBlastemFruit(lykrast.defiledlands.common.entity.projectile.EntityBlastemFruit)

Example 2 with EntityBlastemFruit

use of lykrast.defiledlands.common.entity.projectile.EntityBlastemFruit in project DefiledLands by Lykrast.

the class ItemUmbraBlaster method onItemRightClick.

/**
 * Called when the equipped item is right clicked.
 */
public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn) {
    ItemStack itemstack = playerIn.getHeldItem(handIn);
    boolean flag = playerIn.capabilities.isCreativeMode || EnchantmentHelper.getEnchantmentLevel(Enchantments.INFINITY, itemstack) > 0;
    ItemStack ammo = findAmmo(playerIn);
    if (!ammo.isEmpty() || flag) {
        if (ammo.isEmpty()) {
            ammo = new ItemStack(ModItems.blastemFruit);
        }
        worldIn.playSound((EntityPlayer) null, playerIn.posX, playerIn.posY, playerIn.posZ, SoundEvents.ENTITY_SNOWBALL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
        playerIn.getCooldownTracker().setCooldown(this, 10);
        if (!worldIn.isRemote) {
            EntityBlastemFruit projectile;
            if (ammo.getItem() == ModItems.blastemFruitBlazing || EnchantmentHelper.getEnchantmentLevel(ModEnchantments.blazing, itemstack) > 0)
                projectile = new EntityBlastemFruitBlazing(worldIn, playerIn);
            else
                projectile = new EntityBlastemFruit(worldIn, playerIn);
            float f = getSharpshooterBonus(itemstack);
            projectile.setHeadingFromThrower(playerIn, playerIn.rotationPitch, playerIn.rotationYaw, 0.0F, 1.5F * f, 1.0F / f);
            if (EnchantmentHelper.getEnchantmentLevel(ModEnchantments.safeguard, itemstack) > 0) {
                projectile.setDestructive(false);
            }
            float j = getDestructiveBonus(itemstack);
            projectile.setDamage(projectile.getDamage() * j);
            projectile.setExplosionStrength(projectile.getExplosionStrength() * j);
            worldIn.spawnEntity(projectile);
            itemstack.damageItem(1, playerIn);
        }
        if (!flag) {
            consumeAmmo(itemstack, ammo, playerIn, worldIn.rand);
        }
        playerIn.addStat(StatList.getObjectUseStats(this));
        return new ActionResult(EnumActionResult.SUCCESS, itemstack);
    } else {
        return new ActionResult<ItemStack>(EnumActionResult.FAIL, itemstack);
    }
}
Also used : ActionResult(net.minecraft.util.ActionResult) EnumActionResult(net.minecraft.util.EnumActionResult) EntityBlastemFruitBlazing(lykrast.defiledlands.common.entity.projectile.EntityBlastemFruitBlazing) ItemStack(net.minecraft.item.ItemStack) EntityBlastemFruit(lykrast.defiledlands.common.entity.projectile.EntityBlastemFruit)

Aggregations

EntityBlastemFruit (lykrast.defiledlands.common.entity.projectile.EntityBlastemFruit)2 ItemStack (net.minecraft.item.ItemStack)2 ActionResult (net.minecraft.util.ActionResult)2 EnumActionResult (net.minecraft.util.EnumActionResult)2 EntityBlastemFruitBlazing (lykrast.defiledlands.common.entity.projectile.EntityBlastemFruitBlazing)1