@Override public Item getItem() { return Item.getItemById(itemID); }
final short dmgValue = data.readShort(); final Item myItem = Item.getItemById( itemID );
private static Item getItemByText(String str) { str = str.replace("%20", " "); Item item = Item.REGISTRY.getObject(new ResourceLocation(str)); if (item == null) { try { item = Item.getItemById(Integer.parseInt(str)); } catch (NumberFormatException numberformatexception) {} } return item; }
@CCCommand(description = "Returns a list of all ItemIdentifier with an NBT tag matching the givven Item ID and data") public List<ItemIdentifier> matchingNBTIdentifier() { Item item = Item.getItemById(itemID); if (item == null) { throw new UnsupportedOperationException("Not a valid ItemIdentifier"); } return ItemIdentifier.getMatchingNBTIdentifier(item, itemData); }
@Override public void addTooltip(List<String> list, int mouseX, int mouseY) { list.add(MOStringHelper.translateToLocal(Item.getItemById(id).getUnlocalizedName() + ".name") + " [" + count + "]"); }
public static CraftingPreviewElementItemStack fromByteBuf(ByteBuf buf) { Item item = Item.getItemById(buf.readInt()); int meta = buf.readInt(); NBTTagCompound tag = ByteBufUtils.readTag(buf); int available = buf.readInt(); boolean missing = buf.readBoolean(); int toCraft = buf.readInt(); ItemStack stack = new ItemStack(item, 1, meta); stack.setTagCompound(tag); return new CraftingPreviewElementItemStack(stack, available, missing, toCraft); }
public static ItemStack readItemStack(ByteBuf buf) { ItemStack stack = new ItemStack(Item.getItemById(buf.readInt()), buf.readInt(), buf.readShort()); stack.setTagCompound(ByteBufUtils.readTag(buf)); return stack; }
@Override public void drawForeground(int mouseX, int mouseY) { RenderUtils.renderStack(posX + 2, posY + 2, new ItemStack(Item.getItemById(id))); gui.getFontRenderer().drawStringWithShadow(Integer.toString(count), posX + 8, posY + 24, 0xFFFFFF); } }
@Nullable @Override public ItemIdentifier readItemIdentifier() { final int itemId = readInt(); if (itemId == 0) { return null; } int damage = readInt(); NBTTagCompound tag = readNBTTagCompound(); return ItemIdentifier.get(Item.getItemById(itemId), damage, tag); }
public static CraftingPreviewElementError fromByteBuf(ByteBuf buf) { int errorIdx = buf.readInt(); CraftingTaskErrorType error = errorIdx >= 0 && errorIdx < CraftingTaskErrorType.values().length ? CraftingTaskErrorType.values()[errorIdx] : CraftingTaskErrorType.TOO_COMPLEX; Item item = Item.getItemById(buf.readInt()); int meta = buf.readInt(); NBTTagCompound tag = ByteBufUtils.readTag(buf); ItemStack stack = new ItemStack(item, 1, meta); stack.setTagCompound(tag); return new CraftingPreviewElementError(error, stack); }
public static Map<UniqueItem, Integer> nbtToItemCount(@Nullable NBTTagList tagList) { Map<UniqueItem, Integer> itemCountMap = new HashMap<UniqueItem, Integer>(); if (tagList == null) return itemCountMap; for (int i = 0; i < tagList.tagCount(); i++) { NBTTagCompound tagCompound = tagList.getCompoundTagAt(i); UniqueItem uniqueItem = new UniqueItem(Item.getItemById(tagCompound.getInteger("item")), tagCompound.getInteger("meta")); int count = tagCompound.getInteger("count"); itemCountMap.put(uniqueItem, count); } return itemCountMap; } }
@Override public void executeCommand(ICommandSender sender, String[] args) { if (args.length < 2) { throw new MissingArgumentException(); } String idString = args[0]; String metaString = args[1]; int id = Integer.valueOf(idString); int meta = Integer.valueOf(metaString); ItemIdentifier item = ItemIdentifier.get(Item.getItemById(id), meta, null); sender.sendMessage(new TextComponentString("Name: " + item.getFriendlyNameCC())); } }
@CCCommand(description = "Returns the ItemIdentifier for this ItemIdentifierBuilder") public ItemIdentifier build() { Item item = null; if(itemIDName != null) { item = (Item) Item.REGISTRY.getObject(new ResourceLocation(itemIDName)); } else { item = Item.getItemById(itemID); } if (item == null) { throw new UnsupportedOperationException("Not a valid ItemIdentifier"); } return ItemIdentifier.get(item, itemData, null); }
public Map<IBlockState, UniqueItem> getIntStackMapFromNBT(NBTTagList tagList) { intStackMap = new HashMap<IBlockState, UniqueItem>(); for (int i = 0; i < tagList.tagCount(); i++) { NBTTagCompound compound = tagList.getCompoundTagAt(i); intStackMap.put(GadgetUtils.compoundToState(compound.getCompoundTag("state")), new UniqueItem(Item.getItemById(compound.getInteger("item")), compound.getInteger("meta"))); } return intStackMap; }
public static void readPacketData(PacketBuffer buf, EntityPlayer player) { int itemId = buf.readShort(); Item item = Item.getItemById(itemId); ItemStack playerItem = player.inventory.getItemStack(); if (!playerItem.isEmpty() && playerItem.getItem() == item) { player.inventory.setItemStack(ItemStack.EMPTY); } } }
public ItemStack readItemStack() throws IOException { ItemStack stack = ItemStack.EMPTY; short itemID = getShort(); if (itemID >= 0) { byte stackSize = getByte(); short damage = getShort(); stack = new ItemStack(Item.getItemById(itemID), stackSize, damage); stack.setTagCompound(readNBT()); } return stack; }
public ItemStack toItemStack(boolean withInfo) { ItemStack itemStack = new ItemStack(Item.getItemById(itemID)); itemStack.setItemDamage(damage); if (withInfo) { itemStack.setTagCompound(new NBTTagCompound()); itemStack.getTagCompound().setByte(MatterDatabaseHelper.PROGRESS_TAG_NAME, (byte) progress); } return itemStack; }
public static ItemStack readItemStackFromNBT(NBTTagCompound nbt) { ItemStack stack = new ItemStack(Item.getItemById(nbt.getShort("id"))); stack.setCount(nbt.getInteger("Count")); stack.setItemDamage(Math.max(0, nbt.getShort("Damage"))); if (nbt.hasKey("tag", 10)) { stack.setTagCompound(nbt.getCompoundTag("tag")); } return stack; }
@Nonnull public static ItemStack deserializeStackFromNbt(NBTTagCompound tag) { ItemStack stack = new ItemStack( Item.getItemById(tag.getInteger(NBT_ITEM_TYPE)), tag.getInteger(NBT_ITEM_QUANTITY), tag.getInteger(NBT_ITEM_DAMAGE), tag.hasKey(NBT_ITEM_CAPS) ? tag.getCompoundTag(NBT_ITEM_CAPS) : null ); stack.setTagCompound(tag.hasKey(NBT_ITEM_NBT) ? tag.getCompoundTag(NBT_ITEM_NBT) : null); return stack; } }
int max = Item.getIdFromItem(Items.RECORD_WAIT); for(int i = min; i <= max; i++) BotaniaAPI.blackListItemFromLoonium(Item.getItemById(i));