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


Java ForgeEventFactory.getBreakSpeed方法代碼示例

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


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

示例1: blockStrength

import net.minecraftforge.event.ForgeEventFactory; //導入方法依賴的package包/類
public static float blockStrength(Block block, EntityPlayer player, World world, int x, int y, int z)
{
    int metadata = world.getBlockMetadata(x, y, z);
    float hardness = block.getBlockHardness(world, x, y, z);
    if (hardness < 0.0F)
    {
        return 0.0F;
    }

    if (!canHarvestBlock(block, player, metadata))
    {
        float speed = ForgeEventFactory.getBreakSpeed(player, block, metadata, 1.0f);
        return (speed < 0 ? 0 : speed) / hardness / 100F;
    }
    else
    {
         return player.getCurrentPlayerStrVsBlock(block, false, metadata) / hardness / 30F;
    }
}
 
開發者ID:HATB0T,項目名稱:RuneCraftery,代碼行數:20,代碼來源:ForgeHooks.java

示例2: getBreakSpeed

import net.minecraftforge.event.ForgeEventFactory; //導入方法依賴的package包/類
public float getBreakSpeed(Block p_146096_1_, boolean p_146096_2_, int meta, int x, int y, int z)
{
	ItemStack stack = this.inventory.getCurrentItem();
	float f = stack == null ? 1.0F : stack.getItem().getDigSpeed(stack, p_146096_1_, meta);
	if (f > 1.0F)
	{
		int i = EnchantmentHelper.getEfficiencyModifier(this);
		ItemStack itemstack = this.inventory.getCurrentItem();
		if ((i > 0) && (itemstack != null))
		{
			float f1 = i * i + 1;

			boolean canHarvest = ForgeHooks.canToolHarvestBlock(p_146096_1_, meta, itemstack);
			if ((!canHarvest) && (f <= 1.0F)) {
				f += f1 * 0.08F;
			} else {
				f += f1;
			}
		}
	}
	if (isPotionActive(Potion.digSpeed)) {
		f *= (1.0F + (getActivePotionEffect(Potion.digSpeed).getAmplifier() + 1) * 0.2F);
	}
	if (isPotionActive(Potion.digSlowdown)) {
		f *= (1.0F - (getActivePotionEffect(Potion.digSlowdown).getAmplifier() + 1) * 0.2F);
	}
	if ((isInsideOfMaterial(Material.water)) && (!EnchantmentHelper.getAquaAffinityModifier(this))) {
		f /= 5.0F;
	}
	if (!this.onGround) {
		f /= 5.0F;
	}
	f = ForgeEventFactory.getBreakSpeed(this, p_146096_1_, meta, f, x, y, z);
	return f < 0.0F ? 0.0F : f;
}
 
開發者ID:4Space,項目名稱:4Space-5,代碼行數:36,代碼來源:EntityPlayer.java

示例3: getBreakSpeed

import net.minecraftforge.event.ForgeEventFactory; //導入方法依賴的package包/類
/**
 * Adapted from {@link net.minecraft.entity.player.EntityPlayer#getBreakSpeed
 * (Block, boolean, int, int, int, int)}.  Uses given item rather than player
 * held item.
 * 
 * @param player    Current player.
 * @param block     To be broken.
 * @param metadata  Extra nibble.
 * @param x         X-axis coordinate of block.
 * @param y         Y-axis coordinate of block.
 * @param z         Z-axis coordinate of block.
 * @param stack     Item breaking block.
 * @return Relative break speed.
 */
public static float getBreakSpeed(EntityPlayer player, Block block
    , int metadata, int x, int y, int z, ItemStack stack) {
  
  float f = (stack == null ? 1.0F
      : stack.getItem().getDigSpeed(stack, block, metadata));

  if(f > 1.0F) {
    int mod = EnchantmentHelper.getEnchantmentLevel
        (Enchantment.efficiency.effectId, stack);
    if(mod > 0 && stack != null) {
      float f1 = (float)(mod * mod + 1);
      if(!ForgeHooks.canToolHarvestBlock(block, metadata, stack)
          && f <= 1.0F) {
        f += f1 * 0.08F;
      }
      else {
        f += f1;
      }
    }
  }
  if(player.isPotionActive(Potion.digSpeed)) {
    f *= 1.0F + (float)(player.getActivePotionEffect(Potion.digSpeed)
        .getAmplifier() + 1) * 0.2F;
  }
  if(player.isPotionActive(Potion.digSlowdown)) {
    f *= 1.0F - (float)(player.getActivePotionEffect(Potion.digSlowdown)
        .getAmplifier() + 1) * 0.2F;
  }
  if(player.isInsideOfMaterial(Material.water)
      && !EnchantmentHelper.getAquaAffinityModifier(player)) {
    f /= 5.0F;
  }
  if(!player.onGround) {
    f /= 5.0F;
  }
  f = ForgeEventFactory.getBreakSpeed(player, block, metadata, f, x, y, z);
  return (f < 0 ? 0 : f);
}
 
開發者ID:GhostMonk3408,項目名稱:MidgarCrusade,代碼行數:53,代碼來源:CustomEventHandler.java

示例4: getPlayerRelativeBlockHardness

import net.minecraftforge.event.ForgeEventFactory; //導入方法依賴的package包/類
@Override
public float getPlayerRelativeBlockHardness(EntityPlayer player, World world, int x, int y, int z) {
	int meta = world.getBlockMetadata(x, y, z);
	float hardness = getBlockHardness(world, x, y, z);
	if(hardness < 0.0F) {
		return 0.0F;
	}
	if(!canHarvestBlock(player, meta)) {
		float speed = ForgeEventFactory.getBreakSpeed(player, this, meta, 1.0f, x, y, z);
		return (speed < 0 ? 0 : speed) / hardness / 100F;
	} else {
		return player.getBreakSpeed(this, false, meta, x, y, z) / hardness / 30F;
	}
}
 
開發者ID:TeamMetallurgy,項目名稱:Metallurgy-Bees,代碼行數:15,代碼來源:BlockBeehive.java

示例5: getBreakSpeed

import net.minecraftforge.event.ForgeEventFactory; //導入方法依賴的package包/類
public float getBreakSpeed(Block p_146096_1_, boolean p_146096_2_, int meta, int x, int y, int z)
{
    ItemStack stack = inventory.getCurrentItem();
    float f = (stack == null ? 1.0F : stack.getItem().getDigSpeed(stack, p_146096_1_, meta));

    if (f > 1.0F)
    {
        int i = EnchantmentHelper.getEfficiencyModifier(this);
        ItemStack itemstack = this.inventory.getCurrentItem();

        if (i > 0 && itemstack != null)
        {
            float f1 = (float)(i * i + 1);

            boolean canHarvest = ForgeHooks.canToolHarvestBlock(p_146096_1_, meta, itemstack);

            if (!canHarvest && f <= 1.0F)
            {
                f += f1 * 0.08F;
            }
            else
            {
                f += f1;
            }
        }
    }

    if (this.isPotionActive(Potion.digSpeed))
    {
        f *= 1.0F + (float)(this.getActivePotionEffect(Potion.digSpeed).getAmplifier() + 1) * 0.2F;
    }

    if (this.isPotionActive(Potion.digSlowdown))
    {
        f *= 1.0F - (float)(this.getActivePotionEffect(Potion.digSlowdown).getAmplifier() + 1) * 0.2F;
    }

    if (this.isInsideOfMaterial(Material.water) && !EnchantmentHelper.getAquaAffinityModifier(this))
    {
        f /= 5.0F;
    }

    if (!this.onGround)
    {
        f /= 5.0F;
    }

    f = ForgeEventFactory.getBreakSpeed(this, p_146096_1_, meta, f, x, y, z);
    return (f < 0 ? 0 : f);
}
 
開發者ID:xtrafrancyz,項目名稱:Cauldron,代碼行數:51,代碼來源:EntityPlayer.java

示例6: getCurrentPlayerStrVsBlock

import net.minecraftforge.event.ForgeEventFactory; //導入方法依賴的package包/類
public float getCurrentPlayerStrVsBlock(Block par1Block, boolean par2, int meta)
{
    ItemStack stack = inventory.getCurrentItem();
    float f = (stack == null ? 1.0F : stack.getItem().getStrVsBlock(stack, par1Block, meta));

    if (f > 1.0F)
    {
        int i = EnchantmentHelper.getEfficiencyModifier(this);
        ItemStack itemstack = this.inventory.getCurrentItem();

        if (i > 0 && itemstack != null)
        {
            float f1 = (float)(i * i + 1);

            boolean canHarvest = ForgeHooks.canToolHarvestBlock(par1Block, meta, itemstack);

            if (!canHarvest && f <= 1.0F)
            {
                f += f1 * 0.08F;
            }
            else
            {
                f += f1;
            }
        }
    }

    if (this.isPotionActive(Potion.digSpeed))
    {
        f *= 1.0F + (float)(this.getActivePotionEffect(Potion.digSpeed).getAmplifier() + 1) * 0.2F;
    }

    if (this.isPotionActive(Potion.digSlowdown))
    {
        f *= 1.0F - (float)(this.getActivePotionEffect(Potion.digSlowdown).getAmplifier() + 1) * 0.2F;
    }

    if (this.isInsideOfMaterial(Material.water) && !EnchantmentHelper.getAquaAffinityModifier(this))
    {
        f /= 5.0F;
    }

    if (!this.onGround)
    {
        f /= 5.0F;
    }

    f = ForgeEventFactory.getBreakSpeed(this, par1Block, meta, f);
    return (f < 0 ? 0 : f);
}
 
開發者ID:HATB0T,項目名稱:RuneCraftery,代碼行數:51,代碼來源:EntityPlayer.java


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