本文整理了Java中net.minecraft.item.ItemStack.getDestroySpeed()
方法的一些代码示例,展示了ItemStack.getDestroySpeed()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ItemStack.getDestroySpeed()
方法的具体详情如下:
包路径:net.minecraft.item.ItemStack
类名称:ItemStack
方法名:getDestroySpeed
暂无
代码示例来源:origin: ldtteam/minecolonies
/**
* Get the strength against a block.
*
* @param state the block.
* @return the float value.
*/
public float getStrVsBlock(final EnumHand hand, final IBlockState state)
{
float f = 1.0F;
if (hand.equals(EnumHand.MAIN_HAND))
{
if (!(this.mainInventory.get(this.mainItem)).isEmpty())
{
f *= (this.mainInventory.get(this.mainItem)).getDestroySpeed(state);
}
}
else if (hand.equals(EnumHand.OFF_HAND)
&& !(this.mainInventory.get(this.offhandItem)).isEmpty())
{
f *= (this.mainInventory.get(this.offhandItem)).getDestroySpeed(state);
}
return f;
}
代码示例来源:origin: cabaletta/baritone
/**
* Calculates how long would it take to mine the specified block given the best tool
* in this toolset is used. A negative value is returned if the specified block is unbreakable.
*
* @param item the item to mine it with
* @param state the blockstate to be mined
* @return how long it would take in ticks
*/
public static double calculateSpeedVsBlock(ItemStack item, IBlockState state) {
float hardness = state.getBlockHardness(null, null);
if (hardness < 0) {
return -1;
}
float speed = item.getDestroySpeed(state);
if (speed > 1) {
int effLevel = EnchantmentHelper.getEnchantmentLevel(Enchantments.EFFICIENCY, item);
if (effLevel > 0 && !item.isEmpty()) {
speed += effLevel * effLevel + 1;
}
}
speed /= hardness;
if (state.getMaterial().isToolNotRequired() || (!item.isEmpty() && item.canHarvestBlock(state))) {
return speed / 30;
} else {
return speed / 100;
}
}
代码示例来源:origin: McJtyMods/TheOneProbe
ItemTool toolItem = (ItemTool) testTool.getItem();
if (testTool.getDestroySpeed(blockState) >= toolItem.toolMaterial.getEfficiency()) {
内容来源于网络,如有侵权,请联系作者删除!