当前位置: 首页>>代码示例>>Java>>正文


Java Item.equals方法代码示例

本文整理汇总了Java中net.minecraft.item.Item.equals方法的典型用法代码示例。如果您正苦于以下问题:Java Item.equals方法的具体用法?Java Item.equals怎么用?Java Item.equals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.minecraft.item.Item的用法示例。


在下文中一共展示了Item.equals方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: stackEqualsNonNBT

import net.minecraft.item.Item; //导入方法依赖的package包/类
public static boolean stackEqualsNonNBT(@Nonnull ItemStack stack, @Nonnull  ItemStack other) {
    if (stack.isEmpty() && other.isEmpty())
        return true;
    if (stack.isEmpty() || other.isEmpty())
        return false;
    Item sItem = stack.getItem();
    Item oItem = other.getItem();
    if (sItem.getHasSubtypes() || oItem.getHasSubtypes()) {
        return sItem.equals(other.getItem()) &&
                (stack.getItemDamage() == other.getItemDamage() ||
                        stack.getItemDamage() == OreDictionary.WILDCARD_VALUE ||
                        other.getItemDamage() == OreDictionary.WILDCARD_VALUE);
    } else {
        return sItem.equals(other.getItem());
    }
}
 
开发者ID:HellFirePvP,项目名称:ModularMachinery,代码行数:17,代码来源:ItemUtils.java

示例2: isBlockOreDict

import net.minecraft.item.Item; //导入方法依赖的package包/类
public static boolean isBlockOreDict(World world, BlockPos pos, String ore) {
    IBlockState state = world.getBlockState(pos);
    Item item = Item.getItemFromBlock(state.getBlock());
    if (!item.equals(Items.AIR)) {
        ItemStack stack = new ItemStack(item);
        int id = OreDictionary.getOreID(ore);
        for (int i : OreDictionary.getOreIDs(stack)) {
            if (i == id) return true;
        }
    }
    return false;
}
 
开发者ID:Buuz135,项目名称:Industrial-Foregoing,代码行数:13,代码来源:BlockUtils.java

示例3: runIfAirOrBlockHeld

import net.minecraft.item.Item; //导入方法依赖的package包/类
public void runIfAirOrBlockHeld(Runnable blockHeld, Runnable airHeld) {
    Item heldItem = player.getHeldItemMainhand().getItem();
    
    if(heldItem.equals(Items.AIR)) {
        info("You don't hold a block. The command will do the cleaning.");
        airHeld.run();
    } else if(!(heldItem instanceof ItemBlock)) {
        info("Hold a block");
    } else {
        blockHeld.run();
    }
}
 
开发者ID:JustinSDK,项目名称:craftsman,代码行数:13,代码来源:FstPlayer.java

示例4: runIfAirOrStairsHeld

import net.minecraft.item.Item; //导入方法依赖的package包/类
public void runIfAirOrStairsHeld(Runnable runnable) {
    Item heldItem = player.getHeldItemMainhand().getItem();
    Block heldBlock = Block.getBlockFromItem(heldItem);
    
    if(heldItem.equals(Items.AIR)) {
        info("You don't hold stairs. The command will do the cleaning.");
    } else if(!(heldBlock instanceof BlockStairs)) {
        info("Hold stairs");
        return;
    }        
    
    runnable.run();
}
 
开发者ID:JustinSDK,项目名称:craftsman,代码行数:14,代码来源:FstPlayer.java

示例5: player_itemSlotHotbar

import net.minecraft.item.Item; //导入方法依赖的package包/类
public static int player_itemSlotHotbar(Item compare) {
    for (int i = 0; i < 9; i++) {
        if (Wrapper.player_inventoryItems() != null) {
            try {
                Item item = getItemFromStack(Wrapper.player_inventoryItems()[i]);
                if (item != null && item.equals(compare))
                    return i;
            } catch (Exception e) {
                continue;
            }
        }
    }
    return -1;
}
 
开发者ID:Ygore,项目名称:bit-client,代码行数:15,代码来源:ItemUtil.java

示例6: player_itemSlot

import net.minecraft.item.Item; //导入方法依赖的package包/类
public static int player_itemSlot(Item compare) {
    for (int i = 0; i < Wrapper.player_inventoryItems().length; i++) {
        if (Wrapper.player_inventoryItems() != null) {
            try {
                Item item = getItemFromStack(Wrapper.player_inventoryItems()[i]);
                if (item != null && item.equals(compare))
                    return i;
            } catch (Exception e) {
                continue;
            }
        }
    }
    return -1;
}
 
开发者ID:Ygore,项目名称:bit-client,代码行数:15,代码来源:ItemUtil.java

示例7: player_itemSlot_noHotbar

import net.minecraft.item.Item; //导入方法依赖的package包/类
public static int player_itemSlot_noHotbar(Item compare) {
    for (int i = 9; i < Wrapper.player_inventoryItems().length; i++) {
        if (Wrapper.player_inventoryItems() != null) {
            try {
                Item item = getItemFromStack(Wrapper.player_inventoryItems()[i]);
                if (item != null && item.equals(compare))
                    return i;
            } catch (Exception e) {
                continue;
            }
        }
    }
    return -1;
}
 
开发者ID:Ygore,项目名称:bit-client,代码行数:15,代码来源:ItemUtil.java


注:本文中的net.minecraft.item.Item.equals方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。