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


Java ForgeHooks.canToolHarvestBlock方法代碼示例

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


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

示例1: checkBlockBreak

import net.minecraftforge.common.ForgeHooks; //導入方法依賴的package包/類
public void checkBlockBreak(World world, EntityPlayer player, int x, int y, int z, ItemStack stack, float strength,
		Block originalBlock, int side)
{
	Block breakBlock = world.getBlock(x, y, z);
	int metadata = world.getBlockMetadata(x, y, z);
	if (ForgeHooks.canToolHarvestBlock(breakBlock, metadata, stack))
	{
		float newStrength = ForgeHooks.blockStrength(breakBlock, player, world, x, y, z);

		if (newStrength > 0f && strength / newStrength <= 10f)
		{
			RandomUtils.breakBlock(world, breakBlock, x, y, z, side, player);

			if ((double) breakBlock.getBlockHardness(world, x, y, z) != 0.0D)
			{
				stack.damageItem(1, player);
			}
		}
	}

}
 
開發者ID:VapourDrive,項目名稱:MagTools,代碼行數:22,代碼來源:MagEarthMover.java

示例2: getBreakSpeed

import net.minecraftforge.common.ForgeHooks; //導入方法依賴的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.common.ForgeHooks; //導入方法依賴的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: click

import net.minecraftforge.common.ForgeHooks; //導入方法依賴的package包/類
@Override
public void click(EntityPlayer entityplayer) {
    // left click: remove a stack, or punt if properly equipped
    if (entityplayer.worldObj.isRemote) {
        return;
    }
    if (punt(entityplayer)) {
        return;
    }
    if (getItemCount() == 0 || item == null) {
        info(entityplayer);
        return;
    }
    ItemStack origHeldItem = entityplayer.getHeldItem();
    if (ForgeHooks.canToolHarvestBlock(worldObj, pos, origHeldItem)) {
        return;
    }
    
    int to_remove = Math.min(item.getMaxStackSize(), getItemCount());
    if (entityplayer.isSneaking() && to_remove >= 1) {
        to_remove = 1;
    }
    if (to_remove > 1 && to_remove == getItemCount()) {
        to_remove--;
    }
    Entity ent = ItemUtil.giveItem(entityplayer, new Coord(this), makeStack(to_remove), SpaceUtil.getOrientation(last_hit_side));
    if (ent != null && ent.isDead && !(entityplayer instanceof FakePlayer)) {
        ItemStack newHeld = entityplayer.getHeldItem();
        if (newHeld != origHeldItem) {
            broadcastMessage(entityplayer, BarrelMessage.BarrelDoubleClickHack);
        }
    }
    changeItemCount(-to_remove);
    cleanBarrel();
    last_hit_side = -1;
}
 
開發者ID:purpleposeidon,項目名稱:Factorization,代碼行數:37,代碼來源:TileEntityDayBarrel.java

示例5: getConvinientToolForBlock

import net.minecraftforge.common.ForgeHooks; //導入方法依賴的package包/類
/**
 * Gets convenient mode for block harvesting.
 * It also works with tools, tool types from other mods
 * @param itemstack = itemstack to get data from
 * @param block = block that will be harvested
 * @param meta = metadata of block
 * @return tool that can harvest this block
 */
public static ItemStack getConvinientToolForBlock(ItemStack itemstack, Block block, int metadata){
	for(int meta = 1; meta < 10; meta++){
		if(hasToolForMeta(itemstack, meta)){
			ItemStack tool = getToolFromMeta(itemstack, meta);
			if(ForgeHooks.canToolHarvestBlock(block, metadata, tool))
				return tool;
		}
	}
	return null;
}
 
開發者ID:Elix-x,項目名稱:toolscompressor,代碼行數:19,代碼來源:ItemCompressedTools.java

示例6: onGetBreakSpeed

import net.minecraftforge.common.ForgeHooks; //導入方法依賴的package包/類
@SubscribeEvent
public void onGetBreakSpeed(PlayerEvent.BreakSpeed event) {
    ItemStack item = BaublesApi.getBaubles(event.getEntityPlayer()).getStackInSlot(1);
    if (item != null && item.getItem() instanceof ItemFairyRing && !event.getEntityPlayer().worldObj.isRemote) {
        List<EntityDigFairy> fairyList = event.getEntityPlayer().worldObj.getEntitiesWithinAABB(EntityDigFairy.class, event.getEntityPlayer().getEntityBoundingBox().expand(20, 20, 20));
        int count = -1;
        for (EntityDigFairy digFairy : fairyList) {
            if (digFairy.player == event.getEntityPlayer()) {
                count++;
            }
        }
        count = Math.min(count, 15);
        event.setNewSpeed((float) (event.getNewSpeed() * Math.pow(1.08, count)));
    }
    if (event.getEntityPlayer().inventory.getCurrentItem() != null && AngelsteelToolHelper.isAngelsteelTool(event.getEntityPlayer().inventory.getCurrentItem().getItem())) {
        if (event.getEntityPlayer().inventory.getCurrentItem().getTagCompound() == null) {
            event.getEntityPlayer().inventory.getCurrentItem().setTagCompound(AngelsteelToolHelper.getRandomBuffCompound(((IAngelsteelTool) event.getEntityPlayer().inventory.getCurrentItem().getItem()).getDegree()));
        }
        ItemStack tool = event.getEntityPlayer().inventory.getCurrentItem();
        if (ForgeHooks.canToolHarvestBlock(event.getEntityPlayer().worldObj, event.getPos(), tool)) {
            int[] buffs = AngelsteelToolHelper.readFromNBT(event.getEntityPlayer().inventory.getCurrentItem().getTagCompound());
            if (buffs.length > 0) {
                int efficiency = buffs[0];
                event.setNewSpeed((float) (event.getNewSpeed() * Math.pow(1.3, efficiency)));
                int shatter = buffs[2];
                int disintegrate = buffs[3];
                //1.5F, the hardness of stone, is used as a dividing point
                //Stone is not affected by either enchant
                if (event.getState().getBlock().getBlockHardness(event.getState(), event.getEntity().worldObj, event.getPos()) <= 1F) {
                    event.setNewSpeed((float) (event.getNewSpeed() * Math.pow(3, disintegrate)));
                }
                if (event.getState().getBlock().getBlockHardness(event.getState(), event.getEntity().worldObj, event.getPos()) >= 2F) {

                    event.setNewSpeed((float) (event.getNewSpeed() * Math.pow(3, shatter)));
                }
            }
        }
    }
}
 
開發者ID:AdlyTempleton,項目名稱:Aura-Cascade,代碼行數:40,代碼來源:EventHandler.java

示例7: canHarvestBlock

import net.minecraftforge.common.ForgeHooks; //導入方法依賴的package包/類
@Override
  public boolean canHarvestBlock(Block block, ItemStack stack)
  {
if(!(this instanceof ItemWarhammer))
{
	return ForgeHooks.canToolHarvestBlock(block, 0, stack);
}
return super.canHarvestBlock(block);
  }
 
開發者ID:TheAwesomeGem,項目名稱:MineFantasy,代碼行數:10,代碼來源:ItemWarpick.java

示例8: canHarvestBlock

import net.minecraftforge.common.ForgeHooks; //導入方法依賴的package包/類
@Override
  public boolean canHarvestBlock( Block block, ItemStack stack )
  {
if ( getDamage( stack ) > getMaxDamage( stack ) )
{
	return false;
}

NBTTagCompound tag = stack.getTagCompound();
String head = tag.getString( "head" );
if ( head == null || head == "" )
{
	return false;
}

boolean goodLevel = ForgeHooks.canToolHarvestBlock( block, metadata, stack );

//System.out.println(needed+" "+level+" "+goodLevel);
//System.out.println(MinecraftForge.getBlockHarvestLevel( block, 0, "pickaxe" ));

if ( tool.actsLike( stack, "axe" ) )
{
	if ( block.getMaterial().equals( net.minecraft.block.material.Material.wood ) || block.getMaterial().equals( net.minecraft.block.material.Material.plants ) || block.getMaterial().equals( net.minecraft.block.material.Material.vine ) )
	{
		return goodLevel;
	}
}
if ( tool.actsLike( stack, "pickaxe" ) )
{
	if ( block.getMaterial().equals( net.minecraft.block.material.Material.iron ) || block.getMaterial().equals( net.minecraft.block.material.Material.anvil ) || block.getMaterial().equals( net.minecraft.block.material.Material.rock ) )
	{
		return goodLevel;
	}
}
if ( tool.actsLike( stack, "shovel" ) )
{
	if ( block.getMaterial().equals( net.minecraft.block.material.Material.snow ) )
	{
		return goodLevel;
	}
}
if ( tool.actsLike( stack, "sword" ) )
{
	if ( block == net.minecraft.init.Blocks.web )
	{
		return goodLevel;
	}
}

      return false;
  }
 
開發者ID:spacechase0,項目名稱:ComponentEquipment,代碼行數:52,代碼來源:HarvesterToolItem.java

示例9: onGetBreakSpeed

import net.minecraftforge.common.ForgeHooks; //導入方法依賴的package包/類
@SubscribeEvent
public void onGetBreakSpeed(PlayerEvent.BreakSpeed event) {
    if (event.getEntityPlayer().inventory.getCurrentItem() != null) {
        ItemStack tool = event.getEntityPlayer().inventory.getCurrentItem();

        int miningDebuff = getEffectStrength(tool, EnumRainbowColor.RED, EnumRainbowColor.GREEN);
        if (miningDebuff > 0) {
            event.setNewSpeed((float) (event.getNewSpeed() / Math.pow(3, miningDebuff)));
        }

        if (ForgeHooks.canToolHarvestBlock(event.getEntityPlayer().worldObj, event.getPos(), tool)) {
            Block block = event.getState().getBlock();
            int efficiency = getEffectStrength(tool, EnumRainbowColor.ORANGE, EnumRainbowColor.ORANGE);
            event.setNewSpeed((float) (event.getNewSpeed() * Math.pow(1.15, efficiency)));
            int shatter = getEffectStrength(tool, EnumRainbowColor.ORANGE, EnumRainbowColor.VIOLET);
            if (shatter > 0 && event.getState().getBlock().getBlockHardness(event.getState(), event.getEntity().worldObj, event.getPos()) >= 3F) {
                event.setNewSpeed((float) (event.getNewSpeed() * Math.pow(1.5, shatter)));
            }

            int oreSpeed = getEffectStrength(tool, EnumRainbowColor.RED, EnumRainbowColor.ORANGE);

            if (oreSpeed > 0 && (Arrays.asList(ores).contains(event.getState().getBlock()) || containsOredict(block, "ore"))) {
                event.setNewSpeed((float) (event.getNewSpeed() * Math.pow(1.25, oreSpeed)));
            }


            int stone = getEffectStrength(tool, EnumRainbowColor.YELLOW, EnumRainbowColor.ORANGE);

            if (stone > 0 && Blocks.STONE == block) {
                event.setNewSpeed((float) (event.getNewSpeed() * Math.pow(1.25, stone)));
            }

            int logSpeed = getEffectStrength(tool, EnumRainbowColor.ORANGE, EnumRainbowColor.GREEN);
            if (logSpeed > 0 && block == Blocks.LOG || block == Blocks.LOG2 || containsOredict(block, "log")) {
                event.setNewSpeed((float) (event.getNewSpeed() * Math.pow(1.25, logSpeed)));
            }

            int digSpeed = getEffectStrength(tool, EnumRainbowColor.ORANGE, EnumRainbowColor.GREEN);
            if (block == Blocks.GRASS || block == Blocks.DIRT || block == Blocks.GRAVEL || block == Blocks.SAND) {
                event.setNewSpeed((float) (event.getNewSpeed() * Math.pow(1.25, digSpeed)));

            }

        }
    }
}
 
開發者ID:AdlyTempleton,項目名稱:Aura-Cascade,代碼行數:47,代碼來源:EnchantEventHandler.java

示例10: canHarvestBlock

import net.minecraftforge.common.ForgeHooks; //導入方法依賴的package包/類
@Override
public boolean canHarvestBlock(Block block, ItemStack stack)
{
	return ForgeHooks.canToolHarvestBlock(block, 0, stack) || Item.shovelIron.canHarvestBlock(block, stack);
}
 
開發者ID:TheAwesomeGem,項目名稱:MineFantasy,代碼行數:6,代碼來源:ItemMattock.java

示例11: isToolEffective

import net.minecraftforge.common.ForgeHooks; //導入方法依賴的package包/類
@Override
protected boolean isToolEffective(ItemStack stack, int id, int meta) {
	return ForgeHooks.canToolHarvestBlock(Block.blocksList[id], meta, stack);
}
 
開發者ID:austinv11,項目名稱:PeripheralsPlusPlus,代碼行數:5,代碼來源:UpgradeScoop.java

示例12: getBreakSpeed

import net.minecraftforge.common.ForgeHooks; //導入方法依賴的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

示例13: getCurrentPlayerStrVsBlock

import net.minecraftforge.common.ForgeHooks; //導入方法依賴的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

示例14: canMineBlock

import net.minecraftforge.common.ForgeHooks; //導入方法依賴的package包/類
public int canMineBlock(int x, int y, int z) {
	BlockPos minePos = new BlockPos(x, y, z);
	IBlockState tryState = world.getBlockState(minePos);
	Block tryBlock = tryState.getBlock();
	
	if (tryBlock != null) {
		//int meta = tryBlock.getMetaFromState(tryState);
		if (
			(tryBlock.getBlockHardness(tryState, world, minePos)>=0) &&
			(!tryBlock.isAir(tryState, world, minePos)) 
		) {
			//ProgressiveAutomation.logger.info("Tool: "+tryBlock.getHarvestTool(meta)+", Level: "+tryBlock.getHarvestLevel(meta)+", Can use Pick: "+tryBlock.isToolEffective("pickaxe", meta));
			//ProgressiveAutomation.logger.info("Harvestable: "+ForgeHooks.canToolHarvestBlock(tryBlock, meta, getStackInSlot(2)));
			if (tryBlock == Blocks.COBBLESTONE) {
				return -1;
			}
			if (tryBlock.getHarvestTool(tryState)=="chisel") { //this is compatibility for chisel 1
				return 2;
			} else if (tryBlock.getHarvestTool(tryState)=="pickaxe") {
				if (ForgeHooks.canToolHarvestBlock(world, minePos, getStackInSlot(2))) {
					//ProgressiveAutomation.logger.info("Tool can harvest");
					return 2;
				}
			} else if (tryBlock.getHarvestTool(tryState)=="shovel") {
				if (ForgeHooks.canToolHarvestBlock(world, minePos, getStackInSlot(3))) {
					return 3;
				}
			} else {
				if (!tryBlock.getMaterial(tryState).isLiquid()) {
					return 1;
				}
			}
		}
		
		//see if the filler upgrade is active, if it is then the block will need to be filled.
		if (hasUpgrade(UpgradeType.FILLER)) {
			if ( (tryBlock.isAir(tryState, world, minePos)) || (tryBlock.getMaterial(tryState).isLiquid()) ) {
				return 4;
			}
		}
	}
	return 0;
}
 
開發者ID:Vanhal,項目名稱:ProgressiveAutomation,代碼行數:44,代碼來源:TileMiner.java


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