Resource icon

CraftResourceProviders: Craft from Bank (Provider Framework + Optional Virtual Storage Support) 1.0.3

Author
unblest
Downloads
13
Views
437
First release
Last update

Ratings

0.00 star(s) 0 ratings
No permission to download Join the discussion

More resources from unblest

Requirements
ServUO (tested on p58-wip / ServUO 5.8)
Server running C# 7.3 / .NET 4.x (default ServUO tooling)
For the optional add-on: Feng’s VirtualStorageChest system installed https://www.servuo.dev/archive/virtual-storage-chests-qol-item-count-reduction-system.2593/
Everything is vibe coded using gpt-5.2. Document below is also generated using gpt-5.2

What the base package does

  • Keeps all normal crafting behavior and validations intact.
  • Extends the resource lookup/consumption path so crafting checks:
    1. Backpack
    2. (Optional) any custom providers you add later
    3. BankBox (recursive)

What the optional VirtualStorage add-on does

If you also use Feng’s VirtualStorageChest system, you can install the optional module to let crafting pull resources from your VirtualStorageChests as well.
  • Uses account tags to persist which chests are “linked” for crafting
    (account-wide, shared by all characters on the account).

How to modify (base package)

File to edit in ServUO

  • Scripts/Services/Craft/Core/CraftItem.cs

Step A: add one using

At the top of the file, in the references/usings area, add:
Code:
Expand Collapse Copy
using Server.Custom.CraftResourceProviders;

Step B: replace the UseAllRes max-calculation lookup

Inside ConsumeRes(...), search for the UseAllRes block that computes tempAmount from the backpack.
You will find a line like:
Code:
Expand Collapse Copy
int tempAmount = ourPack.GetAmount(types[i]);
Replace that single line so it calls the provider chain instead of the backpack:
Code:
Expand Collapse Copy
int tempAmount = CraftResourceService.Chain.GetBestGroupAmount(from, types[i], true, CheckHueGrouping);

Step C: replace the grouped-consume calls (twice)

Still inside ConsumeRes(...), search for the grouped consume call that looks like:
Code:
Expand Collapse Copy
ourPack.ConsumeTotalGrouped(types, amounts, true, ResourceValidator, OnResourceConsumed, CheckHueGrouping);
This appears in both:
  • the ConsumeType.All branch
  • the ConsumeType.Half branch
For both occurrences, replace the backpack call with the provider chain call:
Code:
Expand Collapse Copy
CraftResourceService.Chain.ConsumeTotalGrouped(from, types, amounts, true, ResourceValidator, OnResourceConsumed, CheckHueGrouping);
That’s it. Crafting will now “see” resources from backpack and bank (and any optional providers you plug into the chain).

Git diff (ServUO changes)

Code:
Expand Collapse Copy
[COLOR=rgb(106, 115, 125)]diff --git a/Scripts/Services/Craft/Core/CraftItem.cs b/Scripts/Services/Craft/Core/CraftItem.cs

index 041055e55..ead9fc5b0 100644

--- a/Scripts/Services/Craft/Core/CraftItem.cs

+++ b/Scripts/Services/Craft/Core/CraftItem.cs[/COLOR]

[COLOR=rgb(0, 92, 197)]@@ -1,4 +1,5 @@[/COLOR]

 #region References

[COLOR=rgb(34, 134, 58)]+using Server.Custom.CraftResourceProviders;[/COLOR]

 using Server.Commands;

 using Server.Engines.Plants;

 using Server.Engines.Quests;

[COLOR=rgb(0, 92, 197)]@@ -1002,7 +1003,7 @@[/COLOR] namespace Server.Engines.Craft

                 // For stackable items that can ben crafted more than one at a time

                 if (UseAllRes)

                 {

[COLOR=rgb(179, 29, 40)]-                    int tempAmount = ourPack.GetAmount(types[i]);[/COLOR]

[COLOR=rgb(34, 134, 58)]+                    int tempAmount = CraftResourceService.Chain.GetBestGroupAmount(from, types[i], true, CheckHueGrouping);[/COLOR]

                     tempAmount /= amounts[i];



                     if (tempAmount < maxPossible)

[COLOR=rgb(0, 92, 197)]@@ -1136,7 +1137,7 @@[/COLOR] namespace Server.Engines.Craft

                 }

                 else

                 {

[COLOR=rgb(179, 29, 40)]-                    index = ourPack.ConsumeTotalGrouped(types, amounts, true, ResourceValidator, OnResourceConsumed, CheckHueGrouping);[/COLOR]

[COLOR=rgb(34, 134, 58)]+                    index = CraftResourceService.Chain.ConsumeTotalGrouped(from, types, amounts, true, ResourceValidator, OnResourceConsumed, CheckHueGrouping);[/COLOR]

                 }



                 resHue = m_ResHue;

[COLOR=rgb(0, 92, 197)]@@ -1168,7 +1169,7 @@[/COLOR] namespace Server.Engines.Craft

                 }

                 else

                 {

[COLOR=rgb(179, 29, 40)]-                    index = ourPack.ConsumeTotalGrouped(types, amounts, true, ResourceValidator, OnResourceConsumed, CheckHueGrouping);[/COLOR]

[COLOR=rgb(34, 134, 58)]+                    index = CraftResourceService.Chain.ConsumeTotalGrouped(from, types, amounts, true, ResourceValidator, OnResourceConsumed, CheckHueGrouping);[/COLOR]

                 }



                 resHue = m_ResHue;

Optional VirtualStorage: provider insertion instruction

If you install the optional VirtualStorage module, edit:
  • Scripts/Custom/CraftResourceProviders/CraftResourceProviderBootstrap.cs
In the provider list, insert the VirtualStorage provider between backpack and bank:
Code:
Expand Collapse Copy
new VirtualStorageChestResourceProvider(new AccountTagVirtualStorageLocator()),
  • copy_CraftResourceProviders.jpg
    copy_CraftResourceProviders.jpg
    315.1 KB · Views: 90
  • Like
Reactions: Moll Dayer and Feng

Latest Updates

  1. Various fixes

    1. VirtualStorage: Virtual Storage Chests adapter now correctly propagates material hue 2...
  2. Fixed issue file not being attached

    No change in the code itself
  3. Included an instruction to adding providers

    Updated file: HowToAddProvider.md

Donations

Total amount
$0.00
Goal
$500.00

Shards

Back