Skip to content

Fix cloned mob item dupe - #122

Merged
Nikolay-Sitnikov merged 8 commits into
masterfrom
fix/pack-mule-clone-dupe
Sep 7, 2026
Merged

Fix cloned mob item dupe#122
Nikolay-Sitnikov merged 8 commits into
masterfrom
fix/pack-mule-clone-dupe

Conversation

@Eldrinn-Elantey

@Eldrinn-Elantey Eldrinn-Elantey commented May 15, 2026

Copy link
Copy Markdown

Taking a blood sample copied the mob's full NBT, including its inventory, so cloning the mob duplicated any carried items. Nesting jarred pack mules inside each other made the duping exponential. A blood sample should carry only genetic data, so it no longer keeps the mob's inventory.

Closes https://github.com/GTNewHorizons/Dupes-Exploits-GTNH/issues/231

Cloning a mob with an inventory (e.g. pack mule) copied its full NBT including items, allowing item duplication. Fixed by clearing all inventory slots after createEntityFromNBT.

@tiffit tiffit left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

small nit, looks good otherwise

Comment thread src/main/java/com/kentington/thaumichorizons/common/tiles/TileVat.java Outdated
@Nikolay-Sitnikov

Copy link
Copy Markdown

Have we verified that this actually works? EntityHorse implements IInvBasic, not IInventory.

Also, even if this did work, this triggers every time the vat ticks, not when the vat duplicates an entity, so if I take my already-existing mule and put it in the vat, its inventory would get voided immediately, even though I didn't duplicate any items.

…Vat.java

Co-authored-by: tiffit <10173431+tiffit@users.noreply.github.com>
@Eldrinn-Elantey

Eldrinn-Elantey commented May 15, 2026

Copy link
Copy Markdown
Author

Good catch on IInvBasic. Fixed by stripping inventory-related NBT keys (Items, ArmorItem, SaddleItem) from a copy of the critter compound before passing it to createEntityFromNBT, so it covers all entity types regardless of which inventory interface they implement.

On the second point - the clearing only happens inside the if (getEntityContained() == null) block, so it only runs when the entity is being created from the blood sample, not on every tick while an existing entity sits in the vat.

@Viptunbeqwfwew

Copy link
Copy Markdown

Why not delete it directly from ItemStringEmpty? It would be more logical there.

@Eldrinn-Elantey

Copy link
Copy Markdown
Author

The blood sample item intentionally stores the full mob NBT (it's used for aspect display and other lookups). Stripping inventory keys at storage time would lose data that may be needed elsewhere. Cleaning up only at clone time in TileVat keeps the sample intact and targets exactly the problem - items being duplicated on entity creation.

@Eldrinn-Elantey

Copy link
Copy Markdown
Author

Actually, looking at ItemSyringeBloodSample more carefully - it only reads critterName and CreatureInfusion from the critter NBT, so stripping inventory keys at sample creation time would be fine too. Both approaches work; the question is where the responsibility sits. Cleaning in TileVat keeps the item layer untouched and makes the fix explicit at the point of entity creation. Cleaning in ItemSyringeBloodSample puts it closer to the data source and prevents the dirty NBT from ever being stored. What do you think is the better place?

@Viptunbeqwfwew

Copy link
Copy Markdown

It depends on the responsibility. But I'm leaning toward ItemSyringeBloodSample. After all, logically, data like items shouldn't be contained in a blood sample. It should only contain the mob type itself and its "genetic" (individual) parameters.

And it's simply not sensible to store unused data.

@Viptunbeqwfwew

Copy link
Copy Markdown

The "ChestedHorse" tag still needs to be removed, otherwise you'll clone a dressed chest on a donkey.

@Eldrinn-Elantey

Copy link
Copy Markdown
Author

Good catch, added ChestedHorse to the strip list.

@Eldrinn-Elantey

Copy link
Copy Markdown
Author

Agreed, moved the stripping to ItemSyringeEmpty at sample creation time. A blood sample shouldn't carry inventory data at all.

Cloning a mob via blood sample copied its full NBT including carried items, allowing item duplication. Fixed by stripping Items, ArmorItem, SaddleItem and ChestedHorse from the critter tag in ItemSyringeEmpty when the sample is taken - a blood sample should only carry genetic data.
@Eldrinn-Elantey
Eldrinn-Elantey requested a review from tiffit May 15, 2026 13:15
@Eldrinn-Elantey Eldrinn-Elantey changed the title Clear cloned entity inventory on creation Fix cloned mob item dupe Jul 6, 2026
@Nikolay-Sitnikov Nikolay-Sitnikov self-assigned this Aug 30, 2026

@Nikolay-Sitnikov Nikolay-Sitnikov left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should work for now. This isn't a particularly good check, because we can never really know where a mod might store its items in its NBT, but this should work for Luggage & Mules.

@Nikolay-Sitnikov
Nikolay-Sitnikov enabled auto-merge (squash) September 7, 2026 19:30
@Nikolay-Sitnikov
Nikolay-Sitnikov merged commit f42bcf2 into master Sep 7, 2026
1 check passed
@Nikolay-Sitnikov
Nikolay-Sitnikov deleted the fix/pack-mule-clone-dupe branch September 7, 2026 19:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants