Refined Storage

Refined Storage

77M Downloads

How to use IExternalStorageProvider?

pkmnfrk opened this issue ยท 5 comments

commented

Issue description:

I am trying to implement IExternalStorageProvider in my mod to address pkmnfrk/equivalentintegrations#12, but it's behaving weird.

I suspect that I'm doing something wrong, but I do not know what.

My implementation is here: https://github.com/pkmnfrk/equivalentintegrations/tree/rscompat/src/main/java/com/mike_caron/equivalentintegrations/integrations/refinedstorage

What happens:

It seems to count each item I present twice. Eg, if I say there are 1000 Cobblestone, it shows 2000.

I believe it is combining the IStorageExternal with the usual IItemHandler capability, and showing both as external storage.

What you expected to happen:

If an IStorageExternal is present, ignore the IItemHandler.

Steps to reproduce:

  1. Install my mod (if you check out the repo, it includes a dependency on RS, so you can fire it up)
  2. Obtain a Soulbound Talisman, and right click to bind yourself
  3. Obtain an Alchemical Algorithms
  4. Place a Transmutation Chamber, and place the talisman and algorithms inside
  5. Hook up a Refined Storage External Storage to the Transmutation Chamber
  6. Put some items into the system, they will show double.
    ...

Version (make sure you are on the latest version before reporting):

  • Minecraft: 1.12.2
  • Forge: 2732
  • Refined Storage: 1.6.4-279

Does this issue occur on a server? yes

commented

I did two big things:

  1. I validated that my update method was tracking the correct values. It was.

  2. I changed my tile entity to pretend not to have the Item Handler capability. When I did that, the numbers in RS suddenly became correct.

The second one was what made me realize that adding an external storage handler was not enough. Am I really expected to not have an Item Handler on the same tile entity? Do I need to create a separate block just for Refined Storage?

commented

No, a external storage handler should be enough. That's the entire reason that API was brought into life.

Number 2 is vital information. Let me check.

commented

Ah, looks like it adds any handler that returns true for canProvide.

Fixing that so we have a priority based system.

https://github.com/raoulvdberge/refinedstorage/blob/mc1.12/src/main/java/com/raoulvdberge/refinedstorage/apiimpl/network/node/NetworkNodeExternalStorage.java#L233-L237

commented

Fixed! Just implement getPriority.

commented

I'm not sure myself, looking at your code. What debugging did you do yourself?