Open ZurrTum opened 2 weeks ago
I rewrote the UI selection method, let me know if you need it
// RebornCore/src/main/java/reborncore/common/blockentity/SlotConfiguration.java
private void handleItemIO(MachineBaseBlockEntity machineBase) {
if (!input && !output) {
return;
}
if (first != null) {
handleItemSideIo(machineBase, sideMap.get(first));
}
sideMap.forEach((key, config) -> {
if (key == first || key == last) return;
handleItemSideIo(machineBase, config);
});
if (last != null) {
handleItemSideIo(machineBase, sideMap.get(last));
}
}
private void handleItemSideIo(MachineBaseBlockEntity machineBase, SlotConfig config) {
switch (config.getSlotIO().getIoConfig()) {
case INPUT -> {
if (input) config.handleItemInput(machineBase);
}
case OUTPUT -> {
if (output) config.handleItemOutput(machineBase);
}
}
}
what is it:
What is the output order? 🤣
Why is it needed?
I need to sort the items using storage units, but looking at the TechReborn code I see that the slot output is handled via a HashMap and the order changes every time I launch the game.
If there is a better way please tell me
View Source Code:
Use the minecraft Direction when creating: https://github.com/TechReborn/TechReborn/blob/a793dc92cbaae39ab6a68cac61acb3d9c185b97e/RebornCore/src/main/java/reborncore/common/blockentity/SlotConfiguration.java#L169-L173
But HashMap uses the hashCode function return value of the minecraft Direction object, which will change, resulting in inconsistent ordering. https://github.com/TechReborn/TechReborn/blob/a793dc92cbaae39ab6a68cac61acb3d9c185b97e/RebornCore/src/main/java/reborncore/common/blockentity/SlotConfiguration.java#L192-L215
Diff:
I fixed the output order to the order of minecraft Direction Enum through my own local modification.