Changes

Jump to navigation Jump to search
→‎Inventory class: expand migration notes to cover special cases
Line 2,647: Line 2,647:  
! migration
 
! migration
 
|-
 
|-
|rowspan="6"| <samp>Farmer</samp>
+
|rowspan="5"| <samp>Farmer</samp>
| <code>getItemCount(id)</code><br /><code>GetTallyOfObject(id)</code><br /><code>GetTallyOfObject(id, isBigCraftable)</code>
+
| <code>getItemCount(id)</code><br /><code>GetTallyOfObject(id)</code><br /><code>GetTallyOfObject(id, isBigCraftable)</code><br /><code>hasItemInInventory(id, count)</code><br /><code>hasItemInInventoryNamed(name)</code><br /><code>hasItemInList(list, id, count)</code><br /><code>hasItemWithNameThatContains(name)</code>
| Use <code>items.CountId(id)</code>.
+
| &#32;
|-
+
* To check an item ID, use <code>items.CountId(id)</code> or <code>Items.ContainsId(id, count)</code>.
| <code>hasItemInInventory(id, count)</code><br /><code>hasItemInInventoryNamed(name)</code><br /><code>hasItemWithNameThatContains(name)</code>
+
* To check Golden Walnuts or Qi Gems, use the <samp>Game1.netWorldState.Value.GoldenWalnuts</samp> and <samp>Farmer.QiGems</samp> fields.
| Use <code>Items.ContainsId(id, count)</code>.
+
* To check category matches or <samp>-777</samp> (seasonal wild seeds), the <samp>getItemCount</samp> and <samp>getItemCountInList</samp> still exist.
|-
  −
| <code>hasItemInList(list, id, count)</code>
  −
| Use <code>list.ContainsId(id, count)</code>.
   
|-
 
|-
 
| <code>areAllItemsNull()</code>
 
| <code>areAllItemsNull()</code>
Line 2,663: Line 2,660:  
| Use <code>items.CountItemStacks()</code> to count all items, or <code>Items.Count(p => p is Object)</code> to match this method's actual behavior.
 
| Use <code>items.CountItemStacks()</code> to count all items, or <code>Items.Count(p => p is Object)</code> to match this method's actual behavior.
 
|-
 
|-
| <code>consumeObject(id, count)</code><br /><code>removeItemsFromInventory(id, count)</code>
+
| <code>consumeObject(id, count)</code>
 
| Use <code>items.ReduceId(id, count)</code>.
 
| Use <code>items.ReduceId(id, count)</code>.
 +
|-
 +
| <code>removeItemsFromInventory(id, count)</code>
 +
| &#32;
 +
* To remove an item by ID, use <code>removeItemsFromInventory(id, count)</code>.
 +
* To deduct Golden Walnuts or Qi Gems, change the <samp>Game1.netWorldState.Value.GoldenWalnuts</samp> and <samp>Farmer.QiGems</samp> fields.
 
|-
 
|-
 
|rowspan="2"| <samp>Object</samp>
 
|rowspan="2"| <samp>Object</samp>
 
| <code>ConsumeInventoryItem(player, id, count)</code>
 
| <code>ConsumeInventoryItem(player, id, count)</code>
| This was somewhat specialized and shouldn't be called by mod code, but the equivalent would be <code>(obj.autoLoadChest?.items ?? player.items).ReduceId(id, count)</code>.
+
| This was somewhat specialized and shouldn't be called by mod code, but the equivalent would be <code>(obj.autoLoadChest?.items ?? player.items).ReduceId(id, count)</code>. See also notes for <samp>Farmer.removeItemsFromInventory</samp>.
 
|-
 
|-
 
| <code>GetTallyOfObject(player, id)</code>
 
| <code>GetTallyOfObject(player, id)</code>
| This was somewhat specialized and shouldn't be called by mod code, but the equivalent would be <code>(obj.autoLoadChest?.items ?? player.items).CountId(id)</code>.
+
| This was somewhat specialized and shouldn't be called by mod code, but the equivalent would be <code>(obj.autoLoadChest?.items ?? player.items).CountId(id)</code>. See also notes for <samp>Farmer.getTallyOfObject</samp>.
 
|}
 
|}
  
translators
8,445

edits

Navigation menu