本文整理汇总了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;
}