Thaumcraft: Golem Batch Guard
A Minecraft 1.7.10 Forge addon that lets Thaumcraft golems retry rejected item placement with smaller carried-stack batches while preserving the carried remainder.
Features
- Golem Stack Preservation: Keeps the uninserted part of a golem's carried stack instead of requiring the target inventory to accept or reject the whole stack.
- Smaller Batch Retry: When a full carried stack is rejected unchanged, retries copied stacks to find a safe smaller insertion amount.
- Thaumcraft AI Patch: Targets Thaumcraft golem item-placement AI instead of changing target inventories.
- All Inventory Targets: Works through Thaumcraft's normal
IInventory insertion path, not only HQM Quest Delivery Systems.
- QDS Compatibility: Explicitly supports
hqm-dontvoidmyitems all-or-nothing QDS item validation behavior.
- Scoped Behavior: Leaves golem carry limits, movement, marker colors, sorting checks, home checks, and inventory open/close behavior under Thaumcraft's normal control.
- Configurable Guard: Provides a generated Forge config for enabling the guard, setting the minimum batch size, and optional debug logging.
Coremod Approach
This mod uses a small coremod patch because Thaumcraft golem insertion behavior is implemented inside Thaumcraft's golem AI classes.
- Late Mixin Loading: Registers the mixins as late UniMixins mixins so Thaumcraft classes are available before the targets are prepared.
- AI Placement Redirects: Redirects Thaumcraft calls to
InventoryUtils.placeItemStackIntoInventory(...) in AIHomePlace, AIEmptyPlace, AISortingPlace, and AIHomeReplace.
- Source Filter Redirects: Redirects
GolemHelper.getContainersWithRoom(...) simulations so golems can pick up a larger source stack when only a smaller batch is currently insertable at the destination.
- Original Helper Reuse: The guarded hook calls Thaumcraft's original inventory helper internally with copied stacks.
- Simulation and Insertion Coverage: Redirects both simulated checks and real insertions so golems can choose a target and then insert the same accepted batch size safely.
- Scoped Patch: The patch is limited to Thaumcraft golem item placement into inventories; item pickup, extraction, fluids, essentia, and HQM internals are not changed.
- Compatibility Target: Built against Minecraft
1.7.10, Forge 10.13.4.1614, UniMixins 0.3.0, and Thaumcraft 4.2.3.5.
Golem Batch Insertion
Thaumcraft's original insertion is always attempted first. If the target accepts the full carried stack, behavior is unchanged.
If the full stack is rejected unchanged, the guard searches for a smaller fully accepted batch:
- A copied stack is offered to the target inventory.
- Binary search finds the largest fully accepted batch at or above the configured minimum.
- If no batch is found, a single-item offer is tried as a final fallback.
- Real insertion uses the accepted batch size.
- The hook returns a copied carried remainder, or
null when the whole carried stack has been inserted.
For example, if a golem carries 8 items and a guarded QDS can safely accept only 2, the golem inserts 2 and keeps 6 carried. If the target accepts none of the item, the golem keeps the full carried stack.
This also applies before pickup for sorting-style flows. If a QDS is at 46/50 stone and the source inventory contains 10 stone, the golem can still take the stack because the destination simulation sees that 4 can be accepted. The placement step then inserts 4 and preserves the remaining 6 for normal Thaumcraft handling.
The generated config contains:
enableBatchGuard=true
minBatchSize=1
debugLogging=false
Limits
- The mod depends on Thaumcraft's original
InventoryUtils.placeItemStackIntoInventory(...) return contract.
- The guard only runs at redirected Thaumcraft golem AI call sites.
- Inventories that report successful insertion but internally discard items cannot be repaired by this addon.
hqm-dontvoidmyitems is optional, but QDS overfill protection still depends on that addon rejecting unsafe oversized QDS item stacks.
- Manual in-pack testing is still recommended for automation-heavy modpacks because inventories can implement insertion rules differently.