Easy Villagers

Easy Villagers

36M Downloads

"Inaccurate extraction" with Refined Storage 2

Closed this issue · 4 comments

commented

Bug description

When trying to extract certain items (villager-related items) from Refined Storage 2, the extraction silently fails and Refined Storage shows the warning "inaccurate extraction". Items can be inserted into the storage system, but extracting them back does not work correctly.

This is caused by the way items with custom data components are handled. Refined Storage 2 explains this issue here:
https://refinedmods.com/refined-storage/troubleshooting/inaccurate-extraction.html

Minecraft version

1.21.1

Mod version

1.21.1-1.1.35

Mod loader and version

NeoForge 21.1.203

Steps to reproduce

  1. Place an item from Easy Villagers (e.g., a captured villager or trader) into Refined Storage 2.
  2. Try to extract the item back into the player inventory.
  3. Refined Storage shows "inaccurate extraction" and fails to extract the item.

Expected behavior

The item should be extracted correctly without errors, just like vanilla items.

Log files

https://gist.github.com/jerem2772/2bf1f6c648fa9cec7dd371230c10d2d3

Screenshots

No response

commented

The villager data components are using equals and hash code:

@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
VillagerData villager1 = (VillagerData) o;
return Objects.equals(nbt, villager1.nbt);
}
@Override
public int hashCode() {
return Objects.hashCode(nbt);
}

Not 100% sure if keeping a weak reference cache inside it could cause the issue though:

private WeakReference<EasyVillagerEntity> villager = new WeakReference<>(null);

commented

It looks like the issue doesn’t come from the weak reference. The Villager item stores the entire villager NBT as its data component, and this NBT changes frequently (age, timers, offers, brain data, etc.), which makes equality unstable for Refined Storage 2.

Would it be possible to reduce the stored NBT to only the identity-relevant fields and remove volatile information, so the data component stays stable for RS2?

commented

All information in there is needed to retain the information of the contained entity. It also does not update when in item form.

commented

Closed due to inactivity.