mirror of
https://github.com/GTNewHorizons/AE2FluidCraft-Rework.git
synced 2026-11-11 15:57:55 +00:00
Add pattern doubling to ae2fc terminals (#148)
* Brings pattern doubling to ae2fc pattern terms Literally copied and pasted the code over * Update dep
This commit is contained in:
1 parent
3df15eae97
commit
3fce70a406
2 files changed
+34
-8
No files matched your search
+33
-7
@@ -523,14 +523,40 @@ public abstract class FCContainerEncodeTerminal extends ContainerItemMonitor
|
||||
return false;
|
||||
}
|
||||
|
||||
static boolean canDouble(SlotFake[] slots, int mult) {
|
||||
for (Slot s : slots) {
|
||||
if (s.getStack() != null) {
|
||||
long result = (long) s.getStack().stackSize * mult;
|
||||
if (result > Integer.MAX_VALUE) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static void doubleStacksInternal(SlotFake[] slots, int mult) {
|
||||
List<SlotFake> enabledSlots = Arrays.stream(slots).filter(SlotFake::isEnabled).collect(Collectors.toList());
|
||||
for (final Slot s : enabledSlots) {
|
||||
ItemStack st = s.getStack();
|
||||
if (st != null) {
|
||||
st.stackSize *= mult;
|
||||
s.putStack(st);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void doubleStacks(boolean isShift) {
|
||||
if (canDoubleStacks(craftingSlots) && canDoubleStacks(outputSlots)) {
|
||||
doubleStacksInternal(this.craftingSlots);
|
||||
doubleStacksInternal(this.outputSlots);
|
||||
if (isShift && (containsItem(outputSlots) || containsItem(craftingSlots))) {
|
||||
while (canDoubleStacks(craftingSlots) && canDoubleStacks(outputSlots)) {
|
||||
doubleStacksInternal(this.craftingSlots);
|
||||
doubleStacksInternal(this.outputSlots);
|
||||
if (!isCraftingMode()) {
|
||||
if (isShift) {
|
||||
if (canDouble(this.craftingSlots, 8) && canDouble(this.outputSlots, 8)) {
|
||||
doubleStacksInternal(this.craftingSlots, 8);
|
||||
doubleStacksInternal(this.outputSlots, 8);
|
||||
}
|
||||
} else {
|
||||
if (canDouble(this.craftingSlots, 2) && canDouble(this.outputSlots, 2)) {
|
||||
doubleStacksInternal(this.craftingSlots, 2);
|
||||
doubleStacksInternal(this.outputSlots, 2);
|
||||
}
|
||||
}
|
||||
this.detectAndSendChanges();
|
||||
|
||||
Reference in new issue
Block a user