-
-
Notifications
You must be signed in to change notification settings - Fork 367
Fix unnecessary item handler invalidation #10677
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: version/1.21
Are you sure you want to change the base?
Conversation
src/main/java/com/minecolonies/core/colony/buildings/AbstractBuildingContainer.java
Outdated
Show resolved
Hide resolved
… into fix/item_handler_cap_recreation
Forgive me if this is not helpful, I am not super familiar with this codebase, and I am probably doing close to the most unsupported thing (Trying to fix a bug in the infamous Compatibility addon for Minecolonies), but I digress. I am running a local compiled version of this patch, backported to TileEntityColinyBuildingif (combinedInv == null)
{
final List<IItemHandlerModifiable> handlers = new ArrayList<>();
final Set<BlockPos> newPositions = new HashSet<>();
final Level world = colony.getWorld();
for (final BlockPos pos : building.getContainers())
{
if (WorldUtil.isBlockLoaded(world, pos) && !pos.equals(this.worldPosition))
{
final BlockEntity te = world.getBlockEntity(pos);
if (te != null)
{
if (te instanceof final AbstractTileEntityRack rack)
{
handlers.add(rack.getInventory());
newPositions.add(pos);
}
}
}
}
+ handlers.add(this.getInventory());
+ newPositions.add(this.getPosition());
combinedInv = LazyOptional.of(() -> new CombinedItemHandler(handlers));
currentInvPositions = newPositions; seemed to fix that. I don't know if this is the best option but thought it might be of help. |
We actually went about this the wrong way a bit, we should change it to add an invalidatin listener to a rack, which when a rack becomes unavailable triggers the reset/invalidation of the combined inventory capability and that way forces a new one to be created |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just blind-shot: could we use/copy/extend https://github.com/neoforged/NeoForge/blob/c01798ea3a4a17e8b1c5bf917444e9990d3b85c3/src/main/java/net/neoforged/neoforge/items/wrapper/CombinedInvWrapper.java
Closes #10671
Closes #10670
Changes proposed in this pull request
Testing
Review please