< x % trigger not working with TiCon Smeltery Controller
Silwing opened this issue ยท 4 comments
I'm playing Regrowth 0.8.3 with Buildcraft 7.1.12 and trying to automate the TiCon smeltery.
What I want is to insert ores into the controller with Buildcraft pipes. In order to prevent overflow I am trying to use a Golden Gate with the < 50% trigger to send a signal for more resources. The problem I'm seeing is that the trigger will be active until the smeltery is completely full, not until it is 50% full. I have attached 4 screenshots showing off the Smeltery filled with blocks, not activating the trigger and the Smeltery with 1 block missing which will then activate the trigger.
My thought is that the gate trigger might not detect that each slot in the Smeltery can only contain 1 item, so with 18 slots available (as in the screenshot) it thinks there is space for 18 stacks of copper, detecting only 17 copper is clearly less than 50% of 18 stacks. However it does detect when the smeltery reports no more space for anything.
I'm not sure whether this is a TiCon specific problem or it might be general for all containers with space for less than a stack in each slot.
Just found that the < 25% trigger does not work properly with JABBA Barrels either. I have a barrel with 40 stacks of copper ore with space for 128 stacks. This barrel has the <25% trigger active even though 40 stacks is more than 25% of 128 stacks.
I looked a little into the code and the problem for the Smeltery at least seems to be this calculation (which is in the TriggerInventoryLevel.java line 92):
float percentage = foundItems / ((float) stackSpace * (float) searchStack.getMaxStackSize());
The calculation assumes that every slot it finds which is compatible with the searchStack also has a max stack size that is the same as the maxStackSize of the searchStack. For the Smeltery that is not the case. I'm not enough into modding that I know whether it is possible to somehow get the MaxStackSize for an inventory slot. If so the stackSpace variable should count the actual space for items instead of counting the number of stacks with available space.
the problem is that sadly it is impossible to know the max stacksize of a slot, we can only get it from the stack, not the slot that is holding the stack :/