/** Used to check if a recipe matches current crafting inventory */ @Override public boolean matches(InventoryCrafting par1InventoryCrafting, World par2World) { this.enchantedBook = null; this.tool = null; for (int i = 0; i < 3; ++i) { for (int j = 0; j < 3; ++j) { ItemStack itemstack = par1InventoryCrafting.getStackInRowAndColumn(j, i); if (itemstack != null) { if (Item.getIdFromItem(itemstack.getItem()) == Item.getIdFromItem(Items.enchanted_book)) { if (this.enchantedBook != null) return false; this.enchantedBook = itemstack; } if (itemstack.getItem() instanceof ToolBase) { if (this.tool != null) return false; this.tool = ((ToolBase) itemstack.getItem()).getToolProperties(itemstack); } } } } return this.enchantedBook != null && this.tool != null; }
@Override public int compareTo(ItemKey o) { if (stack.getItem() != o.stack.getItem()) return compareInt(Item.getIdFromItem(stack.getItem()), Item.getIdFromItem(o.stack.getItem())); if (actualDamage(stack) != actualDamage(o.stack)) return compareInt(actualDamage(stack), actualDamage(o.stack)); return 0; }
public AnvilRecipe SetCraftingBound(int max) { craftingValue = 70 + new Random( (input1 != null ? Item.getIdFromItem(input1.getItem()) : 0) + (result != null ? Item.getIdFromItem(result.getItem()) : 0)) .nextInt(max); return this; }
public static NBTTagList getEnchantmentTagList(ItemStack itemStack) { NBTTagList nbttaglist = itemStack.getEnchantmentTagList(); if (nbttaglist == null || (nbttaglist.tagCount() == 0 && Item.getIdFromItem(itemStack.getItem()) == Item.getIdFromItem(Items.enchanted_book))) nbttaglist = Items.enchanted_book.func_92110_g(itemStack); return nbttaglist != null ? nbttaglist : new NBTTagList(); }
@SubscribeEvent public void openGui(PlayerOpenContainerEvent event) { ItemStack currentItem = event.entityPlayer.getCurrentEquippedItem(); if (currentItem != null) { if (Item.getIdFromItem(currentItem.getItem()) == Item.getIdFromItem(CommonProxy.portableItem) || Item.getIdFromItem(currentItem.getItem()) == Item.getIdFromItem(CommonProxy.portableBlock)) { event.setResult(Event.Result.ALLOW); } } }
public int getComparatorInputOverride(IBlockState blockState, World worldIn, BlockPos pos) { TileEntity tileentity = worldIn.getTileEntity(pos); if (tileentity instanceof BlockJukebox.TileEntityJukebox) { ItemStack itemstack = ((BlockJukebox.TileEntityJukebox) tileentity).getRecord(); if (itemstack != null) { return Item.getIdFromItem(itemstack.getItem()) + 1 - Item.getIdFromItem(Items.RECORD_13); } } return 0; }
public AnvilRecipe(ItemStack in, ItemStack in2, String p, AnvilReq req, ItemStack result) { this( in, in2, p.toLowerCase(), 70 + new Random( (in != null ? Item.getIdFromItem(in.getItem()) : 0) + (result != null ? Item.getIdFromItem(result.getItem()) : 0)) .nextInt(craftingBoundDefault), false, req.Tier, result); }
public boolean matches(ItemStack left, ItemStack right) { this.enchantedBook = null; this.tool = null; if (Item.getIdFromItem(right.getItem()) == Item.getIdFromItem(Items.enchanted_book)) { this.enchantedBook = right; } if (left.getItem() instanceof ToolBase) { this.tool = ((ToolBase) left.getItem()).getToolProperties(left); } return this.enchantedBook != null && this.tool != null; }
/** * Returns the bonus item produced from a smelting operation in the infernal furnace * * @param in The input of the smelting operation. e.g. new ItemStack(oreGold) * @return the The bonus item that can be produced */ public static ItemStack getSmeltingBonus(ItemStack in) { ItemStack out = smeltingBonus.get(Arrays.asList(Item.getIdFromItem(in.getItem()), in.getItemDamage())); if (out == null) { out = smeltingBonus.get( Arrays.asList(Item.getIdFromItem(in.getItem()), OreDictionary.WILDCARD_VALUE)); } if (out == null) { String od = OreDictionary.getOreName(OreDictionary.getOreID(in)); out = smeltingBonus.get(od); } return out; }
/** * A simple function for comparing ItemStacks in a compatible with comparators. * * @param stack1 The {@link ItemStack} being compared. * @param stack2 The {@link ItemStack} to compare to. * @return The ordering of stack1 relative to stack2. */ public static int compareStacks(ItemStack stack1, ItemStack stack2) { if (stack1 == stack2) { return 0; // catches both null } if (stack1 == null || stack2 == null) { return stack1 == null ? -1 : 1; // null stack goes first } if (stack1.getItem() != stack2.getItem()) { return Item.getIdFromItem(stack1.getItem()) - Item.getIdFromItem(stack2.getItem()); } if (stack1.stackSize != stack2.stackSize) { return stack1.stackSize - stack2.stackSize; } return stack1.getItemDamage() - stack2.getItemDamage(); }
public static Object[] getCraftingRecipeKey(EntityPlayer player, ItemStack stack) { int[] key = new int[] {Item.getIdFromItem(stack.getItem()), stack.getItemDamage()}; if (keyCache.containsKey(key)) { if (keyCache.get(key) == null) return null; if (ThaumcraftApiHelper.isResearchComplete( player.getCommandSenderName(), (String) (keyCache.get(key))[0])) return keyCache.get(key); else return null; } for (ResearchCategoryList rcl : ResearchCategories.researchCategories.values()) { for (ResearchItem ri : rcl.research.values()) { if (ri.getPages() == null) continue; for (int a = 0; a < ri.getPages().length; a++) { ResearchPage page = ri.getPages()[a]; if (page.recipeOutput != null && stack != null && page.recipeOutput.isItemEqual(stack)) { keyCache.put(key, new Object[] {ri.key, a}); if (ThaumcraftApiHelper.isResearchComplete(player.getCommandSenderName(), ri.key)) return new Object[] {ri.key, a}; else return null; } } } } keyCache.put(key, null); return null; }
private static void func_151179_e() { Iterator var0 = Item.itemRegistry.iterator(); while (var0.hasNext()) { Item var1 = (Item) var0.next(); if (var1 != null) { int var2 = Item.getIdFromItem(var1); String var3 = func_180204_a(var1); if (var3 != null && var1.isDamageable()) { objectBreakStats[var2] = (new StatCrafting( "stat.breakItem.", var3, new ChatComponentTranslation( "stat.breakItem", new Object[] {(new ItemStack(var1)).getChatComponent()}), var1)) .registerStat(); } } } replaceAllSimilarBlocks(objectBreakStats); }
private static void initStats() { Iterator var0 = Item.itemRegistry.iterator(); while (var0.hasNext()) { Item var1 = (Item) var0.next(); if (var1 != null) { int var2 = Item.getIdFromItem(var1); String var3 = func_180204_a(var1); if (var3 != null) { objectUseStats[var2] = (new StatCrafting( "stat.useItem.", var3, new ChatComponentTranslation( "stat.useItem", new Object[] {(new ItemStack(var1)).getChatComponent()}), var1)) .registerStat(); if (!(var1 instanceof ItemBlock)) { itemStats.add((StatCrafting) objectUseStats[var2]); } } } } replaceAllSimilarBlocks(objectUseStats); }
/** * Registeres a piece (called by code or config) * * @param piece the item to list * @param weight the weight of the piece (Kg) * @param bulk the bulk of the piece * @param alterSpeed if the armour's weight slows you down */ public static void registerItem(Item piece, float efficiency) { int id = Item.getIdFromItem(piece); MineFantasyAPI.debugMsg( "Added Custom hoe: " + piece.getUnlocalizedName() + " Efficiency = " + efficiency); entries.put(id, new CustomHoeEntry(id, efficiency)); }
/** Called when the mob's health reaches 0. */ public void onDeath(DamageSource cause) { super.onDeath(cause); if (cause.getEntity() instanceof EntitySkeleton) { int i = Item.getIdFromItem(Items.record_13); int j = Item.getIdFromItem(Items.record_wait); int k = i + this.rand.nextInt(j - i + 1); this.dropItem(Item.getItemById(k), 1); } else if (cause.getEntity() instanceof EntityCreeper && cause.getEntity() != this && ((EntityCreeper) cause.getEntity()).getPowered() && ((EntityCreeper) cause.getEntity()).isAIEnabled()) { ((EntityCreeper) cause.getEntity()).func_175493_co(); this.entityDropItem(new ItemStack(Items.skull, 1, 4), 0.0F); } }
public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn) { if (playerIn.isSneaking()) { if (!playerIn.capabilities.isCreativeMode) { --itemStackIn.stackSize; } worldIn.playSoundAtEntity( playerIn, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F)); if (!worldIn.isRemote) { // EntityEnchantedEbonheart worldIn.spawnEntityInWorld(new EntityEnchantedEbonheart(worldIn, playerIn)); // EntityEnchantedEbonheart entityenchantedebonheart = new EntityEnchantedEbonheart(worldIn, // playerIn); // entityenchantedebonheart.setHeadingFromThrower(playerIn, playerIn.rotationPitch, // playerIn.rotationYaw, -20.0F, 0.7F, 1.0F); // worldIn.spawnEntityInWorld(entityenchantedebonheart); // EntityExpBottle entityexpbottle = new EntityExpBottle(worldIn, playerIn); // entityexpbottle.func_184538_a(playerIn, playerIn.rotationPitch, playerIn.rotationYaw, // -20.0F, 0.7F, 1.0F); // worldIn.spawnEntityInWorld(entityexpbottle); } playerIn.triggerAchievement(StatList.objectUseStats[Item.getIdFromItem(this)]); return itemStackIn; } return itemStackIn; }
public StatCrafting( String p_i45910_1_, String p_i45910_2_, IChatComponent p_i45910_3_, Item p_i45910_4_) { super(p_i45910_1_ + p_i45910_2_, p_i45910_3_); this.field_150960_a = p_i45910_4_; int var5 = Item.getIdFromItem(p_i45910_4_); if (var5 != 0) { IScoreObjectiveCriteria.INSTANCES.put(p_i45910_1_ + var5, this.func_150952_k()); } }
/** * Gets the entry for an item * * @param piece the armour item * @return the entry(if there is one), else null */ public static CustomHoeEntry getEntry(Item piece) { if (piece != null) { int id = Item.getIdFromItem(piece); if (entries.containsKey(piece)) { return entries.get(piece); } } return null; }
@Nullable @Override public BaseItem createFromId(int id) { Item item = (Item) Item.itemRegistry.getObjectById(id); if (item != null) { return new BaseItem(Item.getIdFromItem(item), (short) item.getDamage(new ItemStack(item, 1))); } else { return null; } }
boolean stackEqual(ItemStack toInsert, ItemStack existing) { if (toInsert == null || existing == null) { return false; } boolean matched = false; if (useOreDict) { int existingId = OreDictionary.getOreID(existing); matched = existingId != -1 && existingId == OreDictionary.getOreID(toInsert); } if (!matched) { matched = Item.getIdFromItem(toInsert.getItem()) == Item.getIdFromItem(existing.getItem()); if (matched && matchMeta) { matched = toInsert.getItemDamage() == existing.getItemDamage(); } if (matched && matchNBT) { matched = ItemStack.areItemStackTagsEqual(toInsert, existing); } } return matched; }
public static boolean hasScannedOffline(UUID playerID, ItemStack stack) { List<Pair<ScanResult, Pair<Double, Double>>> offlineScans = TEC.aspectBuffer.get(playerID); if (offlineScans != null) { for (Pair<ScanResult, Pair<Double, Double>> scanPair : offlineScans) { if (scanPair.getKey().id == Item.getIdFromItem(stack.getItem()) && scanPair.getKey().meta == stack.getItemDamage()) { return true; } } } return false; }
public static String itemName(ItemStack item) { String idText = ""; if (Minecraft.getMinecraft().gameSettings.advancedItemTooltips) { if (item.getHasSubtypes()) { idText = String.format( " (%s #%04d/%d)", Item.itemRegistry.getNameForObject(item.getItem()), Item.getIdFromItem(item.getItem()), getItemDamage(item)); } else { idText = String.format( " (%s #%04d)", Item.itemRegistry.getNameForObject(item.getItem()), Item.getIdFromItem(item.getItem())); } } return item.getDisplayName() + idText; }
@Nullable private IPart getRenderer(final ItemStack is, final IPartItem c) { final int id = (Item.getIdFromItem(is.getItem()) << Platform.DEF_OFFSET) | is.getItemDamage(); IPart part = RENDER_PART.get(id); if (part == null) { part = c.createPartFromItemStack(is); if (part != null) { RENDER_PART.put(id, part); } } return part; }
/** * Gets all the integer ID for the ores that the specified item stakc is registered to. If the * item stack is not linked to any ore, this will return an empty array and no new entry will be * created. * * @param stack The item stack of the ore. * @return An array of ids that this ore is registerd as. */ public static int[] getOreIDs(ItemStack stack) { if (stack == null || stack.getItem() == null) throw new IllegalArgumentException("Stack can not be null!"); Set<Integer> set = new HashSet<Integer>(); int id = Item.getIdFromItem(stack.getItem()); List<Integer> ids = stackToId.get(id); if (ids != null) set.addAll(ids); ids = stackToId.get(id | ((stack.getItemDamage() + 1) << 16)); if (ids != null) set.addAll(ids); Integer[] tmp = set.toArray(new Integer[set.size()]); int[] ret = new int[tmp.length]; for (int x = 0; x < tmp.length; x++) ret[x] = tmp[x]; return ret; }
protected void drawSlot( int p_180791_1_, int p_180791_2_, int p_180791_3_, int p_180791_4_, int p_180791_5_, int p_180791_6_) { StatCrafting var7 = this.func_148211_c(p_180791_1_); Item var8 = var7.func_150959_a(); GuiStats.this.drawStatsScreen(p_180791_2_ + 40, p_180791_3_, var8); int var9 = Item.getIdFromItem(var8); this.func_148209_a( StatList.objectBreakStats[var9], p_180791_2_ + 115, p_180791_3_, p_180791_1_ % 2 == 0); this.func_148209_a( StatList.objectCraftStats[var9], p_180791_2_ + 165, p_180791_3_, p_180791_1_ % 2 == 0); this.func_148209_a(var7, p_180791_2_ + 215, p_180791_3_, p_180791_1_ % 2 == 0); }
public static final String getItemKey(ItemStack itemStack) { Item item = itemStack.getItem(); String key = String.valueOf(Item.getIdFromItem(item)) + ":" + String.valueOf(itemStack.getItemDamage()); if (!(item instanceof IFood)) return key; key += ":" + (Food.isBrined(itemStack) ? "1" : "0") + (Food.isPickled(itemStack) ? "1" : "0") + (Food.isCooked(itemStack) ? "1" : "0") + (Food.isDried(itemStack) ? "1" : "0") + (Food.isSmoked(itemStack) ? "1" : "0") + (Food.isSalted(itemStack) ? "1" : "0"); return key; }
/** * Initializes statistics related to craftable items. Is only called after both block and item * stats have been initialized. */ private static void initCraftableStats() { HashSet var0 = Sets.newHashSet(); Iterator var1 = CraftingManager.getInstance().getRecipeList().iterator(); while (var1.hasNext()) { IRecipe var2 = (IRecipe) var1.next(); if (var2.getRecipeOutput() != null) { var0.add(var2.getRecipeOutput().getItem()); } } var1 = FurnaceRecipes.instance().getSmeltingList().values().iterator(); while (var1.hasNext()) { ItemStack var5 = (ItemStack) var1.next(); var0.add(var5.getItem()); } var1 = var0.iterator(); while (var1.hasNext()) { Item var6 = (Item) var1.next(); if (var6 != null) { int var3 = Item.getIdFromItem(var6); String var4 = func_180204_a(var6); if (var4 != null) { objectCraftStats[var3] = (new StatCrafting( "stat.craftItem.", var4, new ChatComponentTranslation( "stat.craftItem", new Object[] {(new ItemStack(var6)).getChatComponent()}), var6)) .registerStat(); } } } replaceAllSimilarBlocks(objectCraftStats); }
@Override protected void writeSyncTag(NBTTagCompound NBT) { super.writeSyncTag(NBT); NBT.setBoolean("dig", digging); NBT.setBoolean("dig2", digReady); NBT.setInteger("index", index); NBT.setBoolean("finish", finishedDigging); NBTTagList li = new NBTTagList(); for (ItemStack is : found.keySet()) { NBTTagCompound tag = new NBTTagCompound(); tag.setInteger("id", Item.getIdFromItem(is.getItem())); tag.setInteger("meta", is.getItemDamage()); tag.setInteger("count", found.get(is)); li.appendTag(tag); } NBT.setTag("count", li); NBT.setBoolean("dropped", dropFlag); }
public static void rebakeMap() { // System.out.println("Baking OreDictionary:"); stackToId.clear(); for (int id = 0; id < idToStack.size(); id++) { List<ItemStack> ores = idToStack.get(id); if (ores == null) continue; for (ItemStack ore : ores) { int hash = Item.getIdFromItem(ore.getItem()); if (ore.getItemDamage() != WILDCARD_VALUE) { hash |= ((ore.getItemDamage() + 1) << 16); // +1 so meta 0 is significant } List<Integer> ids = stackToId.get(hash); if (ids == null) { ids = Lists.newArrayList(); stackToId.put(hash, ids); } ids.add(id); // System.out.println(id + " " + getOreName(id) + " " + Integer.toHexString(hash) + " " + // ore); } } }
/** * Registers a ore item into the dictionary. Raises the registerOre function in all registered * handlers. * * @param name The name of the ore * @param ore The ore's ItemStack */ private static void registerOreImpl(String name, ItemStack ore) { if ("Unknown".equals(name)) return; // prevent bad IDs. int oreID = getOreID(name); int hash = Item.getIdFromItem(ore.getItem()); if (ore.getItemDamage() != WILDCARD_VALUE) { hash |= ((ore.getItemDamage() + 1) << 16); // +1 so 0 is significant } // Add things to the baked version, and prevent duplicates List<Integer> ids = stackToId.get(hash); if (ids != null && ids.contains(oreID)) return; if (ids == null) { ids = Lists.newArrayList(); stackToId.put(hash, ids); } ids.add(oreID); // Add to the unbaked version ore = ore.copy(); idToStack.get(oreID).add(ore); MinecraftForge.EVENT_BUS.post(new OreRegisterEvent(name, ore)); }