
A situation where construction workers do not request materials from the warehouse
Closed this issue · 8 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.864
Structurize Version
Structurize: 1.20.1-1.0.768-snapshot (or above)
Related Mods and their Versions
No response
Current Behavior
When there are items in my warehouse, builders may not initiate material requests when needed. The root cause lies in the two methods by which the Builder's Hut triggers material requests.
- When a builder accepts a construction task, according to the 《structureStep()》 function in 《com/minecolonies/core/entity/ai/workers/AbstractEntityAIStructure.java》, they must go to the construction site. Based on the 《switch-case》 conditions, they first execute the 《CLEAR》 case (site clearing), during which they request materials once.
- When the builder detects that the Builder's Hut inventory contains the first material of the current type (e.g., blocks count as solids, while signs are classified as a different material type), the 《pickUpMaterial()》 function in 《AbstractEntityAIStructure.java》 is invoked. This function iterates through the required material types and the stored materials in the hut, then requests missing materials for the current type and preloads requests for the next type.
However, there are issues preventing the hut from requesting materials:
First Scenario
If site clearing is unnecessary, the material request code is:
《building.checkOrRequestBucket(building.getRequiredResources(), worker.getCitizenData());》
Here, 《building.getRequiredResources()》 should return all required materials, but its implementation shows:
《return (buckets.isEmpty() || ((AbstractBuildingStructureBuilder) building).getProgress() == null || ((AbstractBuildingStructureBuilder) building).getProgress().getB() == BuildingStructureHandler.Stage.CLEAR) ? null : buckets.getFirst();》
When site clearing is skipped and the first material of the initial type is missing, 《.getProgress()》 returns 《null》 (due to no actionable blocks). This causes the function to return 《null》, failing to request materials.
Second Scenario
If the Builder's Hut inventory completely lacks the first material of the initial type, the 《pickUpMaterial()》 function is never triggered. Consequently, materials cannot be requested through this mechanism.
The combination of these two issues explains why builders may fail to request materials from the warehouse when:
• You assign a construction task on empty land.
• Upgrading buildings that don’t require block removal (e.g., certain non-excavation upgrades).
• Constructing auxiliary huts for large multi-part buildings (e.g., complex structures in the "Old English" style), where sub-huts may also fail to request materials.
I don't know why it must be the first material of the first material type, and I don't want to know because I don't have any project development experience. In order to debug this problem, I studied for two whole days and DUBUG for a day. My experimental results show that when the construction workshop does not have the first material of the first material type, it will not call the pickUpMaterial function. As long as it has at least one, it will call this function normally.
Context for Investigation
I researched this issue because during gameplay, I observed:
- Buildings requiring upgrades without block removal never auto-requested materials if the Builder's Hut lacked the first material of the initial type.
- Auxiliary huts in large multi-building complexes (common in "Old English"-style structures) also exhibited material request failures.
我不知道为什么issue的风格变得这么诡异,为了让中国的开发者了解我的含义,或者让这个issue能看,我在下面写出我提交BUG的中文版本。
当我仓库内有物品,建筑工需要材料时,可能不会发起需要材料的请求。
这里的根源在于,建筑小屋发起材料请求的方式有两种。
1、 当建筑工接受到需要建造这个建筑任务的时候,根据函数
com\minecolonies\core\entity\ai\workers\AbstractEntityAIStructure.java中的
protected IAIState structureStep()
的要求,他必须去施工现场,根据switch,case中的条件,他会首先执行case CLEAR,也就是清理场地,这时他也会请求一次材料。
2、 当建筑工发现建筑工小屋的仓库内拥有当前类型材料(比如方块算固体,告示牌不算固体算另外一种材料)的第一个材料时,会调用
com\minecolonies\core\entity\ai\workers\AbstractEntityAIStructure.java
中的public IAIState pickUpMaterial()函数。
这个函数会遍历当前他需要的材料类型和小屋存储内的材料类型。然后把当前类型缺少的材料发起请求,并把下个类型材料也发起请求,相当于预加载。
但是现在有个问题,会导致小屋不会向仓库请求材料。
1.1首先是第一种情况,如果不需要清理场地,他请求材料的代码是
building.checkOrRequestBucket(building.getRequiredResources(), worker.getCitizenData());
这句话中,building.getRequiredResources()是请求的所有材料清单,但是这个函数内容如下:
return (buckets.isEmpty() || ((AbstractBuildingStructureBuilder) building) .getProgress() == null || ((AbstractBuildingStructureBuilder) building).getProgress().getB() == BuildingStructureHandler.Stage.CLEAR) ? null : buckets.getFirst();
这个函数中,第二个条件.getProgress()由于没有清理场地,加上他缺少第一种材料类型的第一个材料,所以这里不会寻找需要操作的方块,导致这个值为null。根据逻辑这里return的值就是null。导致无法向仓库请求材料。
2.2我们再说第二种情况,当我小屋仓库里面没有(一个都没有)第一种材料类型的第一个材料时,他永远不会触发pickUpMaterial这个函数,也就是说,他不会通过这种方法向仓库请求材料。
这两种情况叠加,就导致当你自己找到一块空地,给小屋发布一个任务的时候,他可能不会向仓库请求材料。
我不知道为什么一定是第一种材料类型的第一个材料,我也不想知道,因为我没有任何项目开发经验,我为了DEBUG这个问题,我整整学习了两天,DUBUG了一天,我的实验结果表明,当建筑工小屋没有第一种材料的第一个材料时他就不会调用pickUpMaterial函数,只要拥有至少1个,他都会正常调用这个函数。
我为什么会研究这个问题,因为我自己在游玩的时候发现,一些不需要挖方块升级的建筑,当我小屋库存里面缺少第一种材料类型的第一个材料时,他永远不回主动请求材料。其次,当我为某个小屋的附属小屋建造时(比如Old English里面很多大建筑带小建筑)他们也有可能不向仓库请求材料。
重现步骤很简单,你只需要新建一个创造存档,建立一个正常的殖民地。然后使用创造的能力直接放置建筑工小屋、仓库、快递员小屋,仓库雇佣快递员、建筑师小屋雇佣建筑工。
然后使用工具随便建造一个新的小屋,你要确保整个小屋不需要清理任何方块杂草或者填补任何方块,我的建议是在一个完全平面上放一个1级的原版风格的快递员小屋,因为他只需要四种类型的一共七个材料。然后设置成需要建筑工建设。然后你把需要的所有材料都放置到仓库(确保建筑需要的材料我的殖民地都存在)。确保建筑工物品栏和建筑工小屋的存储空间内没有任何材料(或者只需要没有建造这个建筑需要的材料,甚至只需要没有第一种类型的第一个材料,我记得1级快递员小屋第一种材料是固体中的橡木台阶).这样你会发现,建筑工去现场勘察后,就会出现红色齿轮告诉你缺少材料,但是不会向仓库请求材料。
Expected Behavior
According to normal logic, in any case, as long as the construction worker's cabin is short of materials, a request should be made to the warehouse, and then the courier should deliver the goods. But the current situation means that no request will be made, let alone delivery.
Reproduction Steps
Reproduction steps are simple: Create a new creative world, establish a normal colony. Use creative mode abilities to directly place a Builder's Hut, Warehouse, and Courier's Hut. Hire a courier for the Warehouse and a builder for the Builder's Hut. Then, use tools to construct a new hut (ensure the hut requires no clearing of blocks/weeds or filling of blocks—I recommend placing a Level 1 vanilla-style Courier's Hut on a completely flat surface, as it only requires 7 materials across 4 types). Assign the construction task to the Builder. Place all required materials into the Warehouse (ensure the colony has all materials needed for the build). Ensure the Builder's inventory and the Builder's Hut storage contain none of the required materials (or at least lack the first material of the first type; for the Level 1 Courier's Hut, I recall the first material is Oak Wood Slabs under the "solid" category). You will observe that after inspecting the site, the Builder displays a red gear icon indicating missing materials but does not request materials from the Warehouse.
Logs
I found the problem with DEBUG, so I don't know how to find this file, but it's easy to reproduce. You can give it a try.
Anything else?
No response
Footer
Viewers
- Add a thumbs-up to the bug report if you are also affected. This helps the bug report become more visible to the team and doesn't clutter the comments.
- Add a comment if you have any insights or background information that isn't already part of the conversation.
I just faced this problem. After reading your explanation, I "solved" it by putting dirt in the construction. 🤡😅
I have had the same issue, however I noticed If I simply clicked or "talked" to the builder they would suddenly order the missing items from the Warehouse. Other times it self resolved after a few "in-game" days if I left him just standing there.
To clarify here, does the builder not request at all and couriers don't deliver at all, or do you mean the builder only requests a single material at a time and not the whole batch?
在这里澄清一下,是建筑商根本没有要求,快递员根本不送货,还是您的意思是建筑商一次只要求一种材料,而不是整批材料?
The builder has no requirements at all.
Because in the first scenario, the builder will make a request when clearing the site, but if the site does not need to be cleared, the build. getRequired Sources () function returns False, which means that materials are needed but the builder does not receive a list of materials and therefore will not make a request.
In the second scenario, if the first block on the list is completely absent from the builder's backpack or block inventory, no request will be made. This is because when the first block in the list exists, the builder will scan the inventory of the builder's block, determine what items are missing, and then make a request. However, due to the complete absence of the first block, he does not scan the inventory at all, that is, he does not know what is missing, resulting in not making a request. This paragraph looks very strange. Although the builder knows what the first block is, they are not clear about the entire list. This may be a bug in the code, you can reproduce it according to the method in the formal content I submitted to understand what I mean.
Method for reproducing the problem: create a new creation archive and establish a normal colony. Then use the creative ability to directly place the builder's cabin, warehouse, and courier's cabin, with the warehouse hiring couriers and the architect's cabin hiring builders. Then use tools to randomly build a new hut. "You need to ensure that the entire hut does not need to clear any block weeds or 'fill' any blocks" (create a building on the ground in a super flat world). My suggestion is to place a Level 1 original style courier hut on a completely flat surface, as it only requires a total of seven materials from four types. Then set it to require construction work. Then you place all the necessary materials in the warehouse (ensuring that the materials needed for the building are available in my colony). Ensure that there are no materials in the storage space of the construction workers' inventory and the construction workers' cabin (or only the materials required for building this building, or even the first type of material, I remember the first type of material for the Level 1 courier cabin is solid oak steps) In this way, you will find that after the construction worker goes to the site for investigation, a red gear will appear to tell you that there is a shortage of materials, but they will not request materials from the warehouse.
To clarify here, does the builder not request at all and couriers don't deliver at all, or do you mean the builder only requests a single material at a time and not the whole batch?
Don't worry yet. I'll record a video to reproduce this situation in the next two days. I'll @ you then.
To clarify here, does the builder not request at all and couriers don't deliver at all, or do you mean the builder only requests a single material at a time and not the whole batch?
Don't worry yet. I'll record a video to reproduce this situation in the next two days. I'll @ you then.
To clarify here, does the builder not request at all and couriers don't deliver at all, or do you mean the builder only requests a single material at a time and not the whole batch?
@Raycoms
I just discovered during testing that this bug has been fixed. The specific situation is as follows:
In versions before 1.20.1-1.1.864, when a builder first detects that a building needs to be constructed, the first state is "CLEAR". If there are no blocks that need to be cleaned, when he calls building. getRequired Sources (), he returns NULL, causing the request to not be initiated.
However, when I first debugged (versions 1.20.1-1.1.876), I found that the "CLEAR" was followed by the "BUILD_Solid" state, which called the code requesting the material during execution. This code was not executed in this way before 1.20.1-1.1.864, so now builders can correctly request materials when building new buildings. Due to the ability to request materials correctly, the associated bug 2 cannot exist anymore, as bug 2 is built upon bug 1.
As for the previous code 1.20.1-1.1.864, due to version updates, I am no longer able to debug (my code file has turned "orange", indicating that DEBUG is invalid)... )Therefore, I am unable to reproduce this bug at the moment. I think this is because you changed some logic while fixing another bug, which now allows the "BUILD_Solid" state to request materials. Therefore, this bug has been fixed. But it did exist, and members of the comment section "bindwkill" and "maxxxwinder" seem to have encountered this problem as well.
Finally, thank you for the update that allowed me to play such an interesting mod. I hope this mod continues to improve.