當前位置: 首頁>>代碼示例>>Java>>正文


Java ForgeEventFactory.onArrowLoose方法代碼示例

本文整理匯總了Java中net.minecraftforge.event.ForgeEventFactory.onArrowLoose方法的典型用法代碼示例。如果您正苦於以下問題:Java ForgeEventFactory.onArrowLoose方法的具體用法?Java ForgeEventFactory.onArrowLoose怎麽用?Java ForgeEventFactory.onArrowLoose使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在net.minecraftforge.event.ForgeEventFactory的用法示例。


在下文中一共展示了ForgeEventFactory.onArrowLoose方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onPlayerStoppedUsing

import net.minecraftforge.event.ForgeEventFactory; //導入方法依賴的package包/類
@Override
public void onPlayerStoppedUsing(ItemStack stack, World worldIn, EntityLivingBase entityLiving, int timeLeft) {
    if (entityLiving instanceof EntityPlayer) {
        EntityPlayer entityplayer = (EntityPlayer)entityLiving;
        boolean flag = entityplayer.capabilities.isCreativeMode || EnchantmentHelper.getEnchantmentLevel(Enchantments.INFINITY, stack) > 0;
        ItemStack itemstack = this.findAmmo(entityplayer);
        int i = this.getMaxItemUseDuration(stack) - timeLeft;
        if ((i = ForgeEventFactory.onArrowLoose(stack, worldIn, (EntityPlayer)entityLiving, i, itemstack != null || flag)) < 0) {
            return;
        }
        if (itemstack != null || flag) {
            float f;
            if (itemstack == null) {
                itemstack = new ItemStack(ModItems.greatarrow);
            }
            if ((double)(f = ItemGreatbow.getArrowVelocity(i)) >= 0.1) {
                boolean flag1;
                boolean bl = flag1 = entityplayer.capabilities.isCreativeMode || itemstack.getItem() instanceof ItemGreatarrow && ((ItemGreatarrow)itemstack.getItem()).isInfinite(itemstack, stack, entityplayer);
                if (!worldIn.isRemote) {
                    int enchpower = EnchantmentHelper.getEnchantmentLevel(Enchantments.POWER, stack);
                    int enchpunch = EnchantmentHelper.getEnchantmentLevel(Enchantments.PUNCH, stack);
                    ItemGreatarrow itemarrow = (ItemGreatarrow)(itemstack.getItem() instanceof ItemGreatarrow ? itemstack.getItem() : ModItems.greatarrow);
                    EntityGreatarrow entityarrow = itemarrow.createArrow(worldIn, itemstack, entityplayer);
                    entityarrow.setAim(entityplayer, entityplayer.rotationPitch, entityplayer.rotationYaw, 0.0f, f * 4.5f, 0.5f);
                    if (f == 1.0f) {
                        entityarrow.setIsCritical(true);
                    }

                    entityarrow.setDamage(entityarrow.getDamage() * 2.0 + (double)enchpower * 0.5 + 0.5);
                    entityarrow.setKnockbackStrength(enchpunch);
                    entityarrow.setBlockBreakPower(entityarrow.getBlockBreakPower() * f * (enchpower+1.0f));

                    if (EnchantmentHelper.getEnchantmentLevel(Enchantments.FLAME, stack) > 0) {
                        entityarrow.setFire(100);
                    }
                    stack.damageItem(1, entityplayer);
                    if (flag1) {
                        entityarrow.pickupStatus = EntityArrow.PickupStatus.CREATIVE_ONLY;
                    }
                    worldIn.spawnEntity(entityarrow);
                }
                worldIn.playSound(null, entityplayer.posX, entityplayer.posY, entityplayer.posZ, SoundEvents.ENTITY_SKELETON_DEATH, SoundCategory.NEUTRAL, 1.0f, 1.0f / (itemRand.nextFloat() * 0.4f + 2.2f) - f * 0.2f);
                if (!flag1) {
                    itemstack.shrink(1);
                    if (itemstack.getCount() == 0) {
                        entityplayer.inventory.deleteStack(itemstack);
                    }
                }
                entityplayer.addStat(StatList.getObjectUseStats(this));
            }
        }
    }
}
 
開發者ID:DaedalusGame,項目名稱:BetterWithAddons,代碼行數:54,代碼來源:ItemGreatbow.java

示例2: onPlayerStoppedUsing

import net.minecraftforge.event.ForgeEventFactory; //導入方法依賴的package包/類
@Override
public void onPlayerStoppedUsing(ItemStack stack, World worldIn, EntityLivingBase entityLiving, int timeLeft)
{
	if (entityLiving instanceof EntityPlayer)
	{
		EntityPlayer entityplayer = (EntityPlayer)entityLiving;
		boolean flag = entityplayer.capabilities.isCreativeMode || EnchantmentHelper.getEnchantmentLevel(Enchantments.INFINITY, stack) > 0;
		ItemStack itemstack = this.findAmmo(entityplayer);

		int i = this.getMaxItemUseDuration(stack) - timeLeft;
		i = ForgeEventFactory.onArrowLoose(stack, worldIn, entityplayer, i, itemstack != null || flag);
		if (i < 0) return;

		if (itemstack != null || flag)
		{
			if (itemstack == null)
			{
				itemstack = new ItemStack(Items.ARROW);
			}

			float f = getArrowVelocity(i);

			if ((double)f >= 0.1D)
			{
				boolean flag1 = entityplayer.capabilities.isCreativeMode || (itemstack.getItem() instanceof ItemArrow ? ((ItemArrow)itemstack.getItem()).isInfinite(itemstack, stack, entityplayer) : false);

				if (!worldIn.isRemote)
				{
					ItemArrow itemarrow = (ItemArrow)(itemstack.getItem() instanceof ItemArrow ? itemstack.getItem() : Items.ARROW);
					EntityArrow entityarrow = itemarrow.createArrow(worldIn, itemstack, entityplayer);
					entityarrow.setAim(entityplayer, entityplayer.rotationPitch, entityplayer.rotationYaw, 0.0F, f * 3.0F, 1.0F);

					if (f == 1.0F)
					{
						entityarrow.setIsCritical(true);
					}

					int j = EnchantmentHelper.getEnchantmentLevel(Enchantments.POWER, stack);

					if (j > 0)
					{
						entityarrow.setDamage(entityarrow.getDamage() + (double)j * 0.5D + 0.5D);
					}

					int k = EnchantmentHelper.getEnchantmentLevel(Enchantments.PUNCH, stack);

					if (k > 0)
					{
						entityarrow.setKnockbackStrength(k);
					}

					if (EnchantmentHelper.getEnchantmentLevel(Enchantments.FLAME, stack) > 0)
					{
						entityarrow.setFire(100);
					}

					if (flag1)
					{
						entityarrow.pickupStatus = EntityArrow.PickupStatus.CREATIVE_ONLY;
					}

					worldIn.spawnEntityInWorld(entityarrow);
				}

				worldIn.playSound(null, entityplayer.posX, entityplayer.posY, entityplayer.posZ, SoundEvents.ENTITY_ARROW_SHOOT, SoundCategory.NEUTRAL, 1.0F, 1.0F / (itemRand.nextFloat() * 0.4F + 1.2F) + f * 0.5F);

				entityplayer.addStat(StatList.getObjectUseStats(this));
			}
		}
	}
}
 
開發者ID:The-Fireplace-Minecraft-Mods,項目名稱:Wars-Mod,代碼行數:72,代碼來源:ItemArcherBow.java

示例3: onPlayerStoppedUsing

import net.minecraftforge.event.ForgeEventFactory; //導入方法依賴的package包/類
/**
 * called when the player releases the use item button. Args: itemstack, world, entityplayer, itemInUseCount
 */
@Override
public void onPlayerStoppedUsing(ItemStack par1ItemStack, World par2World, EntityLivingBase par3EntityLivingBase, int par4)
{
	if(par3EntityLivingBase instanceof EntityPlayer){

		EntityPlayer player = (EntityPlayer) par3EntityLivingBase;
		boolean flag = player.capabilities.isCreativeMode || EnchantmentHelper.getEnchantmentLevel(Enchantments.INFINITY, par1ItemStack) > 0;
		ItemStack itemstack = findAmmo(player);


		int i = getMaxItemUseDuration(par1ItemStack) - par4;
		i = ForgeEventFactory.onArrowLoose(par1ItemStack, par2World, player, i, itemstack != null || flag);
		if(i < 0) return;

		if (itemstack != null || flag)
		{
			if (itemstack == null)
				itemstack = new ItemStack(Items.ARROW);

			float f = getArrowVelocity(i);

			if (f >= 0.1D)
			{
				boolean flag1 = flag && itemstack.getItem() instanceof ItemArrow; //Forge: Fix consuming custom arrows.

				if (!par2World.isRemote)
				{
					EntityCoraliumArrow entityarrow = new EntityCoraliumArrow(par2World, player);
					entityarrow.setAim(player, player.rotationPitch, player.rotationYaw, 0.0F, f * 3.0F, 1.0F);

					if (f == 1.0F)
						entityarrow.setIsCritical(true);

					int j = EnchantmentHelper.getEnchantmentLevel(Enchantments.POWER, par1ItemStack);

					if (j > 0)
						entityarrow.setDamage(entityarrow.getDamage() + j * 0.5D + 0.5D);

					int k = EnchantmentHelper.getEnchantmentLevel(Enchantments.PUNCH, par1ItemStack);

					if (k > 0)
						entityarrow.setKnockbackStrength(k);

					if (EnchantmentHelper.getEnchantmentLevel(Enchantments.FLAME, par1ItemStack) > 0)
						entityarrow.setFire(100);

					par1ItemStack.damageItem(1, player);

					if (flag1)
						entityarrow.pickupStatus = EntityArrow.PickupStatus.CREATIVE_ONLY;

					par2World.spawnEntity(entityarrow);
				}

				par2World.playSound((EntityPlayer)null, player.posX, player.posY, player.posZ, SoundEvents.ENTITY_ARROW_SHOOT, SoundCategory.NEUTRAL, 1.0F, 1.0F / (itemRand.nextFloat() * 0.4F + 1.2F) + f * 0.5F);

				if (!flag1)
				{
					itemstack.shrink(1);

					if (itemstack.isEmpty())
						player.inventory.deleteStack(itemstack);
				}

				player.addStat(StatList.getObjectUseStats(this));
			}
		}
	}
}
 
開發者ID:Shinoow,項目名稱:AbyssalCraft,代碼行數:73,代碼來源:ItemCoraliumBow.java

示例4: onPlayerStoppedUsing

import net.minecraftforge.event.ForgeEventFactory; //導入方法依賴的package包/類
public void onPlayerStoppedUsing(ItemStack stack, World worldIn, EntityLivingBase entityLiving, int timeLeft) {
    
    if (! (entityLiving instanceof EntityPlayer)) {
      return;
    }
    EntityPlayer entityplayer = (EntityPlayer) entityLiving;
    boolean hasInfinateArrows = entityplayer.capabilities.isCreativeMode || EnchantmentHelper.getEnchantmentLevel(Enchantments.INFINITY, stack) > 0;
    ItemStack itemstack = getArrowsToShoot(entityplayer);
    int draw = getMaxItemUseDuration(stack) - timeLeft;
    draw = ForgeEventFactory.onArrowLoose(stack, worldIn, (EntityPlayer) entityLiving, draw, itemstack != null || hasInfinateArrows);
    if (draw < 0){
      return;
    }

    if(itemstack == null && hasInfinateArrows) {
      itemstack = new ItemStack(Items.ARROW);
    }
    
    if (itemstack == null) {
      return;
    }

    float drawRatio = getArrowVelocity(draw);
    if (drawRatio >= 0.1) {
      boolean arrowIsInfinite = hasInfinateArrows && itemstack.getItem() instanceof ItemArrow;
      if (!worldIn.isRemote) {
        ItemArrow itemarrow = (ItemArrow) ((ItemArrow) (itemstack.getItem() instanceof ItemArrow ? itemstack.getItem() : Items.ARROW));
        EntityArrow entityarrow = itemarrow.createArrow(worldIn, itemstack, entityplayer);
        //TODO: 1.9 Arrows dont fly straight with higher force 
//        entityarrow.func_184547_a(entityplayer, entityplayer.rotationPitch, entityplayer.rotationYaw, 0.0F, drawRatio * 3.0F * forceMultiplier, 1.0F);
        entityarrow.setAim(entityplayer, entityplayer.rotationPitch, entityplayer.rotationYaw, 0.0F, drawRatio * (3.0F + forceMultiplier), 0.25F);
        //entityarrow.setVelocity(x, y, z);
        

        if (drawRatio == 1.0F) {
          entityarrow.setIsCritical(true);
        }
        int powerLevel = EnchantmentHelper.getEnchantmentLevel(Enchantments.POWER, stack);
        if (powerLevel > 0) {
          entityarrow.setDamage(entityarrow.getDamage() + (double) powerLevel * 0.5D + 0.5D);
        }
        int knockBack = EnchantmentHelper.getEnchantmentLevel(Enchantments.PUNCH, stack);
        if (knockBack > 0) {
          entityarrow.setKnockbackStrength(knockBack);
        }
        if (EnchantmentHelper.getEnchantmentLevel(Enchantments.FLAME, stack) > 0) {
          entityarrow.setFire(100);
        }

        stack.damageItem(1, entityplayer);

        if (arrowIsInfinite) {
          entityarrow.pickupStatus = EntityArrow.PickupStatus.CREATIVE_ONLY;
        }
        
        entityarrow.setDamage(entityarrow.getDamage() + damageBonus + 20);
        
        worldIn.spawnEntity(entityarrow);
      }

      worldIn.playSound((EntityPlayer) null, entityplayer.posX, entityplayer.posY, entityplayer.posZ, SoundEvents.ENTITY_ARROW_SHOOT, SoundCategory.NEUTRAL,
          1.0F, 1.0F / (itemRand.nextFloat() * 0.4F + 1.2F) + drawRatio * 0.5F);

      if (!arrowIsInfinite) {
        itemstack.shrink(1);
        if (itemstack.isEmpty()) {
          entityplayer.inventory.deleteStack(itemstack);
        }
      }
      entityplayer.addStat(StatList.getObjectUseStats(this));
    }

  }
 
開發者ID:SleepyTrousers,項目名稱:EnderZoo,代碼行數:74,代碼來源:ItemGuardiansBow.java

示例5: onPlayerStoppedUsing

import net.minecraftforge.event.ForgeEventFactory; //導入方法依賴的package包/類
@Override
public void onPlayerStoppedUsing(@Nonnull ItemStack stack, @Nonnull World worldIn, @Nonnull EntityLivingBase entityLiving, int timeLeft) {

  if (!(entityLiving instanceof EntityPlayer)) {
    return;
  }
  EntityPlayer entityplayer = (EntityPlayer) entityLiving;
  boolean hasInfinateArrows = entityplayer.capabilities.isCreativeMode || EnchantmentHelper.getEnchantmentLevel(Enchantments.INFINITY, stack) > 0;
  ItemStack itemstack = getArrowsToShoot(entityplayer);
  int draw = getMaxItemUseDuration(stack) - timeLeft;
  draw = ForgeEventFactory.onArrowLoose(stack, worldIn, (EntityPlayer) entityLiving, draw, Prep.isValid(itemstack) || hasInfinateArrows);
  if (draw < 0) {
    return;
  }

  if (itemstack.isEmpty() && hasInfinateArrows) {
    itemstack = new ItemStack(Items.ARROW);
  }

  if (itemstack.isEmpty()) {
    return;
  }

  float drawRatio = getCustumArrowVelocity(stack, draw);
  if (drawRatio >= 0.1) {
    boolean arrowIsInfinite = hasInfinateArrows && itemstack.getItem() instanceof ItemArrow;
    if (!worldIn.isRemote) {

      EnergyUpgradeHolder upgrade = EnergyUpgradeManager.loadFromItem(stack);

      ItemArrow itemarrow = ((ItemArrow) (itemstack.getItem() instanceof ItemArrow ? itemstack.getItem() : Items.ARROW));
      EntityArrow entityarrow = itemarrow.createArrow(worldIn, itemstack, entityplayer);
      entityarrow.setAim(entityplayer, entityplayer.rotationPitch, entityplayer.rotationYaw, 0.0F, drawRatio * 3.0F * getForceMultiplier(upgrade), 0.25F);

      if (drawRatio == 1.0F) {
        entityarrow.setIsCritical(true);
      }
      int powerLevel = EnchantmentHelper.getEnchantmentLevel(Enchantments.POWER, stack);
      if (powerLevel > 0) {
        entityarrow.setDamage(entityarrow.getDamage() + powerLevel * 0.5D + 0.5D);
      }
      int knockBack = EnchantmentHelper.getEnchantmentLevel(Enchantments.PUNCH, stack);
      if (knockBack > 0) {
        entityarrow.setKnockbackStrength(knockBack);
      }
      if (EnchantmentHelper.getEnchantmentLevel(Enchantments.FLAME, stack) > 0) {
        entityarrow.setFire(100);
      }

      stack.damageItem(1, entityplayer);

      if (arrowIsInfinite) {
        entityarrow.pickupStatus = EntityArrow.PickupStatus.CREATIVE_ONLY;
      }

      entityarrow.setDamage(entityarrow.getDamage() + damageBonus);

      worldIn.spawnEntity(entityarrow);

      int used = getRequiredPower(draw, upgrade);
      if (used > 0) {
        upgrade.setEnergy(upgrade.getEnergy() - used);
        upgrade.writeToItem(stack);
      }

    }

    worldIn.playSound((EntityPlayer) null, entityplayer.posX, entityplayer.posY, entityplayer.posZ, SoundEvents.ENTITY_ARROW_SHOOT, SoundCategory.NEUTRAL,
        1.0F, 1.0F / (itemRand.nextFloat() * 0.4F + 1.2F) + drawRatio * 0.5F);

    if (!arrowIsInfinite) {
      itemstack.shrink(1);
    }
    supressed(entityplayer);
  }

}
 
開發者ID:SleepyTrousers,項目名稱:EnderIO,代碼行數:78,代碼來源:ItemDarkSteelBow.java


注:本文中的net.minecraftforge.event.ForgeEventFactory.onArrowLoose方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。