Skip to content

Commit

Permalink
Merge pull request #88 from asdflj/master
Browse files Browse the repository at this point in the history
pattern terminal add auto fill blank pattern
  • Loading branch information
Dream-Master authored Feb 18, 2023
2 parents 271917c + c21752b commit 1a7acf4
Show file tree
Hide file tree
Showing 35 changed files with 419 additions and 50 deletions.
2 changes: 1 addition & 1 deletion dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ dependencies {
compileOnly('com.github.GTNewHorizons:GTplusplus:1.7.191:dev') { transitive = false }

compileOnly('com.github.GTNewHorizons:KekzTech:0.6.25:dev')
runtimeOnly('com.github.GTNewHorizons:Baubles:1.0.1.14:dev')
compile('com.github.GTNewHorizons:Baubles:1.0.1.14:dev')
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ public GuiFCImgButton(final int x, final int y, final String idx, final String v
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");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,23 @@

import net.minecraft.entity.player.InventoryPlayer;

import appeng.container.slot.AppEngSlot;
import appeng.container.slot.SlotDisabled;

import com.glodblock.github.inventory.item.IWirelessTerminal;

public class GuiFluidPatternExWireless extends GuiFluidPatternTerminalEx {

public GuiFluidPatternExWireless(InventoryPlayer inventoryPlayer, IWirelessTerminal te) {
super(inventoryPlayer, te);
}

@Override
protected void repositionSlot(final AppEngSlot s) {
if (s instanceof SlotDisabled || s.isPlayerSide()) {
s.yDisplayPosition = s.getY() + this.ySize - 78 - 5;
} else {
s.yDisplayPosition = s.getY() + this.ySize - 78 - 3;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

import com.glodblock.github.client.gui.base.FCGuiEncodeTerminal;
import com.glodblock.github.client.gui.container.ContainerFluidPatternTerminal;
import com.glodblock.github.client.gui.container.ContainerFluidPatternWireless;
import com.glodblock.github.inventory.item.IWirelessTerminal;
import com.glodblock.github.util.ModAndClassUtil;
import com.glodblock.github.util.NameConst;

Expand All @@ -29,6 +31,10 @@ public GuiFluidPatternTerminal(final InventoryPlayer inventoryPlayer, final ITer
super(inventoryPlayer, te, new ContainerFluidPatternTerminal(inventoryPlayer, te));
}

public GuiFluidPatternTerminal(final InventoryPlayer inventoryPlayer, final IWirelessTerminal te) {
super(inventoryPlayer, te, new ContainerFluidPatternWireless(inventoryPlayer, te));
}

@Override
@SuppressWarnings("unchecked")
public void initGui() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@

import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.base.FCGuiEncodeTerminal;
import com.glodblock.github.client.gui.container.ContainerFluidPatternExWireless;
import com.glodblock.github.client.gui.container.ContainerFluidPatternTerminalEx;
import com.glodblock.github.inventory.item.IWirelessTerminal;
import com.glodblock.github.network.CPacketFluidPatternTermBtns;
import com.glodblock.github.util.ModAndClassUtil;
import com.glodblock.github.util.NameConst;
Expand All @@ -24,6 +26,12 @@ public GuiFluidPatternTerminalEx(final InventoryPlayer inventoryPlayer, final IT
processingScrollBar.setTexture(FluidCraft.MODID, "gui/pattern3.png", 242, 0);
}

public GuiFluidPatternTerminalEx(final InventoryPlayer inventoryPlayer, final IWirelessTerminal te) {
super(inventoryPlayer, te, new ContainerFluidPatternExWireless(inventoryPlayer, te));
processingScrollBar.setHeight(70).setWidth(7).setLeft(6).setRange(0, 1, 1);
processingScrollBar.setTexture(FluidCraft.MODID, "gui/pattern3.png", 242, 0);
}

@Override
@SuppressWarnings("unchecked")
public void initGui() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,23 @@

import net.minecraft.entity.player.InventoryPlayer;

import appeng.container.slot.AppEngSlot;
import appeng.container.slot.SlotDisabled;

import com.glodblock.github.inventory.item.IWirelessTerminal;

public class GuiFluidPatternWireless extends GuiFluidPatternTerminal {

public GuiFluidPatternWireless(InventoryPlayer inventoryPlayer, IWirelessTerminal te) {
super(inventoryPlayer, te);
}

@Override
protected void repositionSlot(final AppEngSlot s) {
if (s instanceof SlotDisabled || s.isPlayerSide()) {
s.yDisplayPosition = s.getY() + this.ySize - 78 - 5;
} else {
s.yDisplayPosition = s.getY() + this.ySize - 78 - 3;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@
import appeng.client.gui.AEBaseMEGui;

import com.glodblock.github.client.gui.*;
import com.glodblock.github.client.gui.container.base.FCBaseContainer;
import com.glodblock.github.common.item.ItemWirelessUltraTerminal;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.inventory.item.IWirelessTerminal;
import com.glodblock.github.util.ModAndClassUtil;

public abstract class FCBaseMEGui extends AEBaseMEGui {
Expand All @@ -27,9 +29,13 @@ public abstract class FCBaseMEGui extends AEBaseMEGui {

public FCBaseMEGui(final InventoryPlayer inventoryPlayer, Container container) {
super(container);
if (inventoryPlayer.getCurrentItem() != null
&& inventoryPlayer.getCurrentItem().getItem() instanceof ItemWirelessUltraTerminal)
this.drawSwitchGuiBtn = true;
if (container instanceof FCBaseContainer) {
Object target = ((FCBaseContainer) container).getTarget();
if (target instanceof IWirelessTerminal
&& ((IWirelessTerminal) target).getItemStack().getItem() instanceof ItemWirelessUltraTerminal) {
this.drawSwitchGuiBtn = true;
}
}
}

@Override
Expand Down Expand Up @@ -135,14 +141,4 @@ protected void actionPerformed(final GuiButton btn) {
}
super.actionPerformed(btn);
}

@Override
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY) {

}

@Override
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY) {

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -62,6 +64,24 @@ public FCGuiEncodeTerminal(final InventoryPlayer inventoryPlayer, final ITermina
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);
Expand Down Expand Up @@ -108,6 +128,11 @@ protected void actionPerformed(final GuiButton btn) {
} 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"));
}
}

Expand All @@ -124,6 +149,8 @@ public void drawFG(final int offsetX, final int offsetY, final int mouseX, final
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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,8 @@
import appeng.core.AELog;
import appeng.core.localization.ButtonToolTips;
import appeng.core.localization.GuiText;
import appeng.core.sync.GuiBridge;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketInventoryAction;
import appeng.core.sync.packets.PacketSwitchGuis;
import appeng.core.sync.packets.PacketValueConfig;
import appeng.helpers.InventoryAction;
import appeng.integration.IntegrationRegistry;
Expand All @@ -50,6 +48,8 @@
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.*;
import com.glodblock.github.client.gui.container.base.FCContainerMonitor;
import com.glodblock.github.inventory.InventoryHandler;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.network.CPacketInventoryAction;
import com.glodblock.github.util.Ae2ReflectClient;
import com.glodblock.github.util.ModAndClassUtil;
Expand Down Expand Up @@ -119,7 +119,7 @@ protected void setScrollBar() {
@Override
protected void actionPerformed(final GuiButton btn) {
if (btn == this.craftingStatusBtn || btn == this.craftingStatusImgBtn) {
NetworkHandler.instance.sendToServer(new PacketSwitchGuis(GuiBridge.GUI_CRAFTING_STATUS));
InventoryHandler.switchGui(GuiType.CRAFTING_STATUS);
}
if (btn instanceof GuiImgButton) {
final boolean backwards = Mouse.isButtonDown(1);
Expand Down Expand Up @@ -314,7 +314,7 @@ public void initGui() {

for (final Object s : this.inventorySlots.inventorySlots) {
if (s instanceof AppEngSlot) {
if (((Slot) s).xDisplayPosition < 195) {
if (((Slot) s).xDisplayPosition < 195 || s instanceof SlotDisabled) {
this.repositionSlot((AppEngSlot) s);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ public void startJob() {
InventoryHandler.openGui(
this.getInventoryPlayer().player,
getWorld(),
new BlockPos(this.getPlayerInv().currentItem, 0, 0),
new BlockPos(((IWirelessTerminal) ah).getInventorySlot(), 0, 0),
ForgeDirection.UNKNOWN,
originalGui);
} else if (this.getOpenContext() != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ private int lockSlot() {
if (isWirelessTerminal()) {
if (this.host != null) {
final int slotIndex = this.host.getInventorySlot();
this.lockPlayerInventorySlot(slotIndex);
if (Util.GuiHelper.decodeInvType(slotIndex).getLeft() == Util.GuiHelper.InvType.PLAYER_INV) {
this.lockPlayerInventorySlot(slotIndex);
}
return slotIndex;
} else {
this.lockPlayerInventorySlot(ip.currentItem);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -302,6 +306,7 @@ public void encodeAndMoveToInventory() {
}
this.patternSlotOUT.putStack(null);
}
fillPattern();
}

public void encodeAllItemAndMoveToInventory() {
Expand All @@ -315,9 +320,38 @@ public void encodeAllItemAndMoveToInventory() {
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.MODULATE, this.getActionSource());
if (out != null) {
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;
Expand Down Expand Up @@ -454,6 +488,7 @@ public void detectAndSendChanges() {
this.combine = this.patternTerminal.shouldCombine();
this.beSubstitute = this.patternTerminal.canBeSubstitute();
this.prioritize = this.patternTerminal.isPrioritize();
this.autoFillPattern = this.patternTerminal.isAutoFillPattern();
}
}

Expand Down
Loading

0 comments on commit 1a7acf4

Please sign in to comment.