Builder doesn't support placement handler which require more than one item
MotionlessTrain opened this issue · 0 comments
Is there an existing issue for this?
- I have searched the existing issues.
Are you using the latest MineColonies Version?
- I am running the latest beta/release version of MineColonies for my Minecraft version.
I am also running the latest versions of other mods that are part of my problem.
Did you check on the Wiki? or ask on Discord?
- I checked the MineColonies Wiki and made sure my issue is not covered there. Or I was sent from discord to open an issue here.
What were you playing at the time? Were you able to reproduce it in both settings?
- Single Player
- Multi Player
Minecraft Version
1.20
MineColonies Version
1.1.1155
Structurize Version
1.0.786
Related Mods and their Versions
CreateColonies 2.0.0-beta.8 (though not released yet)
But is likely a bug on the 1.20 version as well, from peeking in the code (that would be CreateColonies 1.0.0)
Create 6.0.6 (as dependency of CreateColonies)
Current Behavior
Whenever the builder places down a block or item that requires multiple of the same item, only one of that item is consumed
Expected Behavior
I would expect that multiple are consumed
Reproduction Steps
I'm not sure whether there are vanilla + minecolonies + dependencies items which could trigger this, but I managed to trigger it with a few blocks with CreateColonies
One of the easiest to set up is a chain conveyor. Two of them are connected with a chain, and the amounts of chains consumed are proportional to the distance between the blocks. I placed two of them something like 13 blocks apart, and needed 6 chains, and scanned those, to let a builder build that again.
The placement handler I wrote for it also requires that amount of chains
Letting it build by the builder only consumes one chain, and the other 5 are lingering in the builder's inventory or the builder's hut inventory
Logs
https://gist.github.com/MotionlessTrain/76f21d8b14c771ea1aab84fc5803fc73
Anything else?
I found the culprit in the code (which is how I suspect 1.20.1 has the same issue, as I found the same code there)
In BuilderStructureHandler, InventoryUtils.reduceBucketAwareStackInItemHandler is called, with two parameters: The citizen's inventory and the stack to be consumed:
This version of the function delegates to the one with a separate count argument, with a count of 1. So only one is consumed:
minecolonies/src/main/java/com/minecolonies/api/util/InventoryUtils.java
Lines 2913 to 2917 in 90ac51d
And so there is only one consumed
I suspect that the BuildingStructureHandler needs to call the three-parameter version instead, and set the item stack count as third parameter
Footer
Viewers
- Add a 👍 reaction to the bug report if you are also affected. This helps the bug report become more visible without cluttering the comments.
⚠️ Only add a comment if you have new insights or background information not already mentioned. Off-topic or "+1" comments will be deleted to keep the discussion focused.