當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。