pattern terminal add auto fill blank pattern

This commit is contained in:
asdflj committed 2023-02-17 12:04:11 +08:00
1 parent 271917c765
commit 09c1c49529
11 files changed
+122 -3

No files matched your search

@@ -57,6 +57,8 @@ public class GuiFCImgButton extends GuiButton implements ITooltip {
this.registerApp(13, "ESSENTIA_TEM", "YES", "essentia_terminal_w");
this.registerApp(14, "INTERFACE_TEM", "YES", "interface_terminal_w");
this.registerApp(15, "PATTERN_EX_TEM", "YES", "pattern_terminal_ex_w");
this.registerApp(16, "FILL_PATTERN", "DO_FILL", "fill_pattern");
this.registerApp(17, "NOT_FILL_PATTERN", "DONT_FILL", "not_fill_pattern");
}
}
@@ -51,6 +51,8 @@ public abstract class FCGuiEncodeTerminal extends GuiItemMonitor {
protected GuiImgButton beSubstitutionsDisabledBtn;
protected GuiFCImgButton combineEnableBtn;
protected GuiFCImgButton combineDisableBtn;
protected GuiFCImgButton autoFillPatternEnableBtn;
protected GuiFCImgButton autoFillPatternDisableBtn;
protected final GuiScrollbar processingScrollBar = new GuiScrollbar();
protected final AppEngRenderItem stackSizeRenderer = Ae2ReflectClient.getStackSizeRenderer(this);
@@ -62,6 +64,24 @@ public abstract class FCGuiEncodeTerminal extends GuiItemMonitor {
setReservedSpace(81);
}
@Override
public void initGui() {
super.initGui();
this.buttonList.add(
this.autoFillPatternEnableBtn = new GuiFCImgButton(
this.guiLeft - 18,
this.offsetY,
"FILL_PATTERN",
"DO_FILL"));
this.buttonList.add(
this.autoFillPatternDisableBtn = new GuiFCImgButton(
this.guiLeft - 18,
this.offsetY,
"NOT_FILL_PATTERN",
"DONT_FILL"));
this.offsetY += 20;
}
@Override
protected void actionPerformed(final GuiButton btn) {
super.actionPerformed(btn);
@@ -108,6 +128,11 @@ public abstract class FCGuiEncodeTerminal extends GuiItemMonitor {
} else if (ModAndClassUtil.isBeSubstitutionsButton && beSubstitutionsEnabledBtn == btn) {
FluidCraft.proxy.netHandler
.sendToServer(new CPacketFluidPatternTermBtns("PatternTerminal.beSubstitute", "0"));
} else if (this.autoFillPatternDisableBtn == btn || this.autoFillPatternEnableBtn == btn) {
FluidCraft.proxy.netHandler.sendToServer(
new CPacketFluidPatternTermBtns(
"PatternTerminal.AutoFillerPattern",
this.autoFillPatternDisableBtn == btn ? "1" : "0"));
}
}
@@ -124,6 +149,8 @@ public abstract class FCGuiEncodeTerminal extends GuiItemMonitor {
updateButton(this.beSubstitutionsDisabledBtn, !this.container.beSubstitute);
updateButton(this.fluidPrioritizedEnabledBtn, this.container.prioritize);
updateButton(this.fluidPrioritizedDisabledBtn, !this.container.prioritize);
updateButton(this.autoFillPatternEnableBtn, this.container.autoFillPattern);
updateButton(this.autoFillPatternDisableBtn, !this.container.autoFillPattern);
super.drawFG(offsetX, offsetY, mouseX, mouseY);
}
@@ -18,6 +18,7 @@ import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.IFluidContainerItem;
import appeng.api.AEApi;
import appeng.api.config.Actionable;
import appeng.api.definitions.IDefinitions;
import appeng.api.storage.ITerminalHost;
import appeng.api.storage.data.IAEItemStack;
@@ -75,6 +76,9 @@ public abstract class FCContainerEncodeTerminal extends ContainerItemMonitor
@GuiSync(91)
public boolean prioritize = false;
@GuiSync(90)
public boolean autoFillPattern = false;
public FCContainerEncodeTerminal(final InventoryPlayer ip, final ITerminalHost monitorable) {
super(ip, monitorable);
this.patternTerminal = (IItemPatternTerminal) monitorable;
@@ -302,6 +306,7 @@ public abstract class FCContainerEncodeTerminal extends ContainerItemMonitor
}
this.patternSlotOUT.putStack(null);
}
fillPattern();
}
public void encodeAllItemAndMoveToInventory() {
@@ -315,9 +320,40 @@ public abstract class FCContainerEncodeTerminal extends ContainerItemMonitor
this.patternSlotOUT.putStack(null);
this.patternSlotIN.putStack(null);
}
fillPattern();
}
private void fillPattern() {
if (this.autoFillPattern && this.getHost().getItemInventory() != null) {
// try to use me network item to fill pattern input slot
final IDefinitions definitions = AEApi.instance().definitions();
int fillStackSize = this.patternSlotIN.getHasStack() ? 64 - this.patternSlotIN.getStack().stackSize : 64;
if (fillStackSize == 0) return;
for (ItemStack blankPattern : definitions.materials().blankPattern().maybeStack(fillStackSize).asSet()) {
IAEItemStack iBlankPattern = AEApi.instance().storage().createItemStack(blankPattern);
if (this.patternSlotIN.getHasStack() && !iBlankPattern.isSameType(this.patternSlotIN.getStack()))
continue;
IAEItemStack out = this.getHost().getItemInventory()
.extractItems(iBlankPattern, Actionable.SIMULATE, this.getActionSource());
if (out != null) {
this.getHost().getItemInventory()
.extractItems(iBlankPattern, Actionable.MODULATE, this.getActionSource());
ItemStack outPattern;
if (this.patternSlotIN.getHasStack()) {
outPattern = this.patternSlotIN.getStack().copy();
outPattern.stackSize += out.getItemStack().stackSize;
} else {
outPattern = out.getItemStack();
}
this.patternSlotIN.putStack(outPattern);
return;
}
}
}
}
public void encode() {
fillPattern();
if (!checkHasFluidPattern()) {
encodeItemPattern();
return;
@@ -454,6 +490,7 @@ public abstract class FCContainerEncodeTerminal extends ContainerItemMonitor
this.combine = this.patternTerminal.shouldCombine();
this.beSubstitute = this.patternTerminal.canBeSubstitute();
this.prioritize = this.patternTerminal.isPrioritize();
this.autoFillPattern = this.patternTerminal.isAutoFillPattern();
}
}
@@ -25,6 +25,7 @@ public abstract class FCFluidEncodeTerminal extends FCPart implements IItemPatte
protected boolean prioritize = false;
protected boolean inverted = false;
protected boolean beSubstitute = false;
protected boolean autoFillPattern = false;
protected int activePage = 0;
public FCFluidEncodeTerminal(ItemStack is) {
@@ -51,6 +52,7 @@ public abstract class FCFluidEncodeTerminal extends FCPart implements IItemPatte
this.setPrioritization(data.getBoolean("priorization"));
this.setInverted(data.getBoolean("inverted"));
this.setActivePage(data.getInteger("activePage"));
this.setAutoFillPattern(data.getBoolean("autoFillPattern"));
this.pattern.readFromNBT(data, "pattern");
this.output.readFromNBT(data, "outputList");
this.crafting.readFromNBT(data, "craftingGrid");
@@ -66,6 +68,7 @@ public abstract class FCFluidEncodeTerminal extends FCPart implements IItemPatte
data.setBoolean("substitute", this.substitute);
data.setBoolean("inverted", this.inverted);
data.setInteger("activePage", this.activePage);
data.setBoolean("autoFillPattern", this.autoFillPattern);
this.pattern.writeToNBT(data, "pattern");
this.output.writeToNBT(data, "outputList");
this.crafting.writeToNBT(data, "craftingGrid");
@@ -204,4 +207,14 @@ public abstract class FCFluidEncodeTerminal extends FCPart implements IItemPatte
}
saveChanges();
}
@Override
public boolean isAutoFillPattern() {
return this.autoFillPattern;
}
@Override
public void setAutoFillPattern(boolean canFill) {
this.autoFillPattern = canFill;
}
}
@@ -35,4 +35,8 @@ public interface IItemPatternTerminal extends IItemTerminal {
boolean isCraftingRecipe();
void sortCraftingItems();
boolean isAutoFillPattern();
void setAutoFillPattern(boolean canFill);
}
@@ -56,6 +56,7 @@ public class WirelessPatternTerminalExInventory extends MEMonitorHandler<IAEItem
protected boolean prioritize = false;
protected boolean inverted = false;
protected boolean beSubstitute = false;
protected boolean autoFillPattern = false;
protected int activePage = 0;
@SuppressWarnings("unchecked")
@@ -111,6 +112,7 @@ public class WirelessPatternTerminalExInventory extends MEMonitorHandler<IAEItem
this.setPrioritization(data.getBoolean("priorization"));
this.setInverted(data.getBoolean("inverted"));
this.setActivePage(data.getInteger("activePage"));
this.setAutoFillPattern(data.getBoolean("autoFillPattern"));
}
public void writeToNBT() {
@@ -121,6 +123,7 @@ public class WirelessPatternTerminalExInventory extends MEMonitorHandler<IAEItem
data.setBoolean("priorization", this.prioritize);
data.setBoolean("inverted", this.inverted);
data.setInteger("activePage", this.activePage);
data.setBoolean("autoFillPattern", this.autoFillPattern);
}
@Override
@@ -396,6 +399,16 @@ public class WirelessPatternTerminalExInventory extends MEMonitorHandler<IAEItem
saveChanges();
}
@Override
public boolean isAutoFillPattern() {
return this.autoFillPattern;
}
@Override
public void setAutoFillPattern(boolean canFill) {
this.autoFillPattern = canFill;
}
@Override
public void saveSettings() {
this.writeToNBT();
@@ -56,6 +56,7 @@ public class WirelessPatternTerminalInventory extends MEMonitorHandler<IAEItemSt
protected boolean prioritize = false;
protected boolean inverted = false;
protected boolean beSubstitute = false;
protected boolean autoFillPattern = false;
protected int activePage = 0;
@SuppressWarnings("unchecked")
@@ -110,6 +111,7 @@ public class WirelessPatternTerminalInventory extends MEMonitorHandler<IAEItemSt
this.setCombineMode(data.getBoolean("combine"));
this.setBeSubstitute(data.getBoolean("beSubstitute"));
this.setActivePage(data.getInteger("activePage"));
this.setAutoFillPattern(data.getBoolean("autoFillPattern"));
}
public void writeToNBT() {
@@ -119,6 +121,7 @@ public class WirelessPatternTerminalInventory extends MEMonitorHandler<IAEItemSt
data.setBoolean("combine", this.combine);
data.setBoolean("beSubstitute", this.beSubstitute);
data.setInteger("activePage", this.activePage);
data.setBoolean("autoFillPattern", this.autoFillPattern);
}
@Override
@@ -368,6 +371,16 @@ public class WirelessPatternTerminalInventory extends MEMonitorHandler<IAEItemSt
saveChanges();
}
@Override
public boolean isAutoFillPattern() {
return this.autoFillPattern;
}
@Override
public void setAutoFillPattern(boolean canFill) {
this.autoFillPattern = canFill;
}
@Override
public void saveSettings() {
this.writeToNBT();
@@ -116,6 +116,9 @@ public class CPacketFluidPatternTermBtns implements IMessage {
break;
}
break;
case "PatternTerminal.AutoFillerPattern":
cpt.getPatternTerminal().setAutoFillPattern(Value.equals("1"));
break;
}
cpt.getPatternTerminal().saveSettings();
} else if (Name.equals("Terminal.Cpu") && c instanceof ContainerFluidCraftConfirm) {