本文整理匯總了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());
}
}
示例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;
}
示例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();
}
}
示例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();
}
示例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;
}
示例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;
}
示例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;
}