当前位置: 首页>>代码示例>>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;未经允许,请勿转载。