diff --git a/CJBItemSpawner/Framework/ItemData/ItemRepository.cs b/CJBItemSpawner/Framework/ItemData/ItemRepository.cs
index 73ff7d1b..53508e34 100644
--- a/CJBItemSpawner/Framework/ItemData/ItemRepository.cs
+++ b/CJBItemSpawner/Framework/ItemData/ItemRepository.cs
@@ -15,9 +15,20 @@ namespace CJBItemSpawner.Framework.ItemData;
/// This is copied from the SMAPI source code and should be kept in sync with it.
internal class ItemRepository
{
+ /*********
+ ** Fields
+ *********/
+ /// Used to communicate with other mods
+ private readonly ItemSpawnerAPI API;
+
/*********
** Public methods
*********/
+ public ItemRepository(ItemSpawnerAPI API)
+ {
+ this.API = API;
+ }
+
/// Get all spawnable items.
/// Only include items for the given .
/// Whether to include flavored variants like "Sunflower Honey".
@@ -90,7 +101,8 @@ public IEnumerable GetAll(string? onlyType = null, bool includeV
break;
default:
- if (result != null)
+ // skip blacklisted items
+ if (result != null && !this.API.IsBlacklisted(result.QualifiedItemId))
yield return result;
break;
}
@@ -99,6 +111,9 @@ public IEnumerable GetAll(string? onlyType = null, bool includeV
{
foreach (SearchableItem? variant in this.GetFlavoredObjectVariants(objectDataDefinition, result?.Item as SObject, itemType))
yield return variant;
+
+ foreach (SearchableItem? variant in this.API.GetVariantsFor("(O)", id, this.TryCreate))
+ yield return variant;
}
}
}
@@ -108,7 +123,17 @@ public IEnumerable GetAll(string? onlyType = null, bool includeV
// no special handling needed
default:
foreach (string id in itemType.GetAllIds())
- yield return this.TryCreate(itemType.Identifier, id, p => ItemRegistry.Create(itemType.Identifier + p.Id));
+ {
+ // skip blacklisted items
+ if (!this.API.IsBlacklisted(itemType.Identifier + id))
+ yield return this.TryCreate(itemType.Identifier, id, p => ItemRegistry.Create(itemType.Identifier + p.Id));
+
+ if (includeVariants)
+ {
+ foreach (SearchableItem? variant in this.API.GetVariantsFor(itemType.Identifier, id, this.TryCreate))
+ yield return variant;
+ }
+ }
break;
}
}
diff --git a/CJBItemSpawner/Framework/ItemSpawnerAPI.cs b/CJBItemSpawner/Framework/ItemSpawnerAPI.cs
new file mode 100644
index 00000000..9f2ad7b4
--- /dev/null
+++ b/CJBItemSpawner/Framework/ItemSpawnerAPI.cs
@@ -0,0 +1,90 @@
+using System;
+using System.Collections.Generic;
+using CJBItemSpawner.Framework.ItemData;
+using StardewValley;
+using StardewValley.Menus;
+
+namespace CJBItemSpawner.Framework
+{
+ public class ItemSpawnerAPI : IItemSpawnerAPI
+ {
+ /*********
+ ** Fields
+ *********/
+ internal delegate SearchableItem? SearchableItemFactory(string type, string key, Func createItem);
+
+ private readonly HashSet Blacklist = [];
+ private readonly Func BuildMenu;
+
+ public class VariantsRequestedEventArgs : IItemSpawnerAPI.IVariantsRequestedEventArgs
+ {
+ private readonly SearchableItemFactory TryCreate;
+ private readonly string type;
+ internal readonly List Items = [];
+
+ ///
+ public string BaseId { get; init; }
+
+ ///
+ public void TryAddVariant(string variantId, Func