mirror of
https://github.com/GTNewHorizons/AE2FluidCraft-Rework.git
synced 2026-11-16 18:44:42 +00:00
ultra terminal
This commit is contained in:
1 parent
30624682e4
commit
3567b68acb
50 files changed
+915
-2399
No files matched your search
@@ -6,10 +6,8 @@ import net.minecraft.entity.player.InventoryPlayer;
|
||||
|
||||
import org.lwjgl.input.Mouse;
|
||||
|
||||
import com.glodblock.github.FluidCraft;
|
||||
import com.glodblock.github.client.gui.container.ContainerFluidStorageBus;
|
||||
import com.glodblock.github.common.parts.PartFluidStorageBus;
|
||||
import com.glodblock.github.network.CPacketFluidPatternTermBtns;
|
||||
import com.glodblock.github.util.NameConst;
|
||||
|
||||
import appeng.api.config.AccessRestriction;
|
||||
@@ -21,8 +19,10 @@ import appeng.client.gui.widgets.GuiImgButton;
|
||||
import appeng.client.gui.widgets.GuiTabButton;
|
||||
import appeng.core.localization.GuiColors;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketConfigButton;
|
||||
import appeng.core.sync.packets.PacketSwitchGuis;
|
||||
|
||||
public class GuiFluidStorageBus extends GuiUpgradeable {
|
||||
|
||||
@@ -86,11 +86,12 @@ public class GuiFluidStorageBus extends GuiUpgradeable {
|
||||
super.actionPerformed(btn);
|
||||
final boolean backwards = Mouse.isButtonDown(1);
|
||||
if (btn == this.partition) {
|
||||
FluidCraft.proxy.netHandler.sendToServer(new CPacketFluidPatternTermBtns("StorageBus.Action", "Partition"));
|
||||
// FluidCraft.proxy.netHandler.sendToServer(new CPacketFluidPatternTermBtns("StorageBus.Action",
|
||||
// "Partition"));
|
||||
} else if (btn == this.clear) {
|
||||
FluidCraft.proxy.netHandler.sendToServer(new CPacketFluidPatternTermBtns("StorageBus.Action", "Clear"));
|
||||
// FluidCraft.proxy.netHandler.sendToServer(new CPacketFluidPatternTermBtns("StorageBus.Action", "Clear"));
|
||||
} else if (btn == this.priority) {
|
||||
// InventoryHandler.switchGui(GuiType.PRIORITY);
|
||||
NetworkHandler.instance.sendToServer(new PacketSwitchGuis(GuiBridge.GUI_PRIORITY));
|
||||
} else if (btn == this.rwMode) {
|
||||
NetworkHandler.instance.sendToServer(new PacketConfigButton(this.rwMode.getSetting(), backwards));
|
||||
}
|
||||
|
||||
@@ -66,6 +66,9 @@ import appeng.core.localization.ButtonToolTips;
|
||||
import appeng.core.localization.GuiColors;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.localization.PlayerMessages;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketSwitchGuis;
|
||||
import appeng.helpers.InventoryAction;
|
||||
import appeng.integration.IntegrationRegistry;
|
||||
import appeng.integration.IntegrationType;
|
||||
@@ -82,7 +85,6 @@ public class GuiLevelTerminal extends FCBaseMEGui implements IDropToFillTextFiel
|
||||
public static final int VIEW_LEFT = 8;
|
||||
private static final ResourceLocation TEX_BG = FluidCraft.resource("textures/gui/level_terminal.png");
|
||||
private static final RenderItem renderItem = new RenderItem();
|
||||
protected int offsetY;
|
||||
private static final int offsetX = 21;
|
||||
protected static String searchFieldOutputsText = "";
|
||||
protected static String searchFieldNamesText = "";
|
||||
@@ -143,16 +145,6 @@ public class GuiLevelTerminal extends FCBaseMEGui implements IDropToFillTextFiel
|
||||
this(inventoryPlayer, new ContainerLevelTerminal(inventoryPlayer, te));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOffsetY() {
|
||||
return offsetY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOffsetY(int y) {
|
||||
offsetY = y;
|
||||
}
|
||||
|
||||
private void setScrollBar() {
|
||||
int maxScroll = masterList.getHeight() - viewHeight - 1;
|
||||
if (maxScroll <= 0) {
|
||||
@@ -170,7 +162,7 @@ public class GuiLevelTerminal extends FCBaseMEGui implements IDropToFillTextFiel
|
||||
final int unusedSpace = height - ySize;
|
||||
guiTop = (int) Math.floor(unusedSpace / (unusedSpace < 0 ? 3.8f : 2.0f));
|
||||
|
||||
offsetY = guiTop + 8;
|
||||
int offsetY = guiTop + 8;
|
||||
terminalStyleBox = new GuiImgButton(
|
||||
guiLeft - 18,
|
||||
offsetY,
|
||||
@@ -209,7 +201,7 @@ public class GuiLevelTerminal extends FCBaseMEGui implements IDropToFillTextFiel
|
||||
|
||||
setScrollBar();
|
||||
repositionSlots();
|
||||
initGuiDone();
|
||||
initCustomButtons(0, offsetY);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -270,12 +262,6 @@ public class GuiLevelTerminal extends FCBaseMEGui implements IDropToFillTextFiel
|
||||
public void drawScreen(final int mouseX, final int mouseY, final float btn) {
|
||||
terminalStyleBox.set(AEConfig.instance.settings.getSetting(Settings.TERMINAL_STYLE));
|
||||
|
||||
buttonList.clear();
|
||||
buttonList.add(terminalStyleBox);
|
||||
buttonList.add(searchStringSave);
|
||||
buttonList.add(craftingStatusBtn);
|
||||
addSwitchGuiBtns();
|
||||
|
||||
super.drawScreen(mouseX, mouseY, btn);
|
||||
|
||||
handleTooltip(mouseX, mouseY, searchFieldOutputs);
|
||||
@@ -305,7 +291,8 @@ public class GuiLevelTerminal extends FCBaseMEGui implements IDropToFillTextFiel
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(final GuiButton btn) {
|
||||
if (ModAndClassUtil.isSaveText && btn == searchStringSave) {
|
||||
if (actionPerformedCustomButtons(btn)) return;
|
||||
if (ModAndClassUtil.isSaveText && btn == searchStringSave) {
|
||||
|
||||
final boolean backwards = Mouse.isButtonDown(1);
|
||||
final GuiImgButton iBtn = (GuiImgButton) btn;
|
||||
@@ -316,6 +303,7 @@ public class GuiLevelTerminal extends FCBaseMEGui implements IDropToFillTextFiel
|
||||
searchStringSave.set(next);
|
||||
|
||||
} else if (btn == craftingStatusBtn) {
|
||||
NetworkHandler.instance.sendToServer(new PacketSwitchGuis(GuiBridge.GUI_CRAFTING_STATUS));
|
||||
} else if (btn instanceof final GuiImgButton iBtn) {
|
||||
if (iBtn.getSetting() != Settings.ACTIONS) {
|
||||
final Enum<?> cv = iBtn.getCurrentValue();
|
||||
|
||||
@@ -15,12 +15,11 @@ import com.glodblock.github.util.NameConst;
|
||||
import appeng.api.config.ActionItems;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
import appeng.client.gui.AEBaseMEGui;
|
||||
import appeng.client.gui.implementations.GuiSub;
|
||||
import appeng.client.gui.widgets.GuiImgButton;
|
||||
import appeng.client.gui.widgets.GuiTabButton;
|
||||
import appeng.client.gui.widgets.MEGuiTextField;
|
||||
|
||||
public class GuiMagnetFilter extends AEBaseMEGui {
|
||||
public class GuiMagnetFilter extends GuiSub {
|
||||
|
||||
protected FCGuiBaseButton listModeBtn;
|
||||
protected ContainerMagnetFilter cont;
|
||||
@@ -28,12 +27,11 @@ public class GuiMagnetFilter extends AEBaseMEGui {
|
||||
|
||||
protected Component[] components = new Component[4];
|
||||
protected MEGuiTextField oreDict;
|
||||
protected GuiTabButton originalGuiBtn;
|
||||
protected GuiImgButton clearBtn;
|
||||
|
||||
public GuiMagnetFilter(InventoryPlayer ip, ITerminalHost container) {
|
||||
super(new ContainerMagnetFilter(ip, container));
|
||||
this.xSize = 195;
|
||||
this.xSize = 176;
|
||||
this.ySize = 214;
|
||||
this.cont = (ContainerMagnetFilter) this.inventorySlots;
|
||||
oreDict = new MEGuiTextField(149, 12, NameConst.i18n(NameConst.TT_MAGNET_CARD_OREDICT));
|
||||
@@ -43,10 +41,10 @@ public class GuiMagnetFilter extends AEBaseMEGui {
|
||||
|
||||
private final GuiFCImgButton enable;
|
||||
private final GuiFCImgButton disable;
|
||||
private final String action;
|
||||
private final CPacketFluidPatternTermBtns.Command action;
|
||||
private boolean var;
|
||||
|
||||
public Component(int x, int y, boolean var, String action) {
|
||||
public Component(int x, int y, boolean var, CPacketFluidPatternTermBtns.Command action) {
|
||||
this.enable = new GuiFCImgButton(x, y, "ENABLE_12x", "ENABLE", false);
|
||||
this.disable = new GuiFCImgButton(x, y, "DISABLE_12x", "DISABLE", false);
|
||||
this.var = var;
|
||||
@@ -104,36 +102,27 @@ public class GuiMagnetFilter extends AEBaseMEGui {
|
||||
this.guiLeft + 157,
|
||||
this.guiTop + 18,
|
||||
this.cont.nbt,
|
||||
"WirelessTerminal.magnet.NBT");
|
||||
CPacketFluidPatternTermBtns.Command.MAGNET_FILTER_NBT);
|
||||
this.components[1] = new Component(
|
||||
this.guiLeft + 157,
|
||||
this.guiTop + 31,
|
||||
this.cont.meta,
|
||||
"WirelessTerminal.magnet.Meta");
|
||||
CPacketFluidPatternTermBtns.Command.MAGNET_FILTER_META);
|
||||
this.components[2] = new Component(
|
||||
this.guiLeft + 157,
|
||||
this.guiTop + 44,
|
||||
this.cont.ore,
|
||||
"WirelessTerminal.magnet.Ore");
|
||||
CPacketFluidPatternTermBtns.Command.MAGNET_FILTER_ORE);
|
||||
this.components[3] = new Component(
|
||||
this.guiLeft + 157,
|
||||
this.guiTop + 112,
|
||||
this.cont.oreDict,
|
||||
"WirelessTerminal.magnet.OreDictState");
|
||||
CPacketFluidPatternTermBtns.Command.MAGNET_FILTER_OREDICT_STATE);
|
||||
|
||||
oreDict.x = this.guiLeft + 7;
|
||||
oreDict.y = this.guiTop + 112;
|
||||
oreDict.setText(this.cont.oreDictFilter);
|
||||
|
||||
this.buttonList.add(
|
||||
this.originalGuiBtn = new GuiTabButton(
|
||||
this.guiLeft + this.xSize - 44,
|
||||
this.guiTop - 4,
|
||||
this.cont.getPortableCell().getItemStack(),
|
||||
this.cont.getPortableCell().getItemStack().getDisplayName(),
|
||||
itemRender));
|
||||
this.originalGuiBtn.setHideEdge(13); // GuiTabButton implementation //
|
||||
|
||||
this.clearBtn = new GuiImgButton(this.guiLeft + 7, this.guiTop + 48, Settings.ACTIONS, ActionItems.CLOSE);
|
||||
this.clearBtn.setHalfSize(true);
|
||||
this.buttonList.add(this.clearBtn);
|
||||
@@ -174,7 +163,9 @@ public class GuiMagnetFilter extends AEBaseMEGui {
|
||||
protected void keyTyped(char typedChar, int keyCode) {
|
||||
if (oreDict.isFocused() && (Keyboard.KEY_NUMPADENTER == keyCode || Keyboard.KEY_RETURN == keyCode)) {
|
||||
FluidCraft.proxy.netHandler.sendToServer(
|
||||
new CPacketFluidPatternTermBtns("WirelessTerminal.magnet.OreDictFilter", oreDict.getText()));
|
||||
new CPacketFluidPatternTermBtns(
|
||||
CPacketFluidPatternTermBtns.Command.MAGNET_FILTER_OREDICT_FILTER,
|
||||
oreDict.getText()));
|
||||
}
|
||||
|
||||
if (!oreDict.textboxKeyTyped(typedChar, keyCode)) super.keyTyped(typedChar, keyCode);
|
||||
@@ -197,13 +188,11 @@ public class GuiMagnetFilter extends AEBaseMEGui {
|
||||
if (btn == this.listModeBtn) {
|
||||
FluidCraft.proxy.netHandler.sendToServer(
|
||||
new CPacketFluidPatternTermBtns(
|
||||
"WirelessTerminal.magnet.FilterMode",
|
||||
CPacketFluidPatternTermBtns.Command.MAGNET_FILTER_MODE,
|
||||
this.cont.listMode != WirelessMagnet.ListMode.WhiteList));
|
||||
} else if (btn == this.originalGuiBtn) {
|
||||
// InventoryHandler.switchGui(ItemWirelessUltraTerminal.readMode(this.cont.getPortableCell().getItemStack()));
|
||||
} else if (btn == this.clearBtn) {
|
||||
FluidCraft.proxy.netHandler
|
||||
.sendToServer(new CPacketFluidPatternTermBtns("WirelessTerminal.magnet.clear", 1));
|
||||
FluidCraft.proxy.netHandler.sendToServer(
|
||||
new CPacketFluidPatternTermBtns(CPacketFluidPatternTermBtns.Command.MAGNET_FILTER_CLEAR, 1));
|
||||
}
|
||||
super.actionPerformed(btn);
|
||||
}
|
||||
|
||||
@@ -17,11 +17,15 @@ import com.glodblock.github.common.tile.TileSuperStockReplenisher;
|
||||
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
import appeng.client.StorageName;
|
||||
import appeng.client.gui.AEBaseGui;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.container.slot.SlotFake;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.helpers.InventoryAction;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketSwitchGuis;
|
||||
import appeng.core.sync.packets.PacketVirtualSlot;
|
||||
import appeng.util.item.AEItemStack;
|
||||
|
||||
public class GuiSuperStockReplenisher extends AEBaseGui {
|
||||
@@ -40,13 +44,14 @@ public class GuiSuperStockReplenisher extends AEBaseGui {
|
||||
if (mouseButton == 3) {
|
||||
if (slot instanceof SlotFake) {
|
||||
if (slot.getHasStack()) {
|
||||
InventoryAction action = InventoryAction.SET_PATTERN_VALUE;
|
||||
IAEItemStack stack = AEItemStack.create(slot.getStack());
|
||||
((AEBaseContainer) this.inventorySlots).setTargetStack(stack);
|
||||
for (int i = 0; i < this.inventorySlots.inventorySlots.size(); i++) {
|
||||
if (slot.equals(this.inventorySlots.inventorySlots.get(i))) {
|
||||
// FluidCraft.proxy.netHandler.sendToServer(new CPacketInventoryAction(action, i, 0,
|
||||
// stack));
|
||||
NetworkHandler.instance
|
||||
.sendToServer(new PacketSwitchGuis(GuiBridge.GUI_PATTERN_VALUE_AMOUNT));
|
||||
NetworkHandler.instance
|
||||
.sendToServer(new PacketVirtualSlot(StorageName.CRAFTING_INPUT, i, stack));
|
||||
}
|
||||
}
|
||||
return;
|
||||
|
||||
@@ -1,61 +1,14 @@
|
||||
package com.glodblock.github.client.gui.base;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
|
||||
import com.glodblock.github.FluidCraft;
|
||||
import com.glodblock.github.client.gui.GuiFCImgButton;
|
||||
import com.glodblock.github.client.gui.GuiLevelWireless;
|
||||
import com.glodblock.github.client.gui.container.base.FCBaseContainer;
|
||||
import com.glodblock.github.common.item.ItemWirelessUltraTerminal;
|
||||
import com.glodblock.github.inventory.item.IWirelessTerminal;
|
||||
import com.glodblock.github.inventory.item.WirelessMagnet;
|
||||
import com.glodblock.github.network.CPacketFluidPatternTermBtns;
|
||||
|
||||
import appeng.api.storage.StorageChannel;
|
||||
import appeng.client.gui.AEBaseMEGui;
|
||||
|
||||
public abstract class FCBaseMEGui extends AEBaseMEGui {
|
||||
|
||||
protected GuiFCImgButton FluidTerminal;
|
||||
protected GuiFCImgButton CraftingTerminal;
|
||||
protected GuiFCImgButton PatternTerminal;
|
||||
protected GuiFCImgButton EssentiaTerminal;
|
||||
protected GuiFCImgButton InterfaceTerminal;
|
||||
protected GuiFCImgButton LevelTerminal;
|
||||
protected GuiFCImgButton PatternTerminalEx;
|
||||
protected GuiFCImgButton magnetOff;
|
||||
protected GuiFCImgButton magnetInv;
|
||||
protected GuiFCImgButton magnetME;
|
||||
protected GuiFCImgButton magnetFilter;
|
||||
protected GuiFCImgButton restockEnableBtn;
|
||||
protected GuiFCImgButton restockDisableBtn;
|
||||
protected List<GuiFCImgButton> termBtns = new ArrayList<>();
|
||||
protected boolean drawSwitchGuiBtn;
|
||||
private StorageChannel channel = null;
|
||||
|
||||
public FCBaseMEGui(final InventoryPlayer inventoryPlayer, Container container) {
|
||||
super(container);
|
||||
if (container instanceof FCBaseContainer) {
|
||||
Object target = ((FCBaseContainer) container).getTarget();
|
||||
if (target instanceof IWirelessTerminal
|
||||
&& ((IWirelessTerminal) target).getItemStack().getItem() instanceof ItemWirelessUltraTerminal) {
|
||||
this.drawSwitchGuiBtn = true;
|
||||
channel = ((IWirelessTerminal) target).getChannel();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected WirelessMagnet.Mode getMagnetMode() {
|
||||
return ((FCBaseContainer) this.inventorySlots).mode;
|
||||
}
|
||||
|
||||
protected boolean isRestock() {
|
||||
return ((FCBaseContainer) this.inventorySlots).restock;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -63,82 +16,6 @@ public abstract class FCBaseMEGui extends AEBaseMEGui {
|
||||
super.onGuiClosed();
|
||||
}
|
||||
|
||||
protected void initGuiDone() {
|
||||
if (drawSwitchGuiBtn) {
|
||||
drawSwitchGuiBtns();
|
||||
}
|
||||
}
|
||||
|
||||
public abstract int getOffsetY();
|
||||
|
||||
public abstract void setOffsetY(int y);
|
||||
|
||||
protected void drawSwitchGuiBtns() {
|
||||
if (!drawSwitchGuiBtn) return;
|
||||
if (!termBtns.isEmpty()) {
|
||||
this.termBtns.clear();
|
||||
}
|
||||
if (this.getMagnetMode() != null && this.channel == StorageChannel.ITEMS) {
|
||||
this.buttonList.add(
|
||||
this.magnetOff = new GuiFCImgButton(
|
||||
this.guiLeft + this.xSize - 18,
|
||||
this.guiTop + this.ySize - 124,
|
||||
"MAGNET_CARD",
|
||||
"OFF"));
|
||||
this.buttonList.add(
|
||||
this.magnetInv = new GuiFCImgButton(
|
||||
this.guiLeft + this.xSize - 18,
|
||||
this.guiTop + this.ySize - 124,
|
||||
"MAGNET_CARD",
|
||||
"INV"));
|
||||
this.buttonList.add(
|
||||
this.magnetME = new GuiFCImgButton(
|
||||
this.guiLeft + this.xSize - 18,
|
||||
this.guiTop + this.ySize - 124,
|
||||
"MAGNET_CARD",
|
||||
"ME"));
|
||||
this.buttonList.add(
|
||||
this.magnetFilter = new GuiFCImgButton(
|
||||
this.guiLeft + this.xSize - 18,
|
||||
this.guiTop + this.ySize - 104,
|
||||
"MAGNET_CARD",
|
||||
"FILTER"));
|
||||
}
|
||||
if (this.channel == StorageChannel.ITEMS) {
|
||||
this.buttonList.add(
|
||||
this.restockEnableBtn = new GuiFCImgButton(
|
||||
this.guiLeft + this.xSize - 18,
|
||||
this.guiTop + this.ySize - 84,
|
||||
"RESTOCK",
|
||||
"ENABLE"));
|
||||
this.buttonList.add(
|
||||
this.restockDisableBtn = new GuiFCImgButton(
|
||||
this.guiLeft + this.xSize - 18,
|
||||
this.guiTop + this.ySize - 84,
|
||||
"RESTOCK",
|
||||
"DISABLE"));
|
||||
}
|
||||
this.buttonList.add(
|
||||
this.InterfaceTerminal = new GuiFCImgButton(
|
||||
this.guiLeft - 18,
|
||||
this.getOffsetY(),
|
||||
"INTERFACE_TEM",
|
||||
"YES"));
|
||||
this.setOffsetY(this.getOffsetY() + 20);
|
||||
termBtns.add(this.InterfaceTerminal);
|
||||
if (!(this instanceof GuiLevelWireless)) {
|
||||
this.buttonList.add(
|
||||
this.LevelTerminal = new GuiFCImgButton(this.guiLeft - 18, this.getOffsetY(), "LEVEL_TEM", "YES"));
|
||||
this.setOffsetY(this.getOffsetY() + 20);
|
||||
termBtns.add(this.LevelTerminal);
|
||||
}
|
||||
}
|
||||
|
||||
protected void addSwitchGuiBtns() {
|
||||
if (!drawSwitchGuiBtn) return;
|
||||
this.buttonList.addAll(termBtns);
|
||||
}
|
||||
|
||||
private boolean scheduleGuiResize;
|
||||
|
||||
@Override
|
||||
@@ -160,39 +37,4 @@ public abstract class FCBaseMEGui extends AEBaseMEGui {
|
||||
protected final void scheduleGuiResize() {
|
||||
scheduleGuiResize = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY) {
|
||||
if (isPortableCell()) return;
|
||||
if (getMagnetMode() != null && this.channel == StorageChannel.ITEMS) {
|
||||
GuiFCImgButton[] magnetButtons = { this.magnetOff, this.magnetInv, this.magnetME };
|
||||
for (int i = 0; i < magnetButtons.length; i++) {
|
||||
magnetButtons[i].visible = getMagnetMode().ordinal() == i;
|
||||
}
|
||||
}
|
||||
if (this.drawSwitchGuiBtn && this.channel == StorageChannel.ITEMS) { // Only ultra terminal
|
||||
this.restockDisableBtn.visible = !this.isRestock();
|
||||
this.restockEnableBtn.visible = this.isRestock();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(final GuiButton btn) {
|
||||
if (btn instanceof GuiFCImgButton) {
|
||||
if (btn == this.magnetOff || btn == this.magnetME || btn == this.magnetInv) {
|
||||
FluidCraft.proxy.netHandler.sendToServer(
|
||||
new CPacketFluidPatternTermBtns("WirelessTerminal.MagnetMode", this.getMagnetMode().ordinal()));
|
||||
} else if (btn == this.magnetFilter) {
|
||||
FluidCraft.proxy.netHandler
|
||||
.sendToServer(new CPacketFluidPatternTermBtns("WirelessTerminal.OpenMagnet", 0));
|
||||
} else if (btn == this.restockDisableBtn || btn == this.restockEnableBtn) {
|
||||
FluidCraft.proxy.netHandler.sendToServer(new CPacketFluidPatternTermBtns("WirelessTerminal.Stock", 1));
|
||||
}
|
||||
}
|
||||
super.actionPerformed(btn);
|
||||
}
|
||||
|
||||
protected boolean isPortableCell() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -3,10 +3,16 @@ package com.glodblock.github.client.gui.container;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
|
||||
import com.glodblock.github.common.tile.TileFluidInterface;
|
||||
import com.glodblock.github.inventory.gui.GuiType;
|
||||
import com.glodblock.github.loader.ItemAndBlockHolder;
|
||||
import com.glodblock.github.util.FluidPrimaryGui;
|
||||
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.config.SidelessMode;
|
||||
import appeng.api.parts.IPart;
|
||||
import appeng.api.util.IConfigManager;
|
||||
import appeng.container.ContainerOpenContext;
|
||||
import appeng.container.PrimaryGui;
|
||||
import appeng.container.guisync.GuiSync;
|
||||
import appeng.container.implementations.ContainerInterface;
|
||||
import appeng.helpers.IInterfaceHost;
|
||||
@@ -33,4 +39,16 @@ public class ContainerDualInterface extends ContainerInterface {
|
||||
super.loadSettingsFromHost(cm);
|
||||
this.sidelessMode = this.isTile ? (SidelessMode) cm.getSetting(Settings.SIDELESS_MODE) : SidelessMode.SIDELESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PrimaryGui getPrimaryGui() {
|
||||
|
||||
ContainerOpenContext context = getOpenContext();
|
||||
return new FluidPrimaryGui(
|
||||
GuiType.DUAL_INTERFACE_FLUID,
|
||||
getTarget() instanceof IPart ? ItemAndBlockHolder.FLUID_INTERFACE.stack()
|
||||
: ItemAndBlockHolder.INTERFACE.stack(),
|
||||
context.getTile(),
|
||||
context.getSide());
|
||||
}
|
||||
}
|
||||
@@ -5,11 +5,16 @@ import net.minecraft.entity.player.InventoryPlayer;
|
||||
import com.glodblock.github.client.gui.container.base.FCContainerFluidConfigurable;
|
||||
import com.glodblock.github.common.parts.PartFluidExportBus;
|
||||
import com.glodblock.github.common.parts.base.FCSharedFluidBus;
|
||||
import com.glodblock.github.inventory.gui.GuiType;
|
||||
import com.glodblock.github.loader.ItemAndBlockHolder;
|
||||
import com.glodblock.github.util.FluidPrimaryGui;
|
||||
|
||||
import appeng.api.config.SchedulingMode;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.config.YesNo;
|
||||
import appeng.api.util.IConfigManager;
|
||||
import appeng.container.ContainerOpenContext;
|
||||
import appeng.container.PrimaryGui;
|
||||
import appeng.tile.inventory.AppEngInternalAEInventory;
|
||||
|
||||
public class ContainerFluidIO extends FCContainerFluidConfigurable {
|
||||
@@ -42,4 +47,16 @@ public class ContainerFluidIO extends FCContainerFluidConfigurable {
|
||||
public void setSchedulingMode(final SchedulingMode schedulingMode) {
|
||||
this.schedulingMode = schedulingMode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PrimaryGui getPrimaryGui() {
|
||||
|
||||
ContainerOpenContext context = getOpenContext();
|
||||
return new FluidPrimaryGui(
|
||||
GuiType.FLUID_BUS_IO,
|
||||
getTarget() instanceof PartFluidExportBus ? ItemAndBlockHolder.FLUID_EXPORT_BUS.stack()
|
||||
: ItemAndBlockHolder.FLUID_IMPORT_BUS.stack(),
|
||||
context.getTile(),
|
||||
context.getSide());
|
||||
}
|
||||
}
|
||||
+16
@@ -6,12 +6,17 @@ import net.minecraft.inventory.IInventory;
|
||||
|
||||
import com.glodblock.github.client.gui.container.base.FCContainerFluidConfigurable;
|
||||
import com.glodblock.github.common.parts.PartFluidLevelEmitter;
|
||||
import com.glodblock.github.inventory.gui.GuiType;
|
||||
import com.glodblock.github.inventory.slot.OptionalFluidSlotFakeTypeOnly;
|
||||
import com.glodblock.github.loader.ItemAndBlockHolder;
|
||||
import com.glodblock.github.util.FluidPrimaryGui;
|
||||
|
||||
import appeng.api.config.RedstoneMode;
|
||||
import appeng.api.config.SecurityPermissions;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.client.gui.widgets.MEGuiTextField;
|
||||
import appeng.container.ContainerOpenContext;
|
||||
import appeng.container.PrimaryGui;
|
||||
import appeng.container.guisync.GuiSync;
|
||||
import appeng.tile.inventory.AppEngInternalAEInventory;
|
||||
import appeng.util.Platform;
|
||||
@@ -96,4 +101,15 @@ public class ContainerFluidLevelEmitter extends FCContainerFluidConfigurable {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public PrimaryGui getPrimaryGui() {
|
||||
|
||||
ContainerOpenContext context = getOpenContext();
|
||||
return new FluidPrimaryGui(
|
||||
GuiType.FLUID_LEVEL_EMITTER,
|
||||
ItemAndBlockHolder.FLUID_LEVEL_EMITTER.stack(),
|
||||
context.getTile(),
|
||||
context.getSide());
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,10 @@ import net.minecraft.inventory.IInventory;
|
||||
import com.glodblock.github.client.gui.container.base.FCContainerFluidConfigurable;
|
||||
import com.glodblock.github.common.item.ItemFluidPacket;
|
||||
import com.glodblock.github.common.parts.PartFluidStorageBus;
|
||||
import com.glodblock.github.inventory.gui.GuiType;
|
||||
import com.glodblock.github.inventory.slot.OptionalFluidSlotFakeTypeOnly;
|
||||
import com.glodblock.github.loader.ItemAndBlockHolder;
|
||||
import com.glodblock.github.util.FluidPrimaryGui;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.AccessRestriction;
|
||||
@@ -19,6 +22,8 @@ import appeng.api.config.Upgrades;
|
||||
import appeng.api.storage.IMEInventory;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
import appeng.container.ContainerOpenContext;
|
||||
import appeng.container.PrimaryGui;
|
||||
import appeng.container.guisync.GuiSync;
|
||||
import appeng.container.slot.SlotRestrictedInput;
|
||||
import appeng.tile.inventory.AppEngInternalAEInventory;
|
||||
@@ -188,4 +193,15 @@ public class ContainerFluidStorageBus extends FCContainerFluidConfigurable {
|
||||
private void setStorageFilter(final StorageFilter storageFilter) {
|
||||
this.storageFilter = storageFilter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PrimaryGui getPrimaryGui() {
|
||||
|
||||
ContainerOpenContext context = getOpenContext();
|
||||
return new FluidPrimaryGui(
|
||||
GuiType.FLUID_STORAGE_BUS,
|
||||
ItemAndBlockHolder.FLUID_STORAGE_BUS.stack(),
|
||||
context.getTile(),
|
||||
context.getSide());
|
||||
}
|
||||
}
|
||||
@@ -20,8 +20,11 @@ import com.glodblock.github.api.registries.LevelItemInfo;
|
||||
import com.glodblock.github.client.gui.container.base.FCBaseContainer;
|
||||
import com.glodblock.github.common.parts.PartLevelTerminal;
|
||||
import com.glodblock.github.coremod.registries.LevelTerminalRegistry;
|
||||
import com.glodblock.github.inventory.gui.GuiType;
|
||||
import com.glodblock.github.inventory.item.IWirelessTerminal;
|
||||
import com.glodblock.github.loader.ItemAndBlockHolder;
|
||||
import com.glodblock.github.network.SPacketLevelTerminalUpdate;
|
||||
import com.glodblock.github.util.FluidPrimaryGui;
|
||||
|
||||
import appeng.api.networking.IGrid;
|
||||
import appeng.api.networking.IGridHost;
|
||||
@@ -29,6 +32,8 @@ import appeng.api.networking.IGridNode;
|
||||
import appeng.api.networking.security.IActionHost;
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
import appeng.api.util.DimensionalCoord;
|
||||
import appeng.container.ContainerOpenContext;
|
||||
import appeng.container.PrimaryGui;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class ContainerLevelTerminal extends FCBaseContainer {
|
||||
@@ -238,4 +243,15 @@ public class ContainerLevelTerminal extends FCBaseContainer {
|
||||
this.infoList = machine.getLevelItemInfoList();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public PrimaryGui getPrimaryGui() {
|
||||
|
||||
ContainerOpenContext context = getOpenContext();
|
||||
return new FluidPrimaryGui(
|
||||
GuiType.LEVEL_TERMINAL,
|
||||
ItemAndBlockHolder.LEVEL_TERMINAL.stack(),
|
||||
context.getTile(),
|
||||
context.getSide());
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,13 @@ package com.glodblock.github.client.gui.container;
|
||||
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
|
||||
import com.glodblock.github.inventory.gui.GuiType;
|
||||
import com.glodblock.github.inventory.item.IWirelessTerminal;
|
||||
import com.glodblock.github.loader.ItemAndBlockHolder;
|
||||
import com.glodblock.github.util.FluidPrimaryGui;
|
||||
|
||||
import appeng.container.ContainerOpenContext;
|
||||
import appeng.container.PrimaryGui;
|
||||
|
||||
public class ContainerLevelWireless extends ContainerLevelTerminal {
|
||||
|
||||
@@ -14,4 +20,15 @@ public class ContainerLevelWireless extends ContainerLevelTerminal {
|
||||
protected boolean isWirelessTerminal() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PrimaryGui getPrimaryGui() {
|
||||
|
||||
ContainerOpenContext context = getOpenContext();
|
||||
return new FluidPrimaryGui(
|
||||
GuiType.WIRELESS_LEVEL_TERMINAL,
|
||||
ItemAndBlockHolder.WIRELESS_LEVEL_TERM.stack(),
|
||||
context.getTile(),
|
||||
context.getSide());
|
||||
}
|
||||
}
|
||||
+15
-18
@@ -5,12 +5,12 @@ import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import com.glodblock.github.client.gui.container.base.FCBaseContainer;
|
||||
import com.glodblock.github.inventory.item.IItemTerminal;
|
||||
import com.glodblock.github.inventory.item.IWirelessMagnetFilter;
|
||||
import com.glodblock.github.inventory.item.WirelessMagnet;
|
||||
import com.glodblock.github.inventory.item.WirelessMagnetCardFilterInventory;
|
||||
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
import appeng.container.ContainerSubGui;
|
||||
import appeng.container.guisync.GuiSync;
|
||||
import appeng.container.slot.AppEngSlot;
|
||||
import appeng.container.slot.IOptionalSlotHost;
|
||||
@@ -19,7 +19,7 @@ import appeng.container.slot.SlotFake;
|
||||
import appeng.container.slot.SlotPatternOutputs;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class ContainerMagnetFilter extends FCBaseContainer implements IOptionalSlotHost {
|
||||
public class ContainerMagnetFilter extends ContainerSubGui implements IOptionalSlotHost {
|
||||
|
||||
@GuiSync(101)
|
||||
public WirelessMagnet.ListMode listMode;
|
||||
@@ -41,12 +41,14 @@ public class ContainerMagnetFilter extends FCBaseContainer implements IOptionalS
|
||||
|
||||
protected OptionalSlotFake[] filterSlots;
|
||||
protected final IInventory filter;
|
||||
private final IWirelessMagnetFilter object;
|
||||
|
||||
public ContainerMagnetFilter(InventoryPlayer ip, ITerminalHost monitorable) {
|
||||
super(ip, monitorable);
|
||||
this.filter = ((IItemTerminal) monitorable).getInventoryByName("config");
|
||||
this.object = (WirelessMagnetCardFilterInventory) monitorable;
|
||||
this.filter = object.getInventoryByName("config");
|
||||
this.filterSlots = new OptionalSlotFake[27];
|
||||
oreDictFilter = ((IWirelessMagnetFilter) getHost()).getOreDictFilter();
|
||||
oreDictFilter = object.getOreDictFilter();
|
||||
for (int y = 0; y < 3; y++) {
|
||||
for (int x = 0; x < 9; x++) {
|
||||
this.addSlotToContainer(
|
||||
@@ -62,14 +64,10 @@ public class ContainerMagnetFilter extends FCBaseContainer implements IOptionalS
|
||||
this.filterSlots[x + y * 9].setRenderDisabled(false);
|
||||
}
|
||||
}
|
||||
this.lockPlayerInventorySlot(this.object.getInventorySlot());
|
||||
bindPlayerInventory(ip, 0, 126);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isWirelessTerminal() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack transferStackInSlot(EntityPlayer p, int idx) {
|
||||
AppEngSlot clickSlot = (AppEngSlot) this.inventorySlots.get(idx);
|
||||
@@ -87,14 +85,13 @@ public class ContainerMagnetFilter extends FCBaseContainer implements IOptionalS
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges() {
|
||||
if (Platform.isServer() && this.getPortableCell() instanceof IWirelessMagnetFilter) {
|
||||
IWirelessMagnetFilter host = (IWirelessMagnetFilter) this.getHost();
|
||||
this.listMode = host.getListMode();
|
||||
this.meta = host.getMetaMode();
|
||||
this.nbt = host.getNBTMode();
|
||||
this.ore = host.getOreMode();
|
||||
this.oreDict = host.getOreDictMode();
|
||||
this.oreDictFilter = host.getOreDictFilter();
|
||||
if (Platform.isServer()) {
|
||||
this.listMode = this.object.getListMode();
|
||||
this.meta = this.object.getMetaMode();
|
||||
this.nbt = this.object.getNBTMode();
|
||||
this.ore = this.object.getOreMode();
|
||||
this.oreDict = this.object.getOreDictMode();
|
||||
this.oreDictFilter = this.object.getOreDictFilter();
|
||||
}
|
||||
super.detectAndSendChanges();
|
||||
}
|
||||
|
||||
+68
-1
@@ -3,6 +3,8 @@ package com.glodblock.github.client.gui.container;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
@@ -13,19 +15,36 @@ import net.minecraft.item.ItemStack;
|
||||
|
||||
import com.glodblock.github.FluidCraft;
|
||||
import com.glodblock.github.common.item.FCBaseItemCell;
|
||||
import com.glodblock.github.common.item.ItemFluidPacket;
|
||||
import com.glodblock.github.common.tile.TileSuperStockReplenisher;
|
||||
import com.glodblock.github.inventory.gui.GuiType;
|
||||
import com.glodblock.github.inventory.slot.OptionalFluidSlotFake;
|
||||
import com.glodblock.github.loader.ItemAndBlockHolder;
|
||||
import com.glodblock.github.network.SPacketSuperStockReplenisherUpdate;
|
||||
import com.glodblock.github.util.FluidPrimaryGui;
|
||||
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
import appeng.client.StorageName;
|
||||
import appeng.client.gui.implementations.GuiPatternItemRenamer;
|
||||
import appeng.client.gui.implementations.GuiPatternValueAmount;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.container.ContainerOpenContext;
|
||||
import appeng.container.PrimaryGui;
|
||||
import appeng.container.slot.IOptionalSlotHost;
|
||||
import appeng.container.slot.SlotPatternOutputs;
|
||||
import appeng.container.slot.SlotRestrictedInput;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketVirtualSlot;
|
||||
import appeng.helpers.IVirtualSlotHolder;
|
||||
import appeng.helpers.IVirtualSlotSource;
|
||||
import appeng.items.storage.ItemBasicStorageCell;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.item.AEItemStack;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||
|
||||
public class ContainerSuperStockReplenisher extends AEBaseContainer implements IOptionalSlotHost {
|
||||
public class ContainerSuperStockReplenisher extends AEBaseContainer
|
||||
implements IOptionalSlotHost, IVirtualSlotHolder, IVirtualSlotSource {
|
||||
|
||||
private final TileSuperStockReplenisher tile;
|
||||
private final IInventory configFluids;
|
||||
@@ -151,4 +170,52 @@ public class ContainerSuperStockReplenisher extends AEBaseContainer implements I
|
||||
public TileSuperStockReplenisher getTile() {
|
||||
return tile;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PrimaryGui getPrimaryGui() {
|
||||
|
||||
ContainerOpenContext context = getOpenContext();
|
||||
return new FluidPrimaryGui(
|
||||
GuiType.GUI_SUPER_STOCK_REPLENISHER,
|
||||
ItemAndBlockHolder.SUPER_STOCK_RERPLENISHER.stack(),
|
||||
context.getTile(),
|
||||
context.getSide());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void receiveSlotStacks(StorageName invName, Int2ObjectMap<IAEStack<?>> slotStacks) {
|
||||
var entry = slotStacks.int2ObjectEntrySet().iterator().next();
|
||||
IAEStack<?> aes = entry.getValue();
|
||||
int slotIndex = entry.getIntKey();
|
||||
|
||||
if (Platform.isServer()) {
|
||||
for (ICrafting crafter : this.crafters) {
|
||||
final EntityPlayerMP emp = (EntityPlayerMP) crafter;
|
||||
NetworkHandler.instance.sendTo(new PacketVirtualSlot(invName, slotIndex, aes), emp);
|
||||
}
|
||||
} else {
|
||||
final GuiScreen gs = Minecraft.getMinecraft().currentScreen;
|
||||
if (gs instanceof GuiPatternValueAmount gpva) {
|
||||
gpva.update();
|
||||
} else if (gs instanceof GuiPatternItemRenamer gpir) {
|
||||
gpir.update();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateVirtualSlot(StorageName invName, int slotId, IAEStack<?> aes) {
|
||||
if (aes instanceof IAEItemStack ais) {
|
||||
ItemStack newIs;
|
||||
if (ais.getItem() instanceof ItemFluidPacket) {
|
||||
newIs = ais.getItemStack();
|
||||
newIs.stackSize = 1;
|
||||
ItemFluidPacket.setFluidAmount(newIs, aes.getStackSize());
|
||||
} else {
|
||||
newIs = ais.getItemStack();
|
||||
}
|
||||
this.inventorySlots.get(slotId).putStack(newIs);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,14 +3,12 @@ package com.glodblock.github.client.gui.container.base;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
|
||||
import com.glodblock.github.inventory.item.IFluidPortableCell;
|
||||
import com.glodblock.github.inventory.item.IWirelessExtendCard;
|
||||
import com.glodblock.github.inventory.item.WirelessMagnet;
|
||||
import com.glodblock.github.util.Util;
|
||||
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.container.guisync.GuiSync;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public abstract class FCBaseContainer extends AEBaseContainer {
|
||||
|
||||
@@ -62,13 +60,6 @@ public abstract class FCBaseContainer extends AEBaseContainer {
|
||||
this.getPowerMultiplier(),
|
||||
((IFluidPortableCell) this.host));
|
||||
}
|
||||
|
||||
if (Platform.isServer()) {
|
||||
if (this.host instanceof IWirelessExtendCard wec) {
|
||||
this.mode = wec.getMagnetCardMode();
|
||||
this.restock = wec.isRestock();
|
||||
}
|
||||
}
|
||||
super.detectAndSendChanges();
|
||||
}
|
||||
|
||||
|
||||
@@ -12,11 +12,9 @@ import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.event.ForgeEventFactory;
|
||||
import net.p455w0rd.wirelesscraftingterminal.helpers.WirelessTerminalGuiObject;
|
||||
|
||||
import com.glodblock.github.inventory.InventoryHandler;
|
||||
@@ -27,12 +25,9 @@ import com.glodblock.github.util.NameConst;
|
||||
import com.glodblock.github.util.UltraTerminalModes;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.features.ILocatable;
|
||||
import appeng.api.features.IWirelessTermHandler;
|
||||
import appeng.api.features.IWirelessTermRegistry;
|
||||
import appeng.api.implementations.guiobjects.IGuiItem;
|
||||
import appeng.api.implementations.guiobjects.IGuiItemObject;
|
||||
import appeng.core.localization.PlayerMessages;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.items.tools.powered.ToolWirelessTerminal;
|
||||
import appeng.util.Platform;
|
||||
@@ -44,7 +39,6 @@ public class ItemBaseWirelessTerminal extends ToolWirelessTerminal implements II
|
||||
protected Object type;
|
||||
public static String infinityBoosterCard = "infinityBoosterCard";
|
||||
public static String infinityEnergyCard = "InfinityEnergyCard";
|
||||
public static String restockItems = "restock";
|
||||
|
||||
public ItemBaseWirelessTerminal(Object t) {
|
||||
super();
|
||||
@@ -55,37 +49,7 @@ public class ItemBaseWirelessTerminal extends ToolWirelessTerminal implements II
|
||||
public ItemStack onItemRightClick(final ItemStack item, final World w, final EntityPlayer player) {
|
||||
if (player.isSneaking()) return removeInfinityBoosterCard(player, item); // todo: doesn't work in universal
|
||||
// terminal
|
||||
if (ForgeEventFactory.onItemUseStart(player, item, 1) > 0) {
|
||||
if (Platform.isClient()) return item;
|
||||
|
||||
IWirelessTermRegistry term = AEApi.instance().registries().wireless();
|
||||
if (!term.isWirelessTerminal(item)) {
|
||||
player.addChatMessage(PlayerMessages.DeviceNotWirelessTerminal.toChat());
|
||||
return item;
|
||||
}
|
||||
|
||||
final IWirelessTermHandler handler = term.getWirelessTerminalHandler(item);
|
||||
final String unparsedKey = handler.getEncryptionKey(item);
|
||||
if (unparsedKey.isEmpty()) {
|
||||
player.addChatMessage(PlayerMessages.DeviceNotLinked.toChat());
|
||||
return item;
|
||||
}
|
||||
|
||||
final long parsedKey = Long.parseLong(unparsedKey);
|
||||
final ILocatable securityStation = AEApi.instance().registries().locatable().getLocatableBy(parsedKey);
|
||||
if (securityStation == null) {
|
||||
player.addChatMessage(PlayerMessages.StationCanNotBeLocated.toChat());
|
||||
return item;
|
||||
}
|
||||
|
||||
if (handler.hasPower(player, 0.5, item)) {
|
||||
openGui(item, w, player);
|
||||
} else {
|
||||
player.addChatMessage(PlayerMessages.DeviceNotPowered.toChat());
|
||||
}
|
||||
}
|
||||
|
||||
return item;
|
||||
return super.onItemRightClick(item, w, player);
|
||||
}
|
||||
|
||||
private ItemStack removeInfinityBoosterCard(final EntityPlayer player, ItemStack is) {
|
||||
@@ -133,11 +97,6 @@ public class ItemBaseWirelessTerminal extends ToolWirelessTerminal implements II
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void toggleRestockItemsMode(ItemStack is, boolean state) {
|
||||
NBTTagCompound data = Platform.openNbtData(is);
|
||||
data.setBoolean(restockItems, state);
|
||||
}
|
||||
|
||||
public static UltraTerminalModes getMode(ItemStack is) {
|
||||
Item item = is.getItem();
|
||||
if (item instanceof ItemWirelessUltraTerminal) {
|
||||
@@ -157,23 +116,24 @@ public class ItemBaseWirelessTerminal extends ToolWirelessTerminal implements II
|
||||
is.getTagCompound().setInteger(MODE, utm.ordinal());
|
||||
}
|
||||
|
||||
public static void openGui(final ItemStack is, final World w, final EntityPlayer player) {
|
||||
@Override
|
||||
public void openGui(final ItemStack is, final World w, final EntityPlayer player, final Object mode) {
|
||||
final GuiBridge aeGui;
|
||||
switch (getMode(is)) {
|
||||
case CRAFTING -> aeGui = GuiBridge.GUI_CRAFTING_TERMINAL;
|
||||
case PATTERN -> aeGui = GuiBridge.GUI_PATTERN_TERMINAL;
|
||||
case PATTERN_EX -> aeGui = GuiBridge.GUI_PATTERN_TERMINAL_EX;
|
||||
case INTERFACE -> aeGui = GuiBridge.GUI_INTERFACE_TERMINAL;
|
||||
case LEVEL -> {
|
||||
InventoryHandler.openGui(
|
||||
player,
|
||||
w,
|
||||
new BlockPos(player.inventory.currentItem, 0, 0),
|
||||
ForgeDirection.UNKNOWN,
|
||||
GuiType.WIRELESS_LEVEL_TERMINAL);
|
||||
return;
|
||||
}
|
||||
default -> aeGui = GuiBridge.GUI_ME;
|
||||
Item item = is.getItem();
|
||||
if (item instanceof ItemWirelessPatternTerminal) {
|
||||
aeGui = GuiBridge.GUI_PATTERN_TERMINAL;
|
||||
} else if (item instanceof ItemWirelessInterfaceTerminal) {
|
||||
aeGui = GuiBridge.GUI_INTERFACE_TERMINAL;
|
||||
} else if (item instanceof ItemWirelessLevelTerminal) {
|
||||
InventoryHandler.openGui(
|
||||
player,
|
||||
w,
|
||||
new BlockPos(player.inventory.currentItem, 0, 0),
|
||||
ForgeDirection.UNKNOWN,
|
||||
GuiType.WIRELESS_LEVEL_TERMINAL);
|
||||
return;
|
||||
} else {
|
||||
aeGui = GuiBridge.GUI_INTERFACE_TERMINAL; // any wireless gui object will fit
|
||||
}
|
||||
Platform.openGUI(player, null, null, aeGui);
|
||||
}
|
||||
|
||||
@@ -21,7 +21,6 @@ import com.glodblock.github.common.storage.IStorageFluidCell;
|
||||
import com.glodblock.github.common.tabs.FluidCraftingTabs;
|
||||
import com.glodblock.github.inventory.FluidCellConfig;
|
||||
import com.glodblock.github.inventory.item.IItemInventory;
|
||||
import com.glodblock.github.inventory.item.PortableFluidCellInventory;
|
||||
import com.glodblock.github.loader.IRegister;
|
||||
import com.glodblock.github.util.NameConst;
|
||||
import com.glodblock.github.util.RenderUtil;
|
||||
@@ -184,7 +183,7 @@ public class ItemPortableFluidCell extends AEBasePoweredItem
|
||||
|
||||
@Override
|
||||
public Object getInventory(ItemStack stack, World world, int x, int y, int z, EntityPlayer player) {
|
||||
return new PortableFluidCellInventory(stack, x);
|
||||
return null;// new PortableFluidCellInventory(stack, x);
|
||||
}
|
||||
|
||||
public ItemStack stack() {
|
||||
|
||||
@@ -14,16 +14,20 @@ import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import org.apache.commons.lang3.tuple.ImmutablePair;
|
||||
|
||||
import com.glodblock.github.FluidCraft;
|
||||
import com.glodblock.github.common.tabs.FluidCraftingTabs;
|
||||
import com.glodblock.github.inventory.InventoryHandler;
|
||||
import com.glodblock.github.inventory.UltraTerminalButtons;
|
||||
import com.glodblock.github.inventory.gui.GuiType;
|
||||
import com.glodblock.github.inventory.item.WirelessLevelTerminalInventory;
|
||||
import com.glodblock.github.inventory.item.WirelessMagnet;
|
||||
import com.glodblock.github.inventory.item.WirelessMagnetCardFilterInventory;
|
||||
import com.glodblock.github.loader.IRegister;
|
||||
import com.glodblock.github.network.CPacketSwitchGuis;
|
||||
import com.glodblock.github.util.BlockPos;
|
||||
import com.glodblock.github.util.NameConst;
|
||||
import com.glodblock.github.util.UltraTerminalModes;
|
||||
import com.glodblock.github.util.Util;
|
||||
@@ -33,8 +37,13 @@ import appeng.api.features.IWirelessTermHandler;
|
||||
import appeng.api.implementations.guiobjects.IGuiItem;
|
||||
import appeng.api.implementations.guiobjects.IGuiItemObject;
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.core.localization.PlayerMessages;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.helpers.ICustomButtonDataObject;
|
||||
import appeng.helpers.ICustomButtonProvider;
|
||||
import appeng.helpers.ICustomButtonSource;
|
||||
import appeng.helpers.WirelessCraftingTerminalGuiObject;
|
||||
import appeng.helpers.WirelessInterfaceTerminalGuiObject;
|
||||
import appeng.helpers.WirelessPatternTerminalGuiObject;
|
||||
@@ -45,7 +54,7 @@ import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class ItemWirelessUltraTerminal extends ItemBaseWirelessTerminal
|
||||
implements IRegister<ItemWirelessUltraTerminal>, IGuiItem {
|
||||
implements IRegister<ItemWirelessUltraTerminal>, IGuiItem, ICustomButtonSource {
|
||||
|
||||
public final static String MODE = "mode";
|
||||
|
||||
@@ -94,7 +103,7 @@ public class ItemWirelessUltraTerminal extends ItemBaseWirelessTerminal
|
||||
return new WirelessMagnetCardFilterInventory(stack, x, gridNode, player);
|
||||
}
|
||||
|
||||
if (getMode(stack) == UltraTerminalModes.LEVEL) {
|
||||
if (z != 0 ? z == UltraTerminalModes.LEVEL.ordinal() : getMode(stack) == UltraTerminalModes.LEVEL) {
|
||||
return new WirelessLevelTerminalInventory(stack, x, gridNode, player);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
@@ -112,19 +121,39 @@ public class ItemWirelessUltraTerminal extends ItemBaseWirelessTerminal
|
||||
return super.onItemRightClick(is, w, player);
|
||||
}
|
||||
|
||||
public static void switchTerminal(EntityPlayer player, UltraTerminalModes mode) {
|
||||
ImmutablePair<Integer, ItemStack> temp = Util.getUltraWirelessTerm(player);
|
||||
if (temp == null) return;
|
||||
ItemStack term = temp.getRight();
|
||||
public void switchTerminal(EntityPlayer player, ItemStack term, UltraTerminalModes mode) {
|
||||
if (term != null && term.getItem() instanceof ItemWirelessUltraTerminal) {
|
||||
if (mode != null) setMode(term, mode);
|
||||
else mode = getMode(term);
|
||||
|
||||
if (Platform.isClient()) FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(mode, true));
|
||||
else openGui(term, player.worldObj, player);
|
||||
openGui(term, player.worldObj, player, mode);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openGui(final ItemStack is, final World w, final EntityPlayer player, final Object mode) {
|
||||
final GuiBridge aeGui;
|
||||
switch (mode instanceof UltraTerminalModes utm ? utm : getMode(is)) {
|
||||
case CRAFTING -> aeGui = GuiBridge.GUI_CRAFTING_TERMINAL;
|
||||
case PATTERN -> aeGui = GuiBridge.GUI_PATTERN_TERMINAL;
|
||||
case PATTERN_EX -> aeGui = GuiBridge.GUI_PATTERN_TERMINAL_EX;
|
||||
case INTERFACE -> aeGui = GuiBridge.GUI_INTERFACE_TERMINAL;
|
||||
case LEVEL -> {
|
||||
InventoryHandler.openGui(
|
||||
player,
|
||||
w,
|
||||
new BlockPos(
|
||||
player.inventory.currentItem,
|
||||
0,
|
||||
player.openContainer instanceof AEBaseContainer abc ? abc.getSwitchAbleGuiNext() : 0),
|
||||
ForgeDirection.UNKNOWN,
|
||||
GuiType.WIRELESS_LEVEL_TERMINAL);
|
||||
return;
|
||||
}
|
||||
default -> aeGui = GuiBridge.GUI_ME;
|
||||
}
|
||||
Platform.openGUI(player, null, null, aeGui);
|
||||
}
|
||||
|
||||
public static boolean hasInfinityBoosterCard(EntityPlayer player) {
|
||||
ImmutablePair<Integer, ItemStack> term = Util.getUltraWirelessTerm(player);
|
||||
if (term == null) return false;
|
||||
@@ -166,11 +195,16 @@ public class ItemWirelessUltraTerminal extends ItemBaseWirelessTerminal
|
||||
public IGuiItemObject getGuiObject(ItemStack is, World world, EntityPlayer p, int x, int y, int z) {
|
||||
final IWirelessTermHandler wh = AEApi.instance().registries().wireless().getWirelessTerminalHandler(is);
|
||||
if (wh == null) return null;
|
||||
return switch (getMode(is)) {
|
||||
return switch (y != -1 ? UltraTerminalModes.values()[y] : getMode(is)) {
|
||||
case CRAFTING -> new WirelessCraftingTerminalGuiObject(wh, is, p, world, x, y, z);
|
||||
case PATTERN, PATTERN_EX -> new WirelessPatternTerminalGuiObject(wh, is, p, world, x, y, z);
|
||||
case INTERFACE -> new WirelessInterfaceTerminalGuiObject(wh, is);
|
||||
default -> super.getGuiObject(is, world, p, x, y, z);
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICustomButtonDataObject getCustomDataObject(ICustomButtonProvider provider) {
|
||||
return new UltraTerminalButtons();
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.glodblock.github.common.parts;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
@@ -20,6 +21,9 @@ import com.glodblock.github.api.registries.ILevelViewable;
|
||||
import com.glodblock.github.api.registries.LevelItemInfo;
|
||||
import com.glodblock.github.api.registries.LevelState;
|
||||
import com.glodblock.github.common.item.ItemFluidPacket;
|
||||
import com.glodblock.github.inventory.InventoryHandler;
|
||||
import com.glodblock.github.inventory.gui.GuiType;
|
||||
import com.glodblock.github.util.BlockPos;
|
||||
import com.glodblock.github.util.Util;
|
||||
|
||||
import appeng.api.config.RedstoneMode;
|
||||
@@ -516,10 +520,14 @@ public class PartFluidLevelEmitter extends PartUpgradeable
|
||||
if (!player.isSneaking()) {
|
||||
if (Platform.isClient()) {
|
||||
return true;
|
||||
} /*
|
||||
* InventoryHandler.openGui( player, this.getHost().getTile().getWorldObj(), new
|
||||
* BlockPos(this.getHost().getTile()), Objects.requireNonNull(getSide()), GuiType.FLUID_LEVEL_EMITTER);
|
||||
*/
|
||||
}
|
||||
InventoryHandler.openGui(
|
||||
player,
|
||||
this.getHost().getTile().getWorldObj(),
|
||||
new BlockPos(this.getHost().getTile()),
|
||||
Objects.requireNonNull(getSide()),
|
||||
GuiType.FLUID_LEVEL_EMITTER);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,22 +1,13 @@
|
||||
package com.glodblock.github.common.parts;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
import com.glodblock.github.client.textures.FCPartsTexture;
|
||||
import com.glodblock.github.common.item.ItemFluidDrop;
|
||||
import com.glodblock.github.common.item.ItemFluidPacket;
|
||||
import com.glodblock.github.common.parts.base.FCFluidEncodeTerminal;
|
||||
import com.glodblock.github.common.parts.base.FCPart;
|
||||
|
||||
import appeng.api.implementations.ICraftingPatternItem;
|
||||
import appeng.api.networking.crafting.ICraftingPatternDetails;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.tile.inventory.BiggerAppEngInventory;
|
||||
import appeng.tile.inventory.InvOperation;
|
||||
|
||||
public class PartFluidPatternTerminal extends FCFluidEncodeTerminal {
|
||||
public class PartFluidPatternTerminal extends FCPart {
|
||||
|
||||
private static final FCPartsTexture FRONT_BRIGHT_ICON = FCPartsTexture.PartFluidPatternTerminal_Bright;
|
||||
private static final FCPartsTexture FRONT_DARK_ICON = FCPartsTexture.PartFluidPatternTerminal_Colored;
|
||||
@@ -24,119 +15,11 @@ public class PartFluidPatternTerminal extends FCFluidEncodeTerminal {
|
||||
|
||||
public PartFluidPatternTerminal(ItemStack is) {
|
||||
super(is);
|
||||
this.crafting = new BiggerAppEngInventory(this, 9);
|
||||
this.output = new BiggerAppEngInventory(this, 3);
|
||||
this.prioritize = false;
|
||||
this.inverted = false;
|
||||
this.activePage = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GuiBridge getGui() {
|
||||
return GuiBridge.GUI_PATTERN_TERMINAL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChangeInventory(final IInventory inv, final int slot, final InvOperation mc,
|
||||
final ItemStack removedStack, final ItemStack newStack) {
|
||||
if (inv == this.pattern && slot == 1) {
|
||||
final ItemStack is = inv.getStackInSlot(1);
|
||||
if (is != null && is.getItem() instanceof final ICraftingPatternItem craftingPatternItem) {
|
||||
final ICraftingPatternDetails details = craftingPatternItem
|
||||
.getPatternForItem(is, this.getHost().getTile().getWorldObj());
|
||||
if (details != null) {
|
||||
final IAEItemStack[] inItems = details.getInputs();
|
||||
final IAEItemStack[] outItems = details.getOutputs();
|
||||
|
||||
this.setCraftingRecipe(details.isCraftable());
|
||||
this.setSubstitution(details.canSubstitute());
|
||||
if (newStack != null) {
|
||||
NBTTagCompound data = newStack.getTagCompound();
|
||||
this.setCombineMode(data.getInteger("combine") == 1);
|
||||
this.setBeSubstitute(details.canBeSubstitute());
|
||||
}
|
||||
for (int i = 0; i < this.crafting.getSizeInventory(); i++) {
|
||||
this.crafting.setInventorySlotContents(i, null);
|
||||
}
|
||||
|
||||
for (int i = 0; i < this.output.getSizeInventory(); i++) {
|
||||
this.output.setInventorySlotContents(i, null);
|
||||
}
|
||||
|
||||
for (int i = 0; i < this.crafting.getSizeInventory() && i < inItems.length; i++) {
|
||||
if (inItems[i] != null) {
|
||||
final IAEItemStack item = inItems[i];
|
||||
if (item != null && item.getItem() instanceof ItemFluidDrop) {
|
||||
ItemStack packet = ItemFluidPacket
|
||||
.newStack(ItemFluidDrop.getFluidStack(item.getItemStack()));
|
||||
this.crafting.setInventorySlotContents(i, packet);
|
||||
} else this.crafting.setInventorySlotContents(i, item == null ? null : item.getItemStack());
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < this.output.getSizeInventory() && i < outItems.length; i++) {
|
||||
if (outItems[i] != null) {
|
||||
final IAEItemStack item = outItems[i];
|
||||
if (item != null && item.getItem() instanceof ItemFluidDrop) {
|
||||
ItemStack packet = ItemFluidPacket
|
||||
.newStack(ItemFluidDrop.getFluidStack(item.getItemStack()));
|
||||
this.output.setInventorySlotContents(i, packet);
|
||||
} else this.output.setInventorySlotContents(i, item == null ? null : item.getItemStack());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (inv == this.crafting) {
|
||||
this.fixCraftingRecipes();
|
||||
}
|
||||
this.getHost().markForSave();
|
||||
}
|
||||
|
||||
private void fixCraftingRecipes() {
|
||||
if (this.craftingMode) {
|
||||
for (int x = 0; x < this.crafting.getSizeInventory(); x++) {
|
||||
final ItemStack is = this.crafting.getStackInSlot(x);
|
||||
if (is != null) {
|
||||
is.stackSize = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setCraftingRecipe(final boolean craftingMode) {
|
||||
super.setCraftingRecipe(craftingMode);
|
||||
this.fixCraftingRecipes();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPrioritization(boolean canPrioritize) {
|
||||
this.prioritize = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPrioritize() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInverted() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInverted(boolean inverted) {
|
||||
this.inverted = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getActivePage() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setActivePage(int activePage) {
|
||||
this.activePage = 0;
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,22 +1,13 @@
|
||||
package com.glodblock.github.common.parts;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
import com.glodblock.github.client.textures.FCPartsTexture;
|
||||
import com.glodblock.github.common.item.ItemFluidDrop;
|
||||
import com.glodblock.github.common.item.ItemFluidPacket;
|
||||
import com.glodblock.github.common.parts.base.FCFluidEncodeTerminal;
|
||||
import com.glodblock.github.common.parts.base.FCPart;
|
||||
|
||||
import appeng.api.implementations.ICraftingPatternItem;
|
||||
import appeng.api.networking.crafting.ICraftingPatternDetails;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.tile.inventory.BiggerAppEngInventory;
|
||||
import appeng.tile.inventory.InvOperation;
|
||||
|
||||
public class PartFluidPatternTerminalEx extends FCFluidEncodeTerminal {
|
||||
public class PartFluidPatternTerminalEx extends FCPart {
|
||||
|
||||
private static final FCPartsTexture FRONT_BRIGHT_ICON = FCPartsTexture.PartFluidPatternTerminal_Bright;
|
||||
private static final FCPartsTexture FRONT_DARK_ICON = FCPartsTexture.PartFluidPatternTerminal_Colored;
|
||||
@@ -24,9 +15,6 @@ public class PartFluidPatternTerminalEx extends FCFluidEncodeTerminal {
|
||||
|
||||
public PartFluidPatternTerminalEx(ItemStack is) {
|
||||
super(is);
|
||||
this.crafting = new BiggerAppEngInventory(this, 32);
|
||||
this.output = new BiggerAppEngInventory(this, 32);
|
||||
this.craftingMode = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -34,99 +22,6 @@ public class PartFluidPatternTerminalEx extends FCFluidEncodeTerminal {
|
||||
return GuiBridge.GUI_ME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChangeInventory(final IInventory inv, final int slot, final InvOperation mc,
|
||||
final ItemStack removedStack, final ItemStack newStack) {
|
||||
if (inv == this.pattern && slot == 1) {
|
||||
final ItemStack is = inv.getStackInSlot(1);
|
||||
|
||||
if (is != null && is.getItem() instanceof final ICraftingPatternItem craftingPatternItem) {
|
||||
final ICraftingPatternDetails details = craftingPatternItem
|
||||
.getPatternForItem(is, this.getHost().getTile().getWorldObj());
|
||||
|
||||
if (details != null) {
|
||||
final IAEItemStack[] inItems = details.getInputs();
|
||||
final IAEItemStack[] outItems = details.getOutputs();
|
||||
int inputsCount = 0;
|
||||
int outputCount = 0;
|
||||
for (IAEItemStack inItem : inItems) {
|
||||
if (inItem != null) {
|
||||
inputsCount++;
|
||||
}
|
||||
}
|
||||
for (IAEItemStack outItem : outItems) {
|
||||
if (outItem != null) {
|
||||
outputCount++;
|
||||
}
|
||||
}
|
||||
|
||||
this.setSubstitution(details.canSubstitute());
|
||||
if (newStack != null) {
|
||||
NBTTagCompound data = newStack.getTagCompound();
|
||||
this.setCombineMode(data.getInteger("combine") == 1);
|
||||
this.setBeSubstitute(details.canBeSubstitute());
|
||||
}
|
||||
this.setInverted(inputsCount <= 8 && outputCount > 8);
|
||||
this.setActivePage(0);
|
||||
|
||||
for (int i = 0; i < this.crafting.getSizeInventory(); i++) {
|
||||
this.crafting.setInventorySlotContents(i, null);
|
||||
}
|
||||
|
||||
for (int i = 0; i < this.output.getSizeInventory(); i++) {
|
||||
this.output.setInventorySlotContents(i, null);
|
||||
}
|
||||
|
||||
for (int i = 0; i < this.crafting.getSizeInventory() && i < inItems.length; i++) {
|
||||
final IAEItemStack item = inItems[i];
|
||||
if (item != null) {
|
||||
if (item.getItem() instanceof ItemFluidDrop) {
|
||||
ItemStack packet = ItemFluidPacket
|
||||
.newStack(ItemFluidDrop.getFluidStack(item.getItemStack()));
|
||||
this.crafting.setInventorySlotContents(i, packet);
|
||||
} else this.crafting.setInventorySlotContents(i, item.getItemStack());
|
||||
}
|
||||
}
|
||||
|
||||
if (inverted) {
|
||||
for (int i = 0; i < this.output.getSizeInventory() && i < outItems.length; i++) {
|
||||
final IAEItemStack item = outItems[i];
|
||||
if (item != null) {
|
||||
if (item.getItem() instanceof ItemFluidDrop) {
|
||||
ItemStack packet = ItemFluidPacket
|
||||
.newStack(ItemFluidDrop.getFluidStack(item.getItemStack()));
|
||||
this.output.setInventorySlotContents(i, packet);
|
||||
} else this.output.setInventorySlotContents(i, item.getItemStack());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (int i = 0; i < outItems.length && i < 8; i++) {
|
||||
final IAEItemStack item = outItems[i];
|
||||
if (item != null) {
|
||||
if (item.getItem() instanceof ItemFluidDrop) {
|
||||
ItemStack packet = ItemFluidPacket
|
||||
.newStack(ItemFluidDrop.getFluidStack(item.getItemStack()));
|
||||
this.output.setInventorySlotContents(i >= 4 ? 12 + i : i, packet);
|
||||
} else this.output.setInventorySlotContents(i >= 4 ? 12 + i : i, item.getItemStack());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
this.getHost().markForSave();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCraftingRecipe(final boolean craftingMode) {
|
||||
this.craftingMode = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCraftingRecipe() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FCPartsTexture getFrontBright() {
|
||||
return FRONT_BRIGHT_ICON;
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.glodblock.github.common.parts;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
@@ -17,7 +18,9 @@ import net.minecraft.util.Vec3;
|
||||
|
||||
import com.glodblock.github.client.textures.FCPartsTexture;
|
||||
import com.glodblock.github.common.item.ItemFluidPacket;
|
||||
import com.glodblock.github.inventory.InventoryHandler;
|
||||
import com.glodblock.github.inventory.MEMonitorIFluidHandler;
|
||||
import com.glodblock.github.inventory.gui.GuiType;
|
||||
import com.glodblock.github.util.BlockPos;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
@@ -315,11 +318,14 @@ public class PartFluidStorageBus extends PartUpgradeable
|
||||
if (player.isSneaking()) {
|
||||
return false;
|
||||
}
|
||||
if (Platform.isServer()) {/*
|
||||
* InventoryHandler.openGui( player, this.getHost().getTile().getWorldObj(), new
|
||||
* BlockPos(this.getHost().getTile()), Objects.requireNonNull(this.getSide()),
|
||||
* GuiType.FLUID_STORAGE_BUS);
|
||||
*/
|
||||
if (Platform.isServer()) {
|
||||
InventoryHandler.openGui(
|
||||
player,
|
||||
this.getHost().getTile().getWorldObj(),
|
||||
new BlockPos(this.getHost().getTile()),
|
||||
Objects.requireNonNull(this.getSide()),
|
||||
GuiType.FLUID_STORAGE_BUS);
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1,240 +0,0 @@
|
||||
package com.glodblock.github.common.parts.base;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
import com.glodblock.github.common.item.ItemFluidPacket;
|
||||
import com.glodblock.github.inventory.item.IItemPatternTerminal;
|
||||
|
||||
import appeng.api.networking.IGrid;
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
import appeng.api.storage.ITerminalPins;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.items.contents.PinsHandler;
|
||||
import appeng.items.contents.PinsHolder;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
|
||||
public abstract class FCFluidEncodeTerminal extends FCPart
|
||||
implements IItemPatternTerminal, ITerminalPins, ITerminalHost {
|
||||
|
||||
protected AppEngInternalInventory crafting;
|
||||
protected AppEngInternalInventory output;
|
||||
protected final AppEngInternalInventory pattern = new AppEngInternalInventory(this, 2);
|
||||
private final PinsHolder pinsInv = new PinsHolder(this);
|
||||
|
||||
protected boolean craftingMode = true;
|
||||
protected boolean substitute = false;
|
||||
protected boolean combine = false;
|
||||
protected boolean prioritize = false;
|
||||
protected boolean inverted = false;
|
||||
protected boolean beSubstitute = false;
|
||||
protected boolean autoFillPattern = false;
|
||||
protected int activePage = 0;
|
||||
|
||||
public FCFluidEncodeTerminal(ItemStack is) {
|
||||
super(is, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getDrops(final List<ItemStack> drops, final boolean wrenched) {
|
||||
super.getDrops(drops, wrenched);
|
||||
for (final ItemStack is : this.pattern) {
|
||||
if (is != null) {
|
||||
drops.add(is);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(final NBTTagCompound data) {
|
||||
super.readFromNBT(data);
|
||||
this.setCraftingRecipe(data.getBoolean("craftingMode"));
|
||||
this.setSubstitution(data.getBoolean("substitute"));
|
||||
this.setCombineMode(data.getBoolean("combine"));
|
||||
this.setBeSubstitute(data.getBoolean("beSubstitute"));
|
||||
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");
|
||||
pinsInv.readFromNBT(data, "pins");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(final NBTTagCompound data) {
|
||||
super.writeToNBT(data);
|
||||
data.setBoolean("craftingMode", this.craftingMode);
|
||||
data.setBoolean("combine", this.combine);
|
||||
data.setBoolean("beSubstitute", this.beSubstitute);
|
||||
data.setBoolean("priorization", this.prioritize);
|
||||
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");
|
||||
pinsInv.writeToNBT(data, "pins");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldCombine() {
|
||||
return this.combine;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCombineMode(boolean shouldCombine) {
|
||||
this.combine = shouldCombine;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSubstitution() {
|
||||
return this.substitute;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPrioritize() {
|
||||
return this.prioritize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBeSubstitute(boolean canBeSubstitute) {
|
||||
this.beSubstitute = canBeSubstitute;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeSubstitute() {
|
||||
return this.beSubstitute;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSubstitution(boolean canSubstitute) {
|
||||
this.substitute = canSubstitute;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPrioritization(boolean canPrioritize) {
|
||||
this.prioritize = canPrioritize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInverted() {
|
||||
return inverted;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInverted(boolean inverted) {
|
||||
this.inverted = inverted;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getActivePage() {
|
||||
return this.activePage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setActivePage(int activePage) {
|
||||
this.activePage = activePage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCraftingRecipe(final boolean craftingMode) {
|
||||
this.craftingMode = craftingMode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCraftingRecipe() {
|
||||
return this.craftingMode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChangeCrafting(IAEItemStack[] newCrafting, IAEItemStack[] newOutput) {
|
||||
IInventory crafting = this.getInventoryByName("crafting");
|
||||
IInventory output = this.getInventoryByName("output");
|
||||
if (crafting instanceof AppEngInternalInventory && output instanceof AppEngInternalInventory) {
|
||||
for (int x = 0; x < crafting.getSizeInventory() && x < newCrafting.length; x++) {
|
||||
final IAEItemStack item = newCrafting[x];
|
||||
crafting.setInventorySlotContents(x, item == null ? null : item.getItemStack());
|
||||
}
|
||||
for (int x = 0; x < output.getSizeInventory() && x < newOutput.length; x++) {
|
||||
final IAEItemStack item = newOutput[x];
|
||||
output.setInventorySlotContents(x, item == null ? null : item.getItemStack());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInventory getInventoryByName(final String name) {
|
||||
if (name.equals("crafting")) {
|
||||
return this.crafting;
|
||||
}
|
||||
|
||||
if (name.equals("output")) {
|
||||
return this.output;
|
||||
}
|
||||
|
||||
if (name.equals("pattern")) {
|
||||
return this.pattern;
|
||||
}
|
||||
|
||||
return super.getInventoryByName(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sortCraftingItems() {
|
||||
List<ItemStack> items = new ArrayList<>();
|
||||
List<ItemStack> fluids = new ArrayList<>();
|
||||
for (ItemStack is : this.crafting) {
|
||||
if (is == null) continue;
|
||||
if (is.getItem() instanceof ItemFluidPacket) {
|
||||
fluids.add(is);
|
||||
} else {
|
||||
items.add(is);
|
||||
}
|
||||
}
|
||||
if (this.prioritize) {
|
||||
fluids.addAll(items);
|
||||
items.clear();
|
||||
} else {
|
||||
items.addAll(fluids);
|
||||
fluids.clear();
|
||||
}
|
||||
|
||||
for (int i = 0; i < this.crafting.getSizeInventory(); i++) {
|
||||
if (this.crafting.getStackInSlot(i) == null) break;
|
||||
if (items.isEmpty()) {
|
||||
this.crafting.setInventorySlotContents(i, fluids.get(i));
|
||||
} else {
|
||||
this.crafting.setInventorySlotContents(i, items.get(i));
|
||||
}
|
||||
}
|
||||
saveChanges();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAutoFillPattern() {
|
||||
return this.autoFillPattern;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAutoFillPattern(boolean canFill) {
|
||||
this.autoFillPattern = canFill;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PinsHandler getPinsHandler(EntityPlayer player) {
|
||||
return pinsInv.getHandler(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IGrid getGrid() {
|
||||
return getGridNode().getGrid();
|
||||
}
|
||||
}
|
||||
@@ -34,10 +34,13 @@ import appeng.api.networking.security.MachineSource;
|
||||
import appeng.api.networking.ticking.IGridTickable;
|
||||
import appeng.api.networking.ticking.TickRateModulation;
|
||||
import appeng.api.networking.ticking.TickingRequest;
|
||||
import appeng.api.storage.IMEMonitor;
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.util.AECableType;
|
||||
import appeng.api.util.DimensionalCoord;
|
||||
import appeng.api.util.IConfigManager;
|
||||
import appeng.core.AELog;
|
||||
import appeng.items.storage.ItemBasicStorageCell;
|
||||
import appeng.me.GridAccessException;
|
||||
@@ -52,7 +55,7 @@ import appeng.util.item.AEItemStack;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
public class TileSuperStockReplenisher extends AENetworkInvTile
|
||||
implements IAEFluidInventory, IFluidHandler, IPowerChannelState, IGridTickable {
|
||||
implements IAEFluidInventory, IFluidHandler, IPowerChannelState, IGridTickable, ITerminalHost {
|
||||
|
||||
private final AppEngInternalInventory cell = new AppEngInternalInventory(this, 1);
|
||||
private final AppEngInternalInventory invItems = new AppEngInternalInventory(this, 63);
|
||||
@@ -460,4 +463,19 @@ public class TileSuperStockReplenisher extends AENetworkInvTile
|
||||
public TickRateModulation tickingRequest(IGridNode node, int TicksSinceLastCall) {
|
||||
return doWork();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMEMonitor<IAEItemStack> getItemInventory() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMEMonitor<IAEFluidStack> getFluidInventory() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IConfigManager getConfigManager() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,232 @@
|
||||
package com.glodblock.github.inventory;
|
||||
|
||||
import static appeng.util.Platform.nextEnum;
|
||||
import static com.glodblock.github.common.item.ItemWirelessUltraTerminal.MODE;
|
||||
import static com.glodblock.github.inventory.item.WirelessMagnet.modeKey;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
import com.glodblock.github.FluidCraft;
|
||||
import com.glodblock.github.client.gui.GuiFCImgButton;
|
||||
import com.glodblock.github.inventory.item.WirelessMagnet;
|
||||
import com.glodblock.github.network.CPacketFluidPatternTermBtns;
|
||||
import com.glodblock.github.network.CPacketSwitchGuis;
|
||||
import com.glodblock.github.util.UltraTerminalModes;
|
||||
|
||||
import appeng.helpers.ICustomButtonDataObject;
|
||||
import appeng.util.Platform;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
public class UltraTerminalButtons implements ICustomButtonDataObject {
|
||||
|
||||
public static String restockItems = "restock";
|
||||
|
||||
private GuiFCImgButton CraftingTerminal;
|
||||
private GuiFCImgButton PatternTerminal;
|
||||
private GuiFCImgButton InterfaceTerminal;
|
||||
private GuiFCImgButton LevelTerminal;
|
||||
private GuiFCImgButton PatternTerminalEx;
|
||||
|
||||
private GuiFCImgButton magnetOff;
|
||||
private GuiFCImgButton magnetInv;
|
||||
private GuiFCImgButton magnetME;
|
||||
|
||||
private GuiFCImgButton magnetFilter;
|
||||
|
||||
private GuiFCImgButton restockEnableBtn;
|
||||
private GuiFCImgButton restockDisableBtn;
|
||||
|
||||
private WirelessMagnet.Mode magnetMode;
|
||||
private boolean reStock;
|
||||
public UltraTerminalModes terminalMode;
|
||||
|
||||
private int offset;
|
||||
|
||||
public void initCustomButtons(int guiLeft, int guiTop, int xSize, int ySize, int xOffset, int yOffset,
|
||||
List<GuiButton> buttonList) {
|
||||
this.offset = yOffset;
|
||||
buttonList.add(
|
||||
this.magnetOff = new GuiFCImgButton(guiLeft + xSize - 17, guiTop + ySize - 65, "MAGNET_CARD", "OFF"));
|
||||
buttonList.add(
|
||||
this.magnetInv = new GuiFCImgButton(guiLeft + xSize - 17, guiTop + ySize - 65, "MAGNET_CARD", "INV"));
|
||||
buttonList.add(
|
||||
this.magnetME = new GuiFCImgButton(guiLeft + xSize - 17, guiTop + ySize - 65, "MAGNET_CARD", "ME"));
|
||||
|
||||
buttonList.add(
|
||||
this.magnetFilter = new GuiFCImgButton(
|
||||
guiLeft + xSize - 17,
|
||||
guiTop + ySize - 45,
|
||||
"MAGNET_CARD",
|
||||
"FILTER"));
|
||||
buttonList.add(
|
||||
this.restockEnableBtn = new GuiFCImgButton(
|
||||
guiLeft + xSize - 17,
|
||||
guiTop + ySize - 25,
|
||||
"RESTOCK",
|
||||
"ENABLE"));
|
||||
|
||||
buttonList.add(
|
||||
this.restockDisableBtn = new GuiFCImgButton(
|
||||
guiLeft + xSize - 17,
|
||||
guiTop + ySize - 25,
|
||||
"RESTOCK",
|
||||
"DISABLE"));
|
||||
|
||||
buttonList.add(this.CraftingTerminal = new GuiFCImgButton(guiLeft - 18, yOffset, "CRAFT_TEM", "YES"));
|
||||
|
||||
buttonList.add(this.PatternTerminal = new GuiFCImgButton(guiLeft - 18, yOffset, "PATTERN_TEM", "YES"));
|
||||
|
||||
buttonList.add(this.PatternTerminalEx = new GuiFCImgButton(guiLeft - 18, yOffset, "PATTERN_EX_TEM", "YES"));
|
||||
|
||||
buttonList.add(this.InterfaceTerminal = new GuiFCImgButton(guiLeft - 18, yOffset, "INTERFACE_TEM", "YES"));
|
||||
|
||||
buttonList.add(this.LevelTerminal = new GuiFCImgButton(guiLeft - 18, yOffset, "LEVEL_TEM", "YES"));
|
||||
|
||||
toggleSwitchButtons();
|
||||
toggleMagnetButtonsVisibility();
|
||||
toggleRestockVisibility();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean actionPerformedCustomButtons(final GuiButton btn) {
|
||||
if (btn instanceof GuiFCImgButton) {
|
||||
if (btn == this.CraftingTerminal) {
|
||||
FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(UltraTerminalModes.CRAFTING, true));
|
||||
} else if (btn == this.PatternTerminal) {
|
||||
FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(UltraTerminalModes.PATTERN, true));
|
||||
} else if (btn == this.InterfaceTerminal) {
|
||||
FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(UltraTerminalModes.INTERFACE, true));
|
||||
} else if (btn == this.LevelTerminal) {
|
||||
FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(UltraTerminalModes.LEVEL, true));
|
||||
} else if (btn == this.PatternTerminalEx) {
|
||||
FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(UltraTerminalModes.PATTERN_EX, true));
|
||||
}
|
||||
|
||||
if (btn == this.magnetOff || btn == this.magnetME || btn == this.magnetInv) {
|
||||
FluidCraft.proxy.netHandler.sendToServer(
|
||||
new CPacketFluidPatternTermBtns(
|
||||
CPacketFluidPatternTermBtns.Command.MAGNET_MODE,
|
||||
this.magnetMode.ordinal()));
|
||||
} else if (btn == this.magnetFilter) FluidCraft.proxy.netHandler.sendToServer(
|
||||
new CPacketFluidPatternTermBtns(CPacketFluidPatternTermBtns.Command.MAGNET_OPEN_FILTER, 0));
|
||||
else if (btn == this.restockDisableBtn || btn == this.restockEnableBtn) {
|
||||
FluidCraft.proxy.netHandler
|
||||
.sendToServer(new CPacketFluidPatternTermBtns(CPacketFluidPatternTermBtns.Command.RESTOCK, 1));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void toggleRestock() {
|
||||
this.reStock = !this.reStock;
|
||||
}
|
||||
|
||||
public void toggleRestockVisibility() {
|
||||
if (Platform.isClient()) {
|
||||
if (this.reStock) {
|
||||
this.restockEnableBtn.setVisibility(true);
|
||||
this.restockDisableBtn.setVisibility(false);
|
||||
} else {
|
||||
this.restockEnableBtn.setVisibility(false);
|
||||
this.restockDisableBtn.setVisibility(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void toggleMagnetMode() {
|
||||
this.magnetMode = nextEnum(this.magnetMode);
|
||||
}
|
||||
|
||||
public void toggleMagnetButtonsVisibility() {
|
||||
switch (this.magnetMode) {
|
||||
case Off -> {
|
||||
this.magnetME.setVisibility(false);
|
||||
this.magnetInv.setVisibility(false);
|
||||
this.magnetOff.setVisibility(true);
|
||||
}
|
||||
case ME -> {
|
||||
this.magnetME.setVisibility(true);
|
||||
this.magnetInv.setVisibility(false);
|
||||
this.magnetOff.setVisibility(false);
|
||||
}
|
||||
case Inv -> {
|
||||
this.magnetME.setVisibility(false);
|
||||
this.magnetInv.setVisibility(true);
|
||||
this.magnetOff.setVisibility(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void toggleSwitchButtons() {
|
||||
int offset = this.offset;
|
||||
|
||||
CraftingTerminal.setVisibility(false);
|
||||
PatternTerminal.setVisibility(false);
|
||||
InterfaceTerminal.setVisibility(false);
|
||||
LevelTerminal.setVisibility(false);
|
||||
PatternTerminalEx.setVisibility(false);
|
||||
|
||||
if (this.terminalMode != UltraTerminalModes.CRAFTING) {
|
||||
this.CraftingTerminal.setVisibility(true);
|
||||
this.CraftingTerminal.yPosition = offset;
|
||||
offset += 20;
|
||||
}
|
||||
if (this.terminalMode != UltraTerminalModes.PATTERN) {
|
||||
this.PatternTerminal.setVisibility(true);
|
||||
this.PatternTerminal.yPosition = offset;
|
||||
offset += 20;
|
||||
}
|
||||
if (this.terminalMode != UltraTerminalModes.PATTERN_EX) {
|
||||
this.PatternTerminalEx.setVisibility(true);
|
||||
this.PatternTerminalEx.yPosition = offset;
|
||||
offset += 20;
|
||||
}
|
||||
if (this.terminalMode != UltraTerminalModes.INTERFACE) {
|
||||
this.InterfaceTerminal.setVisibility(true);
|
||||
this.InterfaceTerminal.yPosition = offset;
|
||||
offset += 20;
|
||||
}
|
||||
if (this.terminalMode != UltraTerminalModes.LEVEL) {
|
||||
this.LevelTerminal.setVisibility(true);
|
||||
this.LevelTerminal.yPosition = offset;
|
||||
offset += 20;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readData(NBTTagCompound tag) {
|
||||
this.reStock = tag.getBoolean(restockItems);
|
||||
this.magnetMode = WirelessMagnet.Mode.values()[tag.getInteger(modeKey)];
|
||||
this.terminalMode = UltraTerminalModes.values()[tag.getInteger(MODE)];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeData(NBTTagCompound tag) {
|
||||
tag.setBoolean(restockItems, this.reStock);
|
||||
tag.setInteger(modeKey, this.magnetMode.ordinal());
|
||||
tag.setInteger(MODE, this.terminalMode.ordinal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readByte(ByteBuf buf) {
|
||||
this.reStock = buf.readBoolean();
|
||||
this.magnetMode = WirelessMagnet.Mode.values()[buf.readInt()];
|
||||
this.terminalMode = UltraTerminalModes.values()[buf.readInt()];
|
||||
|
||||
toggleMagnetButtonsVisibility();
|
||||
toggleRestockVisibility();
|
||||
toggleSwitchButtons();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeByte(ByteBuf buf) {
|
||||
buf.writeBoolean(this.reStock);
|
||||
buf.writeInt(this.magnetMode.ordinal());
|
||||
buf.writeInt(this.terminalMode.ordinal());
|
||||
}
|
||||
}
|
||||
-61
@@ -1,61 +0,0 @@
|
||||
package com.glodblock.github.inventory;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import com.glodblock.github.inventory.item.IWirelessPatternTerminal;
|
||||
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
import appeng.tile.inventory.InvOperation;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class WirelessFluidPatternTerminalPatterns extends AppEngInternalInventory {
|
||||
|
||||
private final ItemStack is;
|
||||
private final IWirelessPatternTerminal terminal;
|
||||
|
||||
public WirelessFluidPatternTerminalPatterns(final ItemStack is, final IWirelessPatternTerminal term) {
|
||||
super(null, 2);
|
||||
this.is = is;
|
||||
this.terminal = term;
|
||||
this.readFromNBT(Platform.openNbtData(is), "pattern");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markDirty() {
|
||||
this.writeToNBT(Platform.openNbtData(is), "pattern");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markDirty(int slotIndex) {
|
||||
this.markDirty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents(final int slot, final ItemStack newItemStack) {
|
||||
final ItemStack oldStack = this.inv[slot];
|
||||
this.inv[slot] = newItemStack;
|
||||
|
||||
if (this.eventsEnabled()) {
|
||||
ItemStack removed = oldStack;
|
||||
ItemStack added = newItemStack;
|
||||
|
||||
if (oldStack != null && newItemStack != null && Platform.isSameItemPrecise(oldStack, newItemStack)) {
|
||||
if (oldStack.stackSize > newItemStack.stackSize) {
|
||||
removed = removed.copy();
|
||||
removed.stackSize -= newItemStack.stackSize;
|
||||
added = null;
|
||||
} else if (oldStack.stackSize < newItemStack.stackSize) {
|
||||
added = added.copy();
|
||||
added.stackSize -= oldStack.stackSize;
|
||||
removed = null;
|
||||
} else {
|
||||
removed = added = null;
|
||||
}
|
||||
}
|
||||
this.terminal.onChangeInventory(this, slot, InvOperation.setInventorySlotContents, removed, added);
|
||||
}
|
||||
|
||||
this.markDirty();
|
||||
}
|
||||
}
|
||||
@@ -8,9 +8,12 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
|
||||
import com.glodblock.github.client.gui.GuiDualInterface;
|
||||
import com.glodblock.github.client.gui.GuiFluidAutoFiller;
|
||||
import com.glodblock.github.client.gui.GuiFluidIO;
|
||||
import com.glodblock.github.client.gui.GuiFluidInterface;
|
||||
import com.glodblock.github.client.gui.GuiFluidLevelEmitter;
|
||||
import com.glodblock.github.client.gui.GuiFluidPacketDecoder;
|
||||
import com.glodblock.github.client.gui.GuiFluidPatternEncoder;
|
||||
import com.glodblock.github.client.gui.GuiFluidStorageBus;
|
||||
import com.glodblock.github.client.gui.GuiIngredientBuffer;
|
||||
import com.glodblock.github.client.gui.GuiLargeIngredientBuffer;
|
||||
import com.glodblock.github.client.gui.GuiLevelMaintainer;
|
||||
@@ -21,9 +24,12 @@ import com.glodblock.github.client.gui.GuiOCPatternEditor;
|
||||
import com.glodblock.github.client.gui.GuiSuperStockReplenisher;
|
||||
import com.glodblock.github.client.gui.container.ContainerDualInterface;
|
||||
import com.glodblock.github.client.gui.container.ContainerFluidAutoFiller;
|
||||
import com.glodblock.github.client.gui.container.ContainerFluidIO;
|
||||
import com.glodblock.github.client.gui.container.ContainerFluidInterface;
|
||||
import com.glodblock.github.client.gui.container.ContainerFluidLevelEmitter;
|
||||
import com.glodblock.github.client.gui.container.ContainerFluidPacketDecoder;
|
||||
import com.glodblock.github.client.gui.container.ContainerFluidPatternEncoder;
|
||||
import com.glodblock.github.client.gui.container.ContainerFluidStorageBus;
|
||||
import com.glodblock.github.client.gui.container.ContainerIngredientBuffer;
|
||||
import com.glodblock.github.client.gui.container.ContainerLargeIngredientBuffer;
|
||||
import com.glodblock.github.client.gui.container.ContainerLevelMaintainer;
|
||||
@@ -32,6 +38,9 @@ import com.glodblock.github.client.gui.container.ContainerLevelWireless;
|
||||
import com.glodblock.github.client.gui.container.ContainerMagnetFilter;
|
||||
import com.glodblock.github.client.gui.container.ContainerOCPatternEditor;
|
||||
import com.glodblock.github.client.gui.container.ContainerSuperStockReplenisher;
|
||||
import com.glodblock.github.common.parts.PartFluidLevelEmitter;
|
||||
import com.glodblock.github.common.parts.PartFluidStorageBus;
|
||||
import com.glodblock.github.common.parts.base.FCSharedFluidBus;
|
||||
import com.glodblock.github.common.tile.TileFluidAutoFiller;
|
||||
import com.glodblock.github.common.tile.TileFluidPacketDecoder;
|
||||
import com.glodblock.github.common.tile.TileFluidPatternEncoder;
|
||||
@@ -62,6 +71,19 @@ public enum GuiType {
|
||||
}
|
||||
}),
|
||||
|
||||
FLUID_LEVEL_EMITTER(new PartGuiFactory<>(PartFluidLevelEmitter.class) {
|
||||
|
||||
@Override
|
||||
protected Object createServerGui(EntityPlayer player, PartFluidLevelEmitter inv) {
|
||||
return new ContainerFluidLevelEmitter(player.inventory, inv);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object createClientGui(EntityPlayer player, PartFluidLevelEmitter inv) {
|
||||
return new GuiFluidLevelEmitter(player.inventory, inv);
|
||||
}
|
||||
}),
|
||||
|
||||
LEVEL_MAINTAINER(new TileGuiFactory<>(TileLevelMaintainer.class) {
|
||||
|
||||
@Override
|
||||
@@ -114,6 +136,32 @@ public enum GuiType {
|
||||
}
|
||||
}),
|
||||
|
||||
FLUID_BUS_IO(new PartGuiFactory<>(FCSharedFluidBus.class) {
|
||||
|
||||
@Override
|
||||
protected Object createServerGui(EntityPlayer player, FCSharedFluidBus inv) {
|
||||
return new ContainerFluidIO(player.inventory, inv);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object createClientGui(EntityPlayer player, FCSharedFluidBus inv) {
|
||||
return new GuiFluidIO(player.inventory, inv);
|
||||
}
|
||||
}),
|
||||
|
||||
FLUID_STORAGE_BUS(new PartGuiFactory<>(PartFluidStorageBus.class) {
|
||||
|
||||
@Override
|
||||
protected Object createServerGui(EntityPlayer player, PartFluidStorageBus inv) {
|
||||
return new ContainerFluidStorageBus(player.inventory, inv);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object createClientGui(EntityPlayer player, PartFluidStorageBus inv) {
|
||||
return new GuiFluidStorageBus(player.inventory, inv);
|
||||
}
|
||||
}),
|
||||
|
||||
INGREDIENT_BUFFER(new TileGuiFactory<>(TileIngredientBuffer.class) {
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.glodblock.github.inventory.item;
|
||||
|
||||
import static com.glodblock.github.common.item.ItemBaseWirelessTerminal.restockItems;
|
||||
import static appeng.util.Platform.nextEnum;
|
||||
import static com.glodblock.github.inventory.UltraTerminalButtons.restockItems;
|
||||
import static com.glodblock.github.inventory.item.WirelessMagnet.modeKey;
|
||||
|
||||
import java.util.Objects;
|
||||
@@ -10,7 +11,6 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import com.glodblock.github.common.item.ItemBaseWirelessTerminal;
|
||||
import com.glodblock.github.util.Util;
|
||||
|
||||
import appeng.api.config.Actionable;
|
||||
@@ -33,8 +33,7 @@ import appeng.items.tools.powered.ToolWirelessTerminal;
|
||||
import appeng.me.storage.NullInventory;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public abstract class BaseWirelessInventory extends MEMonitorHandler
|
||||
implements IWirelessTerminal, IWirelessExtendCard, ITerminalPins {
|
||||
public abstract class BaseWirelessInventory extends MEMonitorHandler implements IWirelessTerminal, ITerminalPins {
|
||||
|
||||
protected final ItemStack target;
|
||||
protected final IAEItemPowerStorage ips;
|
||||
@@ -81,8 +80,8 @@ public abstract class BaseWirelessInventory extends MEMonitorHandler
|
||||
|
||||
private void readFromNBT() {
|
||||
NBTTagCompound data = Platform.openNbtData(this.target);
|
||||
this.setMagnetCardMode(WirelessMagnet.Mode.getModes()[data.getInteger(modeKey)]);
|
||||
this.setRestock(data.getBoolean(ItemBaseWirelessTerminal.restockItems));
|
||||
this.setMagnetCardMode(WirelessMagnet.Mode.values()[data.getInteger(modeKey)]);
|
||||
this.setRestock(data.getBoolean(restockItems));
|
||||
}
|
||||
|
||||
public StorageChannel getChannel() {
|
||||
@@ -131,24 +130,20 @@ public abstract class BaseWirelessInventory extends MEMonitorHandler
|
||||
return this.grid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlayerSource getActionSource() {
|
||||
return this.source;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMagnetCardMode(WirelessMagnet.Mode mode) {
|
||||
this.magnetMode = mode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WirelessMagnet.Mode getMagnetCardMode() {
|
||||
return this.magnetMode;
|
||||
}
|
||||
|
||||
public void setMagnetCardNextMode() {
|
||||
final WirelessMagnet.Mode[] MODES = WirelessMagnet.Mode.getModes();
|
||||
setMagnetCardMode(MODES[(getMagnetCardMode().ordinal() + 1) % MODES.length]);
|
||||
setMagnetCardMode(nextEnum(getMagnetCardMode()));
|
||||
}
|
||||
|
||||
public void setRestock(boolean val) {
|
||||
|
||||
@@ -1,42 +0,0 @@
|
||||
package com.glodblock.github.inventory.item;
|
||||
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
|
||||
public interface IItemPatternTerminal extends IItemTerminal {
|
||||
|
||||
boolean isInverted();
|
||||
|
||||
boolean canBeSubstitute();
|
||||
|
||||
boolean isPrioritize();
|
||||
|
||||
boolean isSubstitution();
|
||||
|
||||
boolean shouldCombine();
|
||||
|
||||
void onChangeCrafting(IAEItemStack[] newCrafting, IAEItemStack[] newOutput);
|
||||
|
||||
void setCraftingRecipe(final boolean craftingMode);
|
||||
|
||||
void setSubstitution(boolean canSubstitute);
|
||||
|
||||
void setBeSubstitute(boolean canBeSubstitute);
|
||||
|
||||
void setCombineMode(boolean shouldCombine);
|
||||
|
||||
void setPrioritization(boolean canPrioritize);
|
||||
|
||||
void setInverted(boolean inverted);
|
||||
|
||||
int getActivePage();
|
||||
|
||||
void setActivePage(int activePage);
|
||||
|
||||
boolean isCraftingRecipe();
|
||||
|
||||
void sortCraftingItems();
|
||||
|
||||
boolean isAutoFillPattern();
|
||||
|
||||
void setAutoFillPattern(boolean canFill);
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
package com.glodblock.github.inventory.item;
|
||||
|
||||
public interface IWirelessCraftTerminal extends IWirelessTerminal, IItemTerminal {
|
||||
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
package com.glodblock.github.inventory.item;
|
||||
|
||||
import appeng.api.networking.security.PlayerSource;
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
|
||||
public interface IWirelessExtendCard {
|
||||
|
||||
default void setMagnetCardMode(WirelessMagnet.Mode mode) {}
|
||||
|
||||
WirelessMagnet.Mode getMagnetCardMode();
|
||||
|
||||
PlayerSource getActionSource();
|
||||
|
||||
IAEStack injectItems(IAEStack aeStack);
|
||||
|
||||
IAEStack extractItems(IAEStack aeStack);
|
||||
|
||||
default void setMagnetCardNextMode() {};
|
||||
|
||||
void setRestock(boolean val);
|
||||
|
||||
default boolean isRestock() {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -14,7 +14,7 @@ public interface IWirelessMagnetFilter extends IWirelessTerminal, IItemTerminal
|
||||
|
||||
String getOreDictFilter();
|
||||
|
||||
void setListMode(WirelessMagnet.ListMode mode);
|
||||
void setListMode(boolean mode);
|
||||
|
||||
void setNBTMode(boolean ignoreNBT);
|
||||
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
package com.glodblock.github.inventory.item;
|
||||
|
||||
public interface IWirelessPatternTerminal extends IWirelessTerminal, IItemPatternTerminal {
|
||||
|
||||
}
|
||||
@@ -1,79 +0,0 @@
|
||||
package com.glodblock.github.inventory.item;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
import com.glodblock.github.common.storage.FluidCellInventory;
|
||||
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.config.PowerMultiplier;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.config.SortDir;
|
||||
import appeng.api.config.SortOrder;
|
||||
import appeng.api.config.ViewItems;
|
||||
import appeng.api.implementations.items.IAEItemPowerStorage;
|
||||
import appeng.api.storage.IMEMonitor;
|
||||
import appeng.api.storage.MEMonitorHandler;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.util.IConfigManager;
|
||||
import appeng.util.ConfigManager;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class PortableFluidCellInventory extends MEMonitorHandler<IAEFluidStack> implements IFluidPortableCell {
|
||||
|
||||
private final ItemStack target;
|
||||
private final IAEItemPowerStorage ips;
|
||||
private final int inventorySlot;
|
||||
|
||||
public PortableFluidCellInventory(final ItemStack is, final int slot) {
|
||||
super(Objects.requireNonNull(FluidCellInventory.getCell(is, null)));
|
||||
this.ips = (IAEItemPowerStorage) is.getItem();
|
||||
this.target = is;
|
||||
this.inventorySlot = slot;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventorySlot() {
|
||||
return this.inventorySlot;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getItemStack() {
|
||||
return this.target;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double extractAEPower(double amt, final Actionable mode, final PowerMultiplier usePowerMultiplier) {
|
||||
amt = usePowerMultiplier.multiply(amt);
|
||||
if (mode == Actionable.SIMULATE) {
|
||||
return usePowerMultiplier.divide(Math.min(amt, this.ips.getAECurrentPower(this.target)));
|
||||
}
|
||||
return usePowerMultiplier.divide(this.ips.extractAEPower(this.target, amt));
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMEMonitor<IAEItemStack> getItemInventory() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMEMonitor<IAEFluidStack> getFluidInventory() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IConfigManager getConfigManager() {
|
||||
final ConfigManager out = new ConfigManager((manager, settingName, newValue) -> {
|
||||
final NBTTagCompound data = Platform.openNbtData(PortableFluidCellInventory.this.target);
|
||||
manager.writeToNBT(data);
|
||||
});
|
||||
out.registerSetting(Settings.SORT_BY, SortOrder.NAME);
|
||||
out.registerSetting(Settings.VIEW_MODE, ViewItems.ALL);
|
||||
out.registerSetting(Settings.SORT_DIRECTION, SortDir.ASCENDING);
|
||||
out.readFromNBT((NBTTagCompound) Platform.openNbtData(this.target).copy());
|
||||
return out;
|
||||
}
|
||||
}
|
||||
-154
@@ -1,154 +0,0 @@
|
||||
package com.glodblock.github.inventory.item;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import com.glodblock.github.inventory.ItemBiggerAppEngInventory;
|
||||
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.config.PowerMultiplier;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.config.SortDir;
|
||||
import appeng.api.config.SortOrder;
|
||||
import appeng.api.config.TypeFilter;
|
||||
import appeng.api.config.ViewItems;
|
||||
import appeng.api.implementations.items.IAEItemPowerStorage;
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.api.storage.IMEMonitor;
|
||||
import appeng.api.storage.StorageChannel;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.util.AECableType;
|
||||
import appeng.api.util.IConfigManager;
|
||||
import appeng.items.contents.WirelessTerminalViewCells;
|
||||
import appeng.items.tools.powered.ToolWirelessTerminal;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
import appeng.tile.inventory.InvOperation;
|
||||
import appeng.util.ConfigManager;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class WirelessCraftingTerminalInventory extends BaseWirelessInventory implements IWirelessCraftTerminal {
|
||||
|
||||
private final ItemStack target;
|
||||
private final IAEItemPowerStorage ips;
|
||||
private final int inventorySlot;
|
||||
private final AppEngInternalInventory viewCell;
|
||||
private final StorageChannel channel;
|
||||
private final IGridNode grid;
|
||||
|
||||
protected AppEngInternalInventory crafting;
|
||||
protected AppEngInternalInventory output;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public WirelessCraftingTerminalInventory(final ItemStack is, final int slot, IGridNode gridNode,
|
||||
EntityPlayer player) {
|
||||
super(is, slot, gridNode, player, StorageChannel.ITEMS);
|
||||
this.ips = (ToolWirelessTerminal) is.getItem();
|
||||
this.grid = gridNode;
|
||||
this.target = is;
|
||||
this.inventorySlot = slot;
|
||||
this.viewCell = new WirelessTerminalViewCells(is);
|
||||
this.channel = StorageChannel.ITEMS;
|
||||
this.crafting = new ItemBiggerAppEngInventory(is, "crafting_c", 9);
|
||||
this.output = new ItemBiggerAppEngInventory(is, "output_c", 3);
|
||||
}
|
||||
|
||||
public StorageChannel getChannel() {
|
||||
return this.channel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getItemStack() {
|
||||
return this.target;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double extractAEPower(double amt, Actionable mode, PowerMultiplier usePowerMultiplier) {
|
||||
amt = usePowerMultiplier.multiply(amt);
|
||||
if (mode == Actionable.SIMULATE) {
|
||||
return usePowerMultiplier.divide(Math.min(amt, this.ips.getAECurrentPower(this.target)));
|
||||
}
|
||||
return usePowerMultiplier.divide(this.ips.extractAEPower(this.target, amt));
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMEMonitor<IAEItemStack> getItemInventory() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMEMonitor<IAEFluidStack> getFluidInventory() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IConfigManager getConfigManager() {
|
||||
final ConfigManager out = new ConfigManager((manager, settingName, newValue) -> {
|
||||
final NBTTagCompound data = Platform.openNbtData(this.target);
|
||||
manager.writeToNBT(data);
|
||||
});
|
||||
out.registerSetting(Settings.SORT_BY, SortOrder.NAME);
|
||||
out.registerSetting(Settings.VIEW_MODE, ViewItems.ALL);
|
||||
out.registerSetting(Settings.SORT_DIRECTION, SortDir.ASCENDING);
|
||||
out.registerSetting(Settings.TYPE_FILTER, TypeFilter.ALL);
|
||||
out.readFromNBT((NBTTagCompound) Platform.openNbtData(this.target).copy());
|
||||
return out;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventorySlot() {
|
||||
return this.inventorySlot;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInventory getViewCellStorage() {
|
||||
return this.viewCell;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IGridNode getGridNode(ForgeDirection dir) {
|
||||
return this.grid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AECableType getCableConnectionType(ForgeDirection dir) {
|
||||
return AECableType.NONE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void securityBreak() {
|
||||
this.getGridNode(ForgeDirection.UNKNOWN).getMachine().securityBreak();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveChanges() {
|
||||
// NO-OP
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChangeInventory(IInventory inv, int slot, InvOperation mc, ItemStack removedStack,
|
||||
ItemStack newStack) {
|
||||
// NO-OP
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInventory getInventoryByName(String name) {
|
||||
if (name.equals("crafting")) {
|
||||
return this.crafting;
|
||||
}
|
||||
|
||||
if (name.equals("output")) {
|
||||
return this.output;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IGridNode getActionableNode() {
|
||||
return this.grid;
|
||||
}
|
||||
}
|
||||
-135
@@ -1,135 +0,0 @@
|
||||
package com.glodblock.github.inventory.item;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.config.PowerMultiplier;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.config.SortDir;
|
||||
import appeng.api.config.SortOrder;
|
||||
import appeng.api.config.ViewItems;
|
||||
import appeng.api.implementations.items.IAEItemPowerStorage;
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.api.storage.IMEMonitor;
|
||||
import appeng.api.storage.StorageChannel;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.util.AECableType;
|
||||
import appeng.api.util.IConfigManager;
|
||||
import appeng.items.contents.WirelessTerminalViewCells;
|
||||
import appeng.items.tools.powered.ToolWirelessTerminal;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
import appeng.tile.inventory.InvOperation;
|
||||
import appeng.util.ConfigManager;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class WirelessFluidTerminalInventory extends BaseWirelessInventory implements IWirelessTerminal, IItemTerminal {
|
||||
|
||||
private final ItemStack target;
|
||||
private final IAEItemPowerStorage ips;
|
||||
private final int inventorySlot;
|
||||
private final AppEngInternalInventory viewCell;
|
||||
private final StorageChannel channel;
|
||||
private final IGridNode grid;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public WirelessFluidTerminalInventory(final ItemStack is, final int slot, IGridNode gridNode, EntityPlayer player) {
|
||||
super(is, slot, gridNode, player, StorageChannel.FLUIDS);
|
||||
this.ips = (ToolWirelessTerminal) is.getItem();
|
||||
this.grid = gridNode;
|
||||
this.target = is;
|
||||
this.inventorySlot = slot;
|
||||
this.viewCell = new WirelessTerminalViewCells(is);
|
||||
this.channel = StorageChannel.FLUIDS;
|
||||
}
|
||||
|
||||
public StorageChannel getChannel() {
|
||||
return this.channel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getItemStack() {
|
||||
return this.target;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double extractAEPower(double amt, Actionable mode, PowerMultiplier usePowerMultiplier) {
|
||||
amt = usePowerMultiplier.multiply(amt);
|
||||
if (mode == Actionable.SIMULATE) {
|
||||
return usePowerMultiplier.divide(Math.min(amt, this.ips.getAECurrentPower(this.target)));
|
||||
}
|
||||
return usePowerMultiplier.divide(this.ips.extractAEPower(this.target, amt));
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMEMonitor<IAEItemStack> getItemInventory() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMEMonitor<IAEFluidStack> getFluidInventory() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IConfigManager getConfigManager() {
|
||||
final ConfigManager out = new ConfigManager((manager, settingName, newValue) -> {
|
||||
final NBTTagCompound data = Platform.openNbtData(this.target);
|
||||
manager.writeToNBT(data);
|
||||
});
|
||||
out.registerSetting(Settings.SORT_BY, SortOrder.NAME);
|
||||
out.registerSetting(Settings.VIEW_MODE, ViewItems.ALL);
|
||||
out.registerSetting(Settings.SORT_DIRECTION, SortDir.ASCENDING);
|
||||
out.readFromNBT((NBTTagCompound) Platform.openNbtData(this.target).copy());
|
||||
out.putSetting(Settings.VIEW_MODE, ViewItems.ALL);
|
||||
return out;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventorySlot() {
|
||||
return this.inventorySlot;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInventory getViewCellStorage() {
|
||||
return this.viewCell;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IGridNode getGridNode(ForgeDirection dir) {
|
||||
return this.grid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AECableType getCableConnectionType(ForgeDirection dir) {
|
||||
return AECableType.NONE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void securityBreak() {
|
||||
this.getGridNode(ForgeDirection.UNKNOWN).getMachine().securityBreak();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveChanges() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public IGridNode getActionableNode() {
|
||||
return this.grid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChangeInventory(IInventory inv, int slot, InvOperation mc, ItemStack removedStack,
|
||||
ItemStack newStack) {}
|
||||
|
||||
@Override
|
||||
public IInventory getInventoryByName(String name) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
-146
@@ -1,146 +0,0 @@
|
||||
package com.glodblock.github.inventory.item;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import com.glodblock.github.util.Util;
|
||||
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.config.PowerMultiplier;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.config.TerminalStyle;
|
||||
import appeng.api.implementations.items.IAEItemPowerStorage;
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.api.storage.IMEMonitor;
|
||||
import appeng.api.storage.StorageChannel;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.util.AECableType;
|
||||
import appeng.api.util.IConfigManager;
|
||||
import appeng.items.tools.powered.ToolWirelessTerminal;
|
||||
import appeng.tile.inventory.InvOperation;
|
||||
import appeng.util.ConfigManager;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class WirelessInterfaceTerminalInventory implements IClickableInTerminal, IWirelessTerminal {
|
||||
|
||||
private final ItemStack target;
|
||||
private final IAEItemPowerStorage ips;
|
||||
private final int inventorySlot;
|
||||
private final IGridNode grid;
|
||||
private Util.DimensionalCoordSide tile;
|
||||
|
||||
public WirelessInterfaceTerminalInventory(ItemStack is, int slot, IGridNode gridNode, EntityPlayer player) {
|
||||
Objects.requireNonNull(Util.getWirelessInv(is, player, StorageChannel.ITEMS));
|
||||
this.ips = (ToolWirelessTerminal) is.getItem();
|
||||
this.grid = gridNode;
|
||||
this.target = is;
|
||||
this.inventorySlot = slot;
|
||||
readFromNBT();
|
||||
}
|
||||
|
||||
public void readFromNBT() {
|
||||
NBTTagCompound data = Platform.openNbtData(this.target);
|
||||
if (data.hasKey("clickedInterface")) {
|
||||
NBTTagCompound tileMsg = (NBTTagCompound) data.getTag("clickedInterface");
|
||||
this.tile = Util.DimensionalCoordSide.readFromNBT(tileMsg);
|
||||
}
|
||||
}
|
||||
|
||||
public void writeToNBT() {
|
||||
NBTTagCompound data = Platform.openNbtData(this.target);
|
||||
NBTTagCompound tileMsg = new NBTTagCompound();
|
||||
tile.writeToNBT(tileMsg);
|
||||
data.setTag("clickedInterface", tileMsg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IGridNode getActionableNode() {
|
||||
return this.grid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IGridNode getGridNode(ForgeDirection dir) {
|
||||
return this.grid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AECableType getCableConnectionType(ForgeDirection dir) {
|
||||
return AECableType.NONE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void securityBreak() {
|
||||
this.getGridNode(ForgeDirection.UNKNOWN).getMachine().securityBreak();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getItemStack() {
|
||||
return this.target;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInventory getViewCellStorage() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double extractAEPower(double amt, Actionable mode, PowerMultiplier usePowerMultiplier) {
|
||||
amt = usePowerMultiplier.multiply(amt);
|
||||
if (mode == Actionable.SIMULATE) {
|
||||
return usePowerMultiplier.divide(Math.min(amt, this.ips.getAECurrentPower(this.target)));
|
||||
}
|
||||
return usePowerMultiplier.divide(this.ips.extractAEPower(this.target, amt));
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMEMonitor<IAEItemStack> getItemInventory() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMEMonitor<IAEFluidStack> getFluidInventory() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IConfigManager getConfigManager() {
|
||||
final ConfigManager out = new ConfigManager((manager, settingName, newValue) -> {
|
||||
final NBTTagCompound data = Platform.openNbtData(this.target);
|
||||
manager.writeToNBT(data);
|
||||
});
|
||||
out.registerSetting(Settings.TERMINAL_STYLE, TerminalStyle.SMALL);
|
||||
out.readFromNBT((NBTTagCompound) Platform.openNbtData(this.target).copy());
|
||||
return out;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventorySlot() {
|
||||
return this.inventorySlot;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveChanges() {}
|
||||
|
||||
@Override
|
||||
public void onChangeInventory(IInventory inv, int slot, InvOperation mc, ItemStack removedStack,
|
||||
ItemStack newStack) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setClickedInterface(Util.DimensionalCoordSide tile) {
|
||||
this.tile = tile;
|
||||
this.writeToNBT();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Util.DimensionalCoordSide getClickedInterface() {
|
||||
return this.tile;
|
||||
}
|
||||
}
|
||||
+48
-1
@@ -1,7 +1,9 @@
|
||||
package com.glodblock.github.inventory.item;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -22,12 +24,17 @@ import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.util.AECableType;
|
||||
import appeng.api.util.IConfigManager;
|
||||
import appeng.helpers.ICustomButtonDataObject;
|
||||
import appeng.helpers.ICustomButtonProvider;
|
||||
import appeng.helpers.ICustomButtonSource;
|
||||
import appeng.items.tools.powered.ToolWirelessTerminal;
|
||||
import appeng.tile.inventory.InvOperation;
|
||||
import appeng.util.ConfigManager;
|
||||
import appeng.util.Platform;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class WirelessLevelTerminalInventory implements IClickableInTerminal, IWirelessTerminal {
|
||||
public class WirelessLevelTerminalInventory implements IClickableInTerminal, IWirelessTerminal, ICustomButtonProvider {
|
||||
|
||||
private final ItemStack target;
|
||||
private final IAEItemPowerStorage ips;
|
||||
@@ -42,6 +49,11 @@ public class WirelessLevelTerminalInventory implements IClickableInTerminal, IWi
|
||||
this.target = is;
|
||||
this.inventorySlot = slot;
|
||||
readFromNBT();
|
||||
|
||||
if (getItemStack().getItem() instanceof ICustomButtonSource icbs) {
|
||||
customButtonDataObject = icbs.getCustomDataObject(this);
|
||||
customButtonDataObject.readData(getItemStack().getTagCompound());
|
||||
}
|
||||
}
|
||||
|
||||
public void readFromNBT() {
|
||||
@@ -143,4 +155,39 @@ public class WirelessLevelTerminalInventory implements IClickableInTerminal, IWi
|
||||
public Util.DimensionalCoordSide getClickedInterface() {
|
||||
return this.tile;
|
||||
}
|
||||
|
||||
private ICustomButtonDataObject customButtonDataObject;
|
||||
|
||||
@Override
|
||||
public void writeCustomButtonData() {
|
||||
this.customButtonDataObject.writeData(this.getItemStack().getTagCompound());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readCustomButtonData() {
|
||||
this.customButtonDataObject.readData(this.getItemStack().getTagCompound());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initCustomButtons(int guiLeft, int guiTop, int xSize, int ySize, int xOffset, int yOffset,
|
||||
List<GuiButton> buttonList) {
|
||||
if (customButtonDataObject != null)
|
||||
customButtonDataObject.initCustomButtons(guiLeft, guiTop, xSize, ySize, xOffset, yOffset, buttonList);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public boolean actionPerformedCustomButtons(final GuiButton btn) {
|
||||
return customButtonDataObject != null && customButtonDataObject.actionPerformedCustomButtons(btn);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICustomButtonDataObject getDataObject() {
|
||||
return customButtonDataObject;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDataObject(ICustomButtonDataObject dataObject) {
|
||||
customButtonDataObject = dataObject;
|
||||
}
|
||||
}
|
||||
@@ -29,13 +29,7 @@ public class WirelessMagnet {
|
||||
|
||||
Off,
|
||||
Inv,
|
||||
ME;
|
||||
|
||||
private static final Mode[] MODES = Mode.values();
|
||||
|
||||
public static Mode[] getModes() {
|
||||
return MODES;
|
||||
}
|
||||
ME
|
||||
}
|
||||
|
||||
public enum ListMode {
|
||||
@@ -144,7 +138,7 @@ public class WirelessMagnet {
|
||||
if (is != null && is.getItem() instanceof ItemWirelessUltraTerminal) {
|
||||
NBTTagCompound data = Platform.openNbtData(is);
|
||||
if (data.hasKey(modeKey)) {
|
||||
return Mode.getModes()[data.getInteger(modeKey)];
|
||||
return Mode.values()[data.getInteger(modeKey)];
|
||||
}
|
||||
setMode(is, Mode.Off);
|
||||
}
|
||||
|
||||
+2
-2
@@ -123,8 +123,8 @@ public class WirelessMagnetCardFilterInventory extends BaseWirelessInventory imp
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setListMode(WirelessMagnet.ListMode mode) {
|
||||
this.listMode = mode;
|
||||
public void setListMode(boolean mode) {
|
||||
this.listMode = mode ? WirelessMagnet.ListMode.WhiteList : WirelessMagnet.ListMode.BlackList;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
-423
@@ -1,423 +0,0 @@
|
||||
package com.glodblock.github.inventory.item;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import com.glodblock.github.common.item.ItemFluidDrop;
|
||||
import com.glodblock.github.common.item.ItemFluidPacket;
|
||||
import com.glodblock.github.inventory.ItemBiggerAppEngInventory;
|
||||
import com.glodblock.github.inventory.WirelessFluidPatternTerminalPatterns;
|
||||
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.config.PowerMultiplier;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.config.SortDir;
|
||||
import appeng.api.config.SortOrder;
|
||||
import appeng.api.config.TypeFilter;
|
||||
import appeng.api.config.ViewItems;
|
||||
import appeng.api.implementations.ICraftingPatternItem;
|
||||
import appeng.api.implementations.items.IAEItemPowerStorage;
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.api.networking.crafting.ICraftingPatternDetails;
|
||||
import appeng.api.storage.IMEMonitor;
|
||||
import appeng.api.storage.StorageChannel;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.util.AECableType;
|
||||
import appeng.api.util.IConfigManager;
|
||||
import appeng.items.contents.WirelessTerminalViewCells;
|
||||
import appeng.items.tools.powered.ToolWirelessTerminal;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
import appeng.tile.inventory.InvOperation;
|
||||
import appeng.util.ConfigManager;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class WirelessPatternTerminalExInventory extends BaseWirelessInventory implements IWirelessPatternTerminal {
|
||||
|
||||
private final ItemStack target;
|
||||
private final IAEItemPowerStorage ips;
|
||||
private final int inventorySlot;
|
||||
private final AppEngInternalInventory viewCell;
|
||||
private final StorageChannel channel;
|
||||
private final IGridNode grid;
|
||||
|
||||
protected AppEngInternalInventory crafting;
|
||||
protected AppEngInternalInventory output;
|
||||
protected final WirelessFluidPatternTerminalPatterns pattern;
|
||||
|
||||
protected boolean craftingMode = false;
|
||||
protected boolean substitute = false;
|
||||
protected boolean combine = false;
|
||||
protected boolean prioritize = false;
|
||||
protected boolean inverted = false;
|
||||
protected boolean beSubstitute = false;
|
||||
protected boolean autoFillPattern = false;
|
||||
protected int activePage = 0;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public WirelessPatternTerminalExInventory(final ItemStack is, final int slot, IGridNode gridNode,
|
||||
EntityPlayer player) {
|
||||
super(is, slot, gridNode, player, StorageChannel.ITEMS);
|
||||
this.ips = (ToolWirelessTerminal) is.getItem();
|
||||
this.grid = gridNode;
|
||||
this.target = is;
|
||||
this.inventorySlot = slot;
|
||||
this.viewCell = new WirelessTerminalViewCells(is);
|
||||
this.channel = StorageChannel.ITEMS;
|
||||
this.pattern = new WirelessFluidPatternTerminalPatterns(is, this);
|
||||
this.crafting = new ItemBiggerAppEngInventory(is, "crafting_ex", 32);
|
||||
this.output = new ItemBiggerAppEngInventory(is, "output_ex", 32);
|
||||
}
|
||||
|
||||
public StorageChannel getChannel() {
|
||||
return this.channel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getItemStack() {
|
||||
return this.target;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double extractAEPower(double amt, Actionable mode, PowerMultiplier usePowerMultiplier) {
|
||||
amt = usePowerMultiplier.multiply(amt);
|
||||
if (mode == Actionable.SIMULATE) {
|
||||
return usePowerMultiplier.divide(Math.min(amt, this.ips.getAECurrentPower(this.target)));
|
||||
}
|
||||
return usePowerMultiplier.divide(this.ips.extractAEPower(this.target, amt));
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMEMonitor<IAEItemStack> getItemInventory() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMEMonitor<IAEFluidStack> getFluidInventory() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void readFromNBT() {
|
||||
NBTTagCompound data = Platform.openNbtData(this.target);
|
||||
this.setSubstitution(data.getBoolean("substitute"));
|
||||
this.setCombineMode(data.getBoolean("combine"));
|
||||
this.setBeSubstitute(data.getBoolean("beSubstitute"));
|
||||
this.setPrioritization(data.getBoolean("priorization"));
|
||||
this.setInverted(data.getBoolean("inverted"));
|
||||
this.setActivePage(data.getInteger("activePage"));
|
||||
this.setAutoFillPattern(data.getBoolean("autoFillPattern"));
|
||||
}
|
||||
|
||||
public void writeToNBT() {
|
||||
NBTTagCompound data = Platform.openNbtData(this.target);
|
||||
data.setBoolean("substitute", this.substitute);
|
||||
data.setBoolean("combine", this.combine);
|
||||
data.setBoolean("beSubstitute", this.beSubstitute);
|
||||
data.setBoolean("priorization", this.prioritize);
|
||||
data.setBoolean("inverted", this.inverted);
|
||||
data.setInteger("activePage", this.activePage);
|
||||
data.setBoolean("autoFillPattern", this.autoFillPattern);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IConfigManager getConfigManager() {
|
||||
final ConfigManager out = new ConfigManager((manager, settingName, newValue) -> {
|
||||
final NBTTagCompound data = Platform.openNbtData(this.target);
|
||||
manager.writeToNBT(data);
|
||||
});
|
||||
out.registerSetting(Settings.SORT_BY, SortOrder.NAME);
|
||||
out.registerSetting(Settings.VIEW_MODE, ViewItems.ALL);
|
||||
out.registerSetting(Settings.SORT_DIRECTION, SortDir.ASCENDING);
|
||||
out.registerSetting(Settings.TYPE_FILTER, TypeFilter.ALL);
|
||||
out.readFromNBT((NBTTagCompound) Platform.openNbtData(this.target).copy());
|
||||
this.readFromNBT();
|
||||
return out;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventorySlot() {
|
||||
return this.inventorySlot;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInventory getViewCellStorage() {
|
||||
return this.viewCell;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IGridNode getGridNode(ForgeDirection dir) {
|
||||
return this.grid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AECableType getCableConnectionType(ForgeDirection dir) {
|
||||
return AECableType.NONE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void securityBreak() {
|
||||
this.getGridNode(ForgeDirection.UNKNOWN).getMachine().securityBreak();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveChanges() {
|
||||
// NO-OP
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChangeInventory(IInventory inv, int slot, InvOperation mc, ItemStack removedStack,
|
||||
ItemStack newStack) {
|
||||
if (inv == this.pattern && slot == 1) {
|
||||
final ItemStack is = inv.getStackInSlot(1);
|
||||
|
||||
if (is != null && is.getItem() instanceof final ICraftingPatternItem craftingPatternItem) {
|
||||
final ICraftingPatternDetails details = craftingPatternItem
|
||||
.getPatternForItem(is, this.getActionableNode().getWorld());
|
||||
|
||||
if (details != null) {
|
||||
final IAEItemStack[] inItems = details.getInputs();
|
||||
final IAEItemStack[] outItems = details.getOutputs();
|
||||
int inputsCount = 0;
|
||||
int outputCount = 0;
|
||||
for (IAEItemStack inItem : inItems) {
|
||||
if (inItem != null) {
|
||||
inputsCount++;
|
||||
}
|
||||
}
|
||||
for (IAEItemStack outItem : outItems) {
|
||||
if (outItem != null) {
|
||||
outputCount++;
|
||||
}
|
||||
}
|
||||
|
||||
this.setSubstitution(details.canSubstitute());
|
||||
if (newStack != null) {
|
||||
NBTTagCompound data = newStack.getTagCompound();
|
||||
this.setCombineMode(data.getInteger("combine") == 1);
|
||||
this.setBeSubstitute(details.canBeSubstitute());
|
||||
}
|
||||
this.setInverted(inputsCount <= 8 && outputCount > 8);
|
||||
this.setActivePage(0);
|
||||
|
||||
for (int i = 0; i < this.crafting.getSizeInventory(); i++) {
|
||||
this.crafting.setInventorySlotContents(i, null);
|
||||
}
|
||||
|
||||
for (int i = 0; i < this.output.getSizeInventory(); i++) {
|
||||
this.output.setInventorySlotContents(i, null);
|
||||
}
|
||||
|
||||
for (int i = 0; i < this.crafting.getSizeInventory() && i < inItems.length; i++) {
|
||||
final IAEItemStack item = inItems[i];
|
||||
if (item != null) {
|
||||
if (item.getItem() instanceof ItemFluidDrop) {
|
||||
ItemStack packet = ItemFluidPacket
|
||||
.newStack(ItemFluidDrop.getFluidStack(item.getItemStack()));
|
||||
this.crafting.setInventorySlotContents(i, packet);
|
||||
} else this.crafting.setInventorySlotContents(i, item.getItemStack());
|
||||
}
|
||||
}
|
||||
|
||||
if (inverted) {
|
||||
for (int i = 0; i < this.output.getSizeInventory() && i < outItems.length; i++) {
|
||||
final IAEItemStack item = outItems[i];
|
||||
if (item != null) {
|
||||
if (item.getItem() instanceof ItemFluidDrop) {
|
||||
ItemStack packet = ItemFluidPacket
|
||||
.newStack(ItemFluidDrop.getFluidStack(item.getItemStack()));
|
||||
this.output.setInventorySlotContents(i, packet);
|
||||
} else this.output.setInventorySlotContents(i, item.getItemStack());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (int i = 0; i < outItems.length && i < 8; i++) {
|
||||
final IAEItemStack item = outItems[i];
|
||||
if (item != null) {
|
||||
if (item.getItem() instanceof ItemFluidDrop) {
|
||||
ItemStack packet = ItemFluidPacket
|
||||
.newStack(ItemFluidDrop.getFluidStack(item.getItemStack()));
|
||||
this.output.setInventorySlotContents(i >= 4 ? 12 + i : i, packet);
|
||||
} else this.output.setInventorySlotContents(i >= 4 ? 12 + i : i, item.getItemStack());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void fixCraftingRecipes() {
|
||||
if (this.craftingMode) {
|
||||
for (int x = 0; x < this.crafting.getSizeInventory(); x++) {
|
||||
final ItemStack is = this.crafting.getStackInSlot(x);
|
||||
if (is != null) {
|
||||
is.stackSize = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInverted() {
|
||||
return this.inverted;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInventory getInventoryByName(String name) {
|
||||
if (name.equals("crafting")) {
|
||||
return this.crafting;
|
||||
}
|
||||
|
||||
if (name.equals("output")) {
|
||||
return this.output;
|
||||
}
|
||||
|
||||
if (name.equals("pattern")) {
|
||||
return this.pattern;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeSubstitute() {
|
||||
return this.beSubstitute;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPrioritize() {
|
||||
return this.prioritize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSubstitution() {
|
||||
return this.substitute;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldCombine() {
|
||||
return this.combine;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChangeCrafting(IAEItemStack[] newCrafting, IAEItemStack[] newOutput) {
|
||||
IInventory crafting = this.getInventoryByName("crafting");
|
||||
IInventory output = this.getInventoryByName("output");
|
||||
if (crafting instanceof AppEngInternalInventory && output instanceof AppEngInternalInventory) {
|
||||
for (int x = 0; x < crafting.getSizeInventory() && x < newCrafting.length; x++) {
|
||||
final IAEItemStack item = newCrafting[x];
|
||||
crafting.setInventorySlotContents(x, item == null ? null : item.getItemStack());
|
||||
}
|
||||
for (int x = 0; x < output.getSizeInventory() && x < newOutput.length; x++) {
|
||||
final IAEItemStack item = newOutput[x];
|
||||
output.setInventorySlotContents(x, item == null ? null : item.getItemStack());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCraftingRecipe(boolean craftingMode) {
|
||||
this.craftingMode = craftingMode;
|
||||
this.fixCraftingRecipes();
|
||||
// force update crafting mode
|
||||
((ItemBiggerAppEngInventory) this.crafting).setCraftingMode(craftingMode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSubstitution(boolean canSubstitute) {
|
||||
this.substitute = canSubstitute;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBeSubstitute(boolean canBeSubstitute) {
|
||||
this.beSubstitute = canBeSubstitute;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCombineMode(boolean shouldCombine) {
|
||||
this.combine = shouldCombine;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPrioritization(boolean canPrioritize) {
|
||||
this.prioritize = canPrioritize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInverted(boolean inverted) {
|
||||
this.inverted = inverted;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getActivePage() {
|
||||
return this.activePage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setActivePage(int activePage) {
|
||||
this.activePage = activePage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCraftingRecipe() {
|
||||
return this.craftingMode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sortCraftingItems() {
|
||||
List<ItemStack> items = new ArrayList<>();
|
||||
List<ItemStack> fluids = new ArrayList<>();
|
||||
for (ItemStack is : this.crafting) {
|
||||
if (is == null) continue;
|
||||
if (is.getItem() instanceof ItemFluidPacket) {
|
||||
fluids.add(is);
|
||||
} else {
|
||||
items.add(is);
|
||||
}
|
||||
}
|
||||
if (this.prioritize) {
|
||||
fluids.addAll(items);
|
||||
items.clear();
|
||||
} else {
|
||||
items.addAll(fluids);
|
||||
fluids.clear();
|
||||
}
|
||||
|
||||
for (int i = 0; i < this.crafting.getSizeInventory(); i++) {
|
||||
if (this.crafting.getStackInSlot(i) == null) break;
|
||||
if (items.isEmpty()) {
|
||||
this.crafting.setInventorySlotContents(i, fluids.get(i));
|
||||
} else {
|
||||
this.crafting.setInventorySlotContents(i, items.get(i));
|
||||
}
|
||||
}
|
||||
saveChanges();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAutoFillPattern() {
|
||||
return this.autoFillPattern;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAutoFillPattern(boolean canFill) {
|
||||
this.autoFillPattern = canFill;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveSettings() {
|
||||
super.saveSettings();
|
||||
this.writeToNBT();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IGridNode getActionableNode() {
|
||||
return this.grid;
|
||||
}
|
||||
}
|
||||
-396
@@ -1,396 +0,0 @@
|
||||
package com.glodblock.github.inventory.item;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import com.glodblock.github.common.item.ItemFluidDrop;
|
||||
import com.glodblock.github.common.item.ItemFluidPacket;
|
||||
import com.glodblock.github.inventory.ItemBiggerAppEngInventory;
|
||||
import com.glodblock.github.inventory.WirelessFluidPatternTerminalPatterns;
|
||||
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.config.PowerMultiplier;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.config.SortDir;
|
||||
import appeng.api.config.SortOrder;
|
||||
import appeng.api.config.TypeFilter;
|
||||
import appeng.api.config.ViewItems;
|
||||
import appeng.api.implementations.ICraftingPatternItem;
|
||||
import appeng.api.implementations.items.IAEItemPowerStorage;
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.api.networking.crafting.ICraftingPatternDetails;
|
||||
import appeng.api.storage.IMEMonitor;
|
||||
import appeng.api.storage.StorageChannel;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.util.AECableType;
|
||||
import appeng.api.util.IConfigManager;
|
||||
import appeng.items.contents.WirelessTerminalViewCells;
|
||||
import appeng.items.tools.powered.ToolWirelessTerminal;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
import appeng.tile.inventory.InvOperation;
|
||||
import appeng.util.ConfigManager;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class WirelessPatternTerminalInventory extends BaseWirelessInventory implements IWirelessPatternTerminal {
|
||||
|
||||
private final ItemStack target;
|
||||
private final IAEItemPowerStorage ips;
|
||||
private final int inventorySlot;
|
||||
private final AppEngInternalInventory viewCell;
|
||||
private final StorageChannel channel;
|
||||
private final IGridNode grid;
|
||||
|
||||
protected AppEngInternalInventory crafting;
|
||||
protected AppEngInternalInventory output;
|
||||
protected final WirelessFluidPatternTerminalPatterns pattern;
|
||||
|
||||
protected boolean craftingMode = true;
|
||||
protected boolean substitute = false;
|
||||
protected boolean combine = false;
|
||||
protected boolean prioritize = false;
|
||||
protected boolean inverted = false;
|
||||
protected boolean beSubstitute = false;
|
||||
protected boolean autoFillPattern = false;
|
||||
protected int activePage = 0;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public WirelessPatternTerminalInventory(final ItemStack is, final int slot, IGridNode gridNode,
|
||||
EntityPlayer player) {
|
||||
super(is, slot, gridNode, player, StorageChannel.ITEMS);
|
||||
this.ips = (ToolWirelessTerminal) is.getItem();
|
||||
this.grid = gridNode;
|
||||
this.target = is;
|
||||
this.inventorySlot = slot;
|
||||
this.viewCell = new WirelessTerminalViewCells(is);
|
||||
this.channel = StorageChannel.ITEMS;
|
||||
this.pattern = new WirelessFluidPatternTerminalPatterns(is, this);
|
||||
this.crafting = new ItemBiggerAppEngInventory(is, "crafting", 9);
|
||||
this.output = new ItemBiggerAppEngInventory(is, "output", 3);
|
||||
}
|
||||
|
||||
public StorageChannel getChannel() {
|
||||
return this.channel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getItemStack() {
|
||||
return this.target;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double extractAEPower(double amt, Actionable mode, PowerMultiplier usePowerMultiplier) {
|
||||
amt = usePowerMultiplier.multiply(amt);
|
||||
if (mode == Actionable.SIMULATE) {
|
||||
return usePowerMultiplier.divide(Math.min(amt, this.ips.getAECurrentPower(this.target)));
|
||||
}
|
||||
return usePowerMultiplier.divide(this.ips.extractAEPower(this.target, amt));
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMEMonitor<IAEItemStack> getItemInventory() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMEMonitor<IAEFluidStack> getFluidInventory() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void readFromNBT() {
|
||||
NBTTagCompound data = Platform.openNbtData(this.target);
|
||||
this.setCraftingRecipe(data.getBoolean("craftingMode"));
|
||||
this.setSubstitution(data.getBoolean("substitute"));
|
||||
this.setCombineMode(data.getBoolean("combine"));
|
||||
this.setBeSubstitute(data.getBoolean("beSubstitute"));
|
||||
this.setActivePage(data.getInteger("activePage"));
|
||||
this.setAutoFillPattern(data.getBoolean("autoFillPattern"));
|
||||
}
|
||||
|
||||
public void writeToNBT() {
|
||||
NBTTagCompound data = Platform.openNbtData(this.target);
|
||||
data.setBoolean("craftingMode", this.craftingMode);
|
||||
data.setBoolean("substitute", this.substitute);
|
||||
data.setBoolean("combine", this.combine);
|
||||
data.setBoolean("beSubstitute", this.beSubstitute);
|
||||
data.setInteger("activePage", this.activePage);
|
||||
data.setBoolean("autoFillPattern", this.autoFillPattern);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IConfigManager getConfigManager() {
|
||||
final ConfigManager out = new ConfigManager((manager, settingName, newValue) -> {
|
||||
final NBTTagCompound data = Platform.openNbtData(this.target);
|
||||
manager.writeToNBT(data);
|
||||
});
|
||||
out.registerSetting(Settings.SORT_BY, SortOrder.NAME);
|
||||
out.registerSetting(Settings.VIEW_MODE, ViewItems.ALL);
|
||||
out.registerSetting(Settings.SORT_DIRECTION, SortDir.ASCENDING);
|
||||
out.registerSetting(Settings.TYPE_FILTER, TypeFilter.ALL);
|
||||
out.readFromNBT((NBTTagCompound) Platform.openNbtData(this.target).copy());
|
||||
this.readFromNBT();
|
||||
return out;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventorySlot() {
|
||||
return this.inventorySlot;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInventory getViewCellStorage() {
|
||||
return this.viewCell;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IGridNode getGridNode(ForgeDirection dir) {
|
||||
return this.grid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AECableType getCableConnectionType(ForgeDirection dir) {
|
||||
return AECableType.NONE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void securityBreak() {
|
||||
this.getGridNode(ForgeDirection.UNKNOWN).getMachine().securityBreak();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveChanges() {
|
||||
// NO-OP
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChangeInventory(IInventory inv, int slot, InvOperation mc, ItemStack removedStack,
|
||||
ItemStack newStack) {
|
||||
if (inv == this.pattern && slot == 1) {
|
||||
final ItemStack is = inv.getStackInSlot(1);
|
||||
if (is != null && is.getItem() instanceof final ICraftingPatternItem craftingPatternItem) {
|
||||
final ICraftingPatternDetails details = craftingPatternItem
|
||||
.getPatternForItem(is, this.getActionableNode().getWorld());
|
||||
if (details != null) {
|
||||
final IAEItemStack[] inItems = details.getInputs();
|
||||
final IAEItemStack[] outItems = details.getOutputs();
|
||||
|
||||
this.setCraftingRecipe(details.isCraftable());
|
||||
this.setSubstitution(details.canSubstitute());
|
||||
if (newStack != null) {
|
||||
NBTTagCompound data = newStack.getTagCompound();
|
||||
this.setCombineMode(data.getInteger("combine") == 1);
|
||||
this.setBeSubstitute(details.canBeSubstitute());
|
||||
}
|
||||
for (int i = 0; i < this.crafting.getSizeInventory(); i++) {
|
||||
this.crafting.setInventorySlotContents(i, null);
|
||||
}
|
||||
|
||||
for (int i = 0; i < this.output.getSizeInventory(); i++) {
|
||||
this.output.setInventorySlotContents(i, null);
|
||||
}
|
||||
|
||||
for (int i = 0; i < this.crafting.getSizeInventory() && i < inItems.length; i++) {
|
||||
if (inItems[i] != null) {
|
||||
final IAEItemStack item = inItems[i];
|
||||
if (item != null && item.getItem() instanceof ItemFluidDrop) {
|
||||
ItemStack packet = ItemFluidPacket
|
||||
.newStack(ItemFluidDrop.getFluidStack(item.getItemStack()));
|
||||
this.crafting.setInventorySlotContents(i, packet);
|
||||
} else this.crafting.setInventorySlotContents(i, item == null ? null : item.getItemStack());
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < this.output.getSizeInventory() && i < outItems.length; i++) {
|
||||
if (outItems[i] != null) {
|
||||
final IAEItemStack item = outItems[i];
|
||||
if (item != null && item.getItem() instanceof ItemFluidDrop) {
|
||||
ItemStack packet = ItemFluidPacket
|
||||
.newStack(ItemFluidDrop.getFluidStack(item.getItemStack()));
|
||||
this.output.setInventorySlotContents(i, packet);
|
||||
} else this.output.setInventorySlotContents(i, item == null ? null : item.getItemStack());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (inv == this.crafting) {
|
||||
this.fixCraftingRecipes();
|
||||
}
|
||||
}
|
||||
|
||||
private void fixCraftingRecipes() {
|
||||
if (this.craftingMode) {
|
||||
for (int x = 0; x < this.crafting.getSizeInventory(); x++) {
|
||||
final ItemStack is = this.crafting.getStackInSlot(x);
|
||||
if (is != null) {
|
||||
is.stackSize = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInverted() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInventory getInventoryByName(String name) {
|
||||
if (name.equals("crafting")) {
|
||||
return this.crafting;
|
||||
}
|
||||
|
||||
if (name.equals("output")) {
|
||||
return this.output;
|
||||
}
|
||||
|
||||
if (name.equals("pattern")) {
|
||||
return this.pattern;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeSubstitute() {
|
||||
return this.beSubstitute;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPrioritize() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSubstitution() {
|
||||
return this.substitute;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldCombine() {
|
||||
return this.combine;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChangeCrafting(IAEItemStack[] newCrafting, IAEItemStack[] newOutput) {
|
||||
IInventory crafting = this.getInventoryByName("crafting");
|
||||
IInventory output = this.getInventoryByName("output");
|
||||
if (crafting instanceof AppEngInternalInventory && output instanceof AppEngInternalInventory) {
|
||||
for (int x = 0; x < crafting.getSizeInventory() && x < newCrafting.length; x++) {
|
||||
final IAEItemStack item = newCrafting[x];
|
||||
crafting.setInventorySlotContents(x, item == null ? null : item.getItemStack());
|
||||
}
|
||||
for (int x = 0; x < output.getSizeInventory() && x < newOutput.length; x++) {
|
||||
final IAEItemStack item = newOutput[x];
|
||||
output.setInventorySlotContents(x, item == null ? null : item.getItemStack());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCraftingRecipe(boolean craftingMode) {
|
||||
this.craftingMode = craftingMode;
|
||||
this.fixCraftingRecipes();
|
||||
// force update crafting mode
|
||||
((ItemBiggerAppEngInventory) this.crafting).setCraftingMode(craftingMode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSubstitution(boolean canSubstitute) {
|
||||
this.substitute = canSubstitute;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBeSubstitute(boolean canBeSubstitute) {
|
||||
this.beSubstitute = canBeSubstitute;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCombineMode(boolean shouldCombine) {
|
||||
this.combine = shouldCombine;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPrioritization(boolean canPrioritize) {
|
||||
this.prioritize = canPrioritize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInverted(boolean inverted) {
|
||||
this.inverted = inverted;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getActivePage() {
|
||||
return this.activePage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setActivePage(int activePage) {
|
||||
this.activePage = activePage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCraftingRecipe() {
|
||||
return this.craftingMode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sortCraftingItems() {
|
||||
List<ItemStack> items = new ArrayList<>();
|
||||
List<ItemStack> fluids = new ArrayList<>();
|
||||
for (ItemStack is : this.crafting) {
|
||||
if (is == null) continue;
|
||||
if (is.getItem() instanceof ItemFluidPacket) {
|
||||
fluids.add(is);
|
||||
} else {
|
||||
items.add(is);
|
||||
}
|
||||
}
|
||||
if (this.prioritize) {
|
||||
fluids.addAll(items);
|
||||
items.clear();
|
||||
} else {
|
||||
items.addAll(fluids);
|
||||
fluids.clear();
|
||||
}
|
||||
|
||||
for (int i = 0; i < this.crafting.getSizeInventory(); i++) {
|
||||
if (this.crafting.getStackInSlot(i) == null) break;
|
||||
if (items.isEmpty()) {
|
||||
this.crafting.setInventorySlotContents(i, fluids.get(i));
|
||||
} else {
|
||||
this.crafting.setInventorySlotContents(i, items.get(i));
|
||||
}
|
||||
}
|
||||
saveChanges();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAutoFillPattern() {
|
||||
return this.autoFillPattern;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAutoFillPattern(boolean canFill) {
|
||||
this.autoFillPattern = canFill;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveSettings() {
|
||||
super.saveSettings();
|
||||
this.writeToNBT();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IGridNode getActionableNode() {
|
||||
return this.grid;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -11,6 +11,7 @@ import com.glodblock.github.network.CPacketLevelMaintainer;
|
||||
import com.glodblock.github.network.CPacketLevelTerminalCommands;
|
||||
import com.glodblock.github.network.CPacketSwitchGuis;
|
||||
import com.glodblock.github.network.CPacketValueConfig;
|
||||
import com.glodblock.github.network.SPacketCustomButtonUpdate;
|
||||
import com.glodblock.github.network.SPacketFluidUpdate;
|
||||
import com.glodblock.github.network.SPacketLevelMaintainerGuiUpdate;
|
||||
import com.glodblock.github.network.SPacketLevelTerminalUpdate;
|
||||
@@ -59,6 +60,11 @@ public class ChannelLoader implements Runnable {
|
||||
SPacketLevelMaintainerGuiUpdate.class,
|
||||
id++,
|
||||
Side.CLIENT);
|
||||
netHandler.registerMessage(
|
||||
new SPacketCustomButtonUpdate.Handler(),
|
||||
SPacketCustomButtonUpdate.class,
|
||||
id++,
|
||||
Side.CLIENT);
|
||||
}
|
||||
|
||||
public static void sendPacketToAllPlayers(Packet packet, World world) {
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package com.glodblock.github.loader;
|
||||
|
||||
import static com.glodblock.github.common.item.ItemWirelessUltraTerminal.switchTerminal;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.entity.EntityClientPlayerMP;
|
||||
import net.minecraft.client.settings.KeyBinding;
|
||||
@@ -11,6 +9,7 @@ import org.apache.commons.lang3.tuple.ImmutablePair;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
import com.glodblock.github.FluidCraft;
|
||||
import com.glodblock.github.network.CPacketSwitchGuis;
|
||||
import com.glodblock.github.network.CPacketValueConfig;
|
||||
import com.glodblock.github.util.Util;
|
||||
|
||||
@@ -59,7 +58,9 @@ public class KeybindLoader implements Runnable {
|
||||
private void handleOpenTerminalKey() {
|
||||
if (Minecraft.getMinecraft().currentScreen != null) return;
|
||||
EntityClientPlayerMP player = Minecraft.getMinecraft().thePlayer;
|
||||
if (player.openContainer != null) switchTerminal(player, null);
|
||||
ImmutablePair<Integer, ItemStack> temp = Util.getUltraWirelessTerm(player);
|
||||
if (temp == null) return;
|
||||
FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(null, true));
|
||||
}
|
||||
|
||||
private void handleRestockKey() {
|
||||
|
||||
@@ -1,20 +1,23 @@
|
||||
package com.glodblock.github.network;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import com.glodblock.github.client.gui.container.ContainerFluidStorageBus;
|
||||
import com.glodblock.github.client.gui.container.base.FCBaseContainer;
|
||||
import com.glodblock.github.FluidCraft;
|
||||
import com.glodblock.github.client.gui.container.ContainerMagnetFilter;
|
||||
import com.glodblock.github.inventory.InventoryHandler;
|
||||
import com.glodblock.github.inventory.UltraTerminalButtons;
|
||||
import com.glodblock.github.inventory.gui.GuiType;
|
||||
import com.glodblock.github.inventory.item.IItemTerminal;
|
||||
import com.glodblock.github.inventory.item.IWirelessExtendCard;
|
||||
import com.glodblock.github.inventory.item.IWirelessMagnetFilter;
|
||||
import com.glodblock.github.inventory.item.WirelessMagnet;
|
||||
import com.glodblock.github.util.BlockPos;
|
||||
import com.glodblock.github.util.Util;
|
||||
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.container.IContainerSubGui;
|
||||
import appeng.container.PrimaryGui;
|
||||
import appeng.container.interfaces.IInventorySlotAware;
|
||||
import appeng.helpers.ICustomButtonProvider;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
|
||||
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
|
||||
@@ -22,21 +25,34 @@ import io.netty.buffer.ByteBuf;
|
||||
|
||||
public class CPacketFluidPatternTermBtns implements IMessage {
|
||||
|
||||
private String Name = "";
|
||||
private String Value = "";
|
||||
private Command command;
|
||||
private String value = "";
|
||||
|
||||
public CPacketFluidPatternTermBtns(final String name, final String value) {
|
||||
Name = name;
|
||||
Value = value;
|
||||
public enum Command {
|
||||
RESTOCK,
|
||||
MAGNET_MODE,
|
||||
MAGNET_OPEN_FILTER,
|
||||
MAGNET_FILTER_NBT,
|
||||
MAGNET_FILTER_META,
|
||||
MAGNET_FILTER_ORE,
|
||||
MAGNET_FILTER_OREDICT_STATE,
|
||||
MAGNET_FILTER_OREDICT_FILTER,
|
||||
MAGNET_FILTER_MODE,
|
||||
MAGNET_FILTER_CLEAR
|
||||
}
|
||||
|
||||
public CPacketFluidPatternTermBtns(final String name, final Integer value) {
|
||||
Name = name;
|
||||
Value = value.toString();
|
||||
public CPacketFluidPatternTermBtns(final Command command, final String value) {
|
||||
this.command = command;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public CPacketFluidPatternTermBtns(final String name, final boolean value) {
|
||||
this(name, value ? 1 : 0);
|
||||
public CPacketFluidPatternTermBtns(final Command command, final Integer value) {
|
||||
this.command = command;
|
||||
this.value = value.toString();
|
||||
}
|
||||
|
||||
public CPacketFluidPatternTermBtns(final Command command, final boolean value) {
|
||||
this(command, value ? 1 : 0);
|
||||
}
|
||||
|
||||
public CPacketFluidPatternTermBtns() {
|
||||
@@ -45,29 +61,23 @@ public class CPacketFluidPatternTermBtns implements IMessage {
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf) {
|
||||
int leName = buf.readInt();
|
||||
this.command = Command.values()[buf.readInt()];
|
||||
|
||||
int leVal = buf.readInt();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int i = 0; i < leName; i++) {
|
||||
sb.append(buf.readChar());
|
||||
}
|
||||
Name = sb.toString();
|
||||
sb = new StringBuilder();
|
||||
for (int i = 0; i < leVal; i++) {
|
||||
sb.append(buf.readChar());
|
||||
}
|
||||
Value = sb.toString();
|
||||
this.value = sb.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf buf) {
|
||||
buf.writeInt(Name.length());
|
||||
buf.writeInt(Value.length());
|
||||
for (int i = 0; i < Name.length(); i++) {
|
||||
buf.writeChar(Name.charAt(i));
|
||||
}
|
||||
for (int i = 0; i < Value.length(); i++) {
|
||||
buf.writeChar(Value.charAt(i));
|
||||
buf.writeInt(this.command.ordinal());
|
||||
|
||||
buf.writeInt(this.value.length());
|
||||
for (int i = 0; i < this.value.length(); i++) {
|
||||
buf.writeChar(this.value.charAt(i));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,65 +85,62 @@ public class CPacketFluidPatternTermBtns implements IMessage {
|
||||
|
||||
@Override
|
||||
public IMessage onMessage(CPacketFluidPatternTermBtns message, MessageContext ctx) {
|
||||
String Name = message.Name;
|
||||
String Value = message.Value;
|
||||
final Command command = message.command;
|
||||
final String value = message.value;
|
||||
final Container c = ctx.getServerHandler().playerEntity.openContainer;
|
||||
final EntityPlayer player = ctx.getServerHandler().playerEntity;
|
||||
if (Name.startsWith("WirelessTerminal.") && (c instanceof FCBaseContainer)) {
|
||||
final FCBaseContainer cpt = (FCBaseContainer) c;
|
||||
final IItemTerminal itemTerminal = (IItemTerminal) cpt.getHost();
|
||||
final IWirelessExtendCard iwt = (IWirelessExtendCard) itemTerminal;
|
||||
switch (Name) {
|
||||
case "WirelessTerminal.Stock":
|
||||
iwt.setRestock(!iwt.isRestock());
|
||||
break;
|
||||
case "WirelessTerminal.MagnetMode":
|
||||
iwt.setMagnetCardNextMode();
|
||||
break;
|
||||
case "WirelessTerminal.OpenMagnet":
|
||||
final EntityPlayerMP player = ctx.getServerHandler().playerEntity;
|
||||
|
||||
if (c instanceof ContainerMagnetFilter cmf && cmf.getTarget() instanceof IWirelessMagnetFilter iwmf) {
|
||||
switch (command) {
|
||||
case MAGNET_FILTER_NBT -> iwmf.setNBTMode(value.equals("1"));
|
||||
case MAGNET_FILTER_META -> iwmf.setMetaMode(value.equals("1"));
|
||||
case MAGNET_FILTER_ORE -> iwmf.setOreMode(value.equals("1"));
|
||||
case MAGNET_FILTER_OREDICT_STATE -> iwmf.setOreDictMode(value.equals("1"));
|
||||
case MAGNET_FILTER_OREDICT_FILTER -> iwmf.setOreDictFilter(value);
|
||||
case MAGNET_FILTER_MODE -> iwmf.setListMode(value.equals("1"));
|
||||
case MAGNET_FILTER_CLEAR -> iwmf.clearConfig();
|
||||
}
|
||||
iwmf.saveSettings();
|
||||
} else if (c instanceof AEBaseContainer abc && abc.getTarget() instanceof ICustomButtonProvider icbp) {
|
||||
|
||||
switch (command) {
|
||||
case RESTOCK -> {
|
||||
if (icbp.getDataObject() instanceof UltraTerminalButtons utb) {
|
||||
utb.toggleRestock();
|
||||
}
|
||||
}
|
||||
case MAGNET_MODE -> {
|
||||
if (icbp.getDataObject() instanceof UltraTerminalButtons utb) {
|
||||
utb.toggleMagnetMode();
|
||||
}
|
||||
}
|
||||
case MAGNET_OPEN_FILTER -> {
|
||||
final PrimaryGui pGui = abc.getPrimaryGui();
|
||||
final int nextGui = abc.getSwitchAbleGuiNext();
|
||||
|
||||
InventoryHandler.openGui(
|
||||
player,
|
||||
player.worldObj,
|
||||
new BlockPos(
|
||||
cpt.getPortableCell().getInventorySlot(),
|
||||
((IInventorySlotAware) abc.getTarget()).getInventorySlot(),
|
||||
Util.GuiHelper.encodeType(0, Util.GuiHelper.GuiType.ITEM),
|
||||
-1),
|
||||
ForgeDirection.UNKNOWN,
|
||||
GuiType.WIRELESS_MAGNET_FILTER);
|
||||
break;
|
||||
case "WirelessTerminal.magnet.NBT":
|
||||
((IWirelessMagnetFilter) itemTerminal).setNBTMode(Value.equals("1"));
|
||||
break;
|
||||
case "WirelessTerminal.magnet.Meta":
|
||||
((IWirelessMagnetFilter) itemTerminal).setMetaMode(Value.equals("1"));
|
||||
break;
|
||||
case "WirelessTerminal.magnet.Ore":
|
||||
((IWirelessMagnetFilter) itemTerminal).setOreMode(Value.equals("1"));
|
||||
break;
|
||||
case "WirelessTerminal.magnet.OreDictState":
|
||||
((IWirelessMagnetFilter) itemTerminal).setOreDictMode(Value.equals("1"));
|
||||
break;
|
||||
case "WirelessTerminal.magnet.OreDictFilter":
|
||||
((IWirelessMagnetFilter) itemTerminal).setOreDictFilter(Value);
|
||||
break;
|
||||
case "WirelessTerminal.magnet.FilterMode":
|
||||
((IWirelessMagnetFilter) itemTerminal).setListMode(
|
||||
Value.equals("1") ? WirelessMagnet.ListMode.WhiteList
|
||||
: WirelessMagnet.ListMode.BlackList);
|
||||
break;
|
||||
case "WirelessTerminal.magnet.clear":
|
||||
((IWirelessMagnetFilter) itemTerminal).clearConfig();
|
||||
break;
|
||||
}
|
||||
itemTerminal.saveSettings();
|
||||
} else if (Name.startsWith("StorageBus.") && c instanceof ContainerFluidStorageBus ccw) {
|
||||
if (Name.equals("StorageBus.Action")) {
|
||||
if (Value.equals("Partition")) {
|
||||
ccw.partition();
|
||||
} else if (Value.equals("Clear")) {
|
||||
ccw.clear();
|
||||
|
||||
if (player.openContainer instanceof IContainerSubGui sg) {
|
||||
sg.setPrimaryGui(pGui);
|
||||
}
|
||||
|
||||
if (player.openContainer instanceof AEBaseContainer ab) {
|
||||
ab.setSwitchAbleGuiNext(nextGui);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
icbp.writeCustomButtonData();
|
||||
|
||||
FluidCraft.proxy.netHandler.sendTo(new SPacketCustomButtonUpdate(icbp.getDataObject()), player);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -1,15 +1,18 @@
|
||||
package com.glodblock.github.network;
|
||||
|
||||
import static com.glodblock.github.common.item.ItemWirelessUltraTerminal.switchTerminal;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import org.apache.commons.lang3.tuple.ImmutablePair;
|
||||
|
||||
import com.glodblock.github.FluidCraft;
|
||||
import com.glodblock.github.common.item.ItemWirelessUltraTerminal;
|
||||
import com.glodblock.github.inventory.InventoryHandler;
|
||||
import com.glodblock.github.inventory.gui.GuiType;
|
||||
import com.glodblock.github.inventory.item.IWirelessTerminal;
|
||||
@@ -20,6 +23,7 @@ import com.glodblock.github.util.Util;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.container.ContainerOpenContext;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.helpers.ICustomButtonProvider;
|
||||
import appeng.util.Platform;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
|
||||
@@ -46,13 +50,14 @@ public class CPacketSwitchGuis implements IMessage {
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf byteBuf) {
|
||||
mode = UltraTerminalModes.values()[byteBuf.readInt()];
|
||||
final int ord = byteBuf.readInt();
|
||||
mode = ord != -1 ? UltraTerminalModes.values()[ord] : null;
|
||||
switchTerminal = byteBuf.readBoolean();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf byteBuf) {
|
||||
byteBuf.writeInt(mode.ordinal());
|
||||
byteBuf.writeInt(mode != null ? mode.ordinal() : -1);
|
||||
byteBuf.writeBoolean(this.switchTerminal);
|
||||
}
|
||||
|
||||
@@ -61,14 +66,27 @@ public class CPacketSwitchGuis implements IMessage {
|
||||
@Nullable
|
||||
@Override
|
||||
public IMessage onMessage(CPacketSwitchGuis message, MessageContext ctx) {
|
||||
if (message.mode == null) return null;
|
||||
|
||||
EntityPlayerMP player = ctx.getServerHandler().playerEntity;
|
||||
Container cont = player.openContainer;
|
||||
|
||||
// switch terminal
|
||||
if (message.switchTerminal) switchTerminal(player, message.mode);
|
||||
else {
|
||||
|
||||
if (message.switchTerminal) {
|
||||
ImmutablePair<Integer, ItemStack> temp = Util.getUltraWirelessTerm(player);
|
||||
if (temp != null && temp.getRight().getItem() instanceof ItemWirelessUltraTerminal iwut) {
|
||||
if (message.mode != null && cont instanceof AEBaseContainer abc) {
|
||||
abc.setSwitchAbleGuiNext(message.mode.ordinal());
|
||||
|
||||
}
|
||||
iwut.switchTerminal(player, temp.getRight(), message.mode);
|
||||
if (player.openContainer instanceof AEBaseContainer abc) {
|
||||
if (abc.getTarget() instanceof ICustomButtonProvider icbp) {
|
||||
FluidCraft.proxy.netHandler
|
||||
.sendTo(new SPacketCustomButtonUpdate(icbp.getDataObject()), player);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// open new terminal //TODO in world stuff
|
||||
if (cont instanceof AEBaseContainer aeBaseContainer) {
|
||||
ContainerOpenContext context = aeBaseContainer.getOpenContext();
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.glodblock.github.network;
|
||||
|
||||
import static com.glodblock.github.util.Util.toggleRestock;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.ContainerPlayer;
|
||||
@@ -10,14 +12,16 @@ import net.minecraft.util.StatCollector;
|
||||
import org.apache.commons.lang3.tuple.ImmutablePair;
|
||||
|
||||
import com.glodblock.github.client.gui.container.ContainerFluidLevelEmitter;
|
||||
import com.glodblock.github.common.item.ItemBaseWirelessTerminal;
|
||||
import com.glodblock.github.inventory.item.WirelessCraftingTerminalInventory;
|
||||
import com.glodblock.github.util.NameConst;
|
||||
import com.glodblock.github.util.Util;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.networking.IGrid;
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.api.networking.security.PlayerSource;
|
||||
import appeng.api.networking.storage.IStorageGrid;
|
||||
import appeng.api.storage.IMEMonitor;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
|
||||
@@ -62,8 +66,7 @@ public class CPacketValueConfig implements IMessage {
|
||||
if (result != null) {
|
||||
final ItemStack wirelessTerm = result.getRight();
|
||||
if (message.valueIndex == 1) {
|
||||
ItemBaseWirelessTerminal
|
||||
.toggleRestockItemsMode(wirelessTerm, !Util.isRestock(wirelessTerm));
|
||||
toggleRestock(wirelessTerm);
|
||||
player.addChatMessage(
|
||||
new ChatComponentText(
|
||||
StatCollector.translateToLocal(
|
||||
@@ -85,25 +88,31 @@ public class CPacketValueConfig implements IMessage {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private void restockItems(ItemStack terminal, IGridNode gridNode, int slot, EntityPlayer player) {
|
||||
WirelessCraftingTerminalInventory inv = new WirelessCraftingTerminalInventory(
|
||||
terminal,
|
||||
slot,
|
||||
gridNode,
|
||||
player);
|
||||
IGrid targetGrid = gridNode.getGrid();
|
||||
IMEMonitor<IAEItemStack> itemStorage = null;
|
||||
|
||||
for (int i = 0; i < 9; i++) {
|
||||
ItemStack is = player.inventory.mainInventory[i];
|
||||
if (is != null) {
|
||||
int maxSize = is.getMaxStackSize();
|
||||
if (is.stackSize < maxSize) {
|
||||
int fillSize = maxSize - is.stackSize;
|
||||
IAEItemStack ias = AEApi.instance().storage().createItemStack(is);
|
||||
ias.setStackSize(fillSize);
|
||||
if (targetGrid != null) {
|
||||
IStorageGrid sg = targetGrid.getCache(IStorageGrid.class);
|
||||
if (sg != null) {
|
||||
itemStorage = sg.getItemInventory();
|
||||
}
|
||||
}
|
||||
|
||||
IAEItemStack extractedItem = (IAEItemStack) inv
|
||||
.extractItems(ias, Actionable.MODULATE, inv.getActionSource());
|
||||
if (extractedItem != null) {
|
||||
player.inventory.addItemStackToInventory(extractedItem.getItemStack());
|
||||
if (itemStorage != null) {
|
||||
for (int i = 0; i < 9; i++) {
|
||||
ItemStack is = player.inventory.mainInventory[i];
|
||||
if (is != null) {
|
||||
int maxSize = is.getMaxStackSize();
|
||||
if (is.stackSize < maxSize) {
|
||||
int fillSize = maxSize - is.stackSize;
|
||||
IAEItemStack ias = AEApi.instance().storage().createItemStack(is);
|
||||
ias.setStackSize(fillSize);
|
||||
|
||||
IAEItemStack extractedItem = itemStorage
|
||||
.extractItems(ias, Actionable.MODULATE, new PlayerSource(player, null));
|
||||
if (extractedItem != null) {
|
||||
player.inventory.addItemStackToInventory(extractedItem.getItemStack());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.glodblock.github.network;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.helpers.ICustomButtonDataObject;
|
||||
import appeng.helpers.ICustomButtonProvider;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
|
||||
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
public class SPacketCustomButtonUpdate implements IMessage {
|
||||
|
||||
private ICustomButtonDataObject dataObject;
|
||||
|
||||
private ByteBuf buf;
|
||||
|
||||
public SPacketCustomButtonUpdate() {}
|
||||
|
||||
public SPacketCustomButtonUpdate(ICustomButtonDataObject dataObject) {
|
||||
this.dataObject = dataObject;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf) {
|
||||
this.buf = buf;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf buf) {
|
||||
this.dataObject.writeByte(buf);
|
||||
}
|
||||
|
||||
public static class Handler implements IMessageHandler<SPacketCustomButtonUpdate, IMessage> {
|
||||
|
||||
@Override
|
||||
public IMessage onMessage(SPacketCustomButtonUpdate message, MessageContext ctx) {
|
||||
if (Minecraft.getMinecraft().thePlayer.openContainer instanceof AEBaseContainer abc
|
||||
&& abc.getTarget() instanceof ICustomButtonProvider icbp) {
|
||||
icbp.getDataObject().readByte(message.buf);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,6 @@ import net.minecraft.item.ItemStack;
|
||||
import com.glodblock.github.client.gui.GuiFluidIO;
|
||||
import com.glodblock.github.client.gui.GuiFluidInterface;
|
||||
import com.glodblock.github.client.gui.GuiFluidLevelEmitter;
|
||||
import com.glodblock.github.client.gui.GuiFluidStorageBus;
|
||||
import com.glodblock.github.client.gui.GuiIngredientBuffer;
|
||||
import com.glodblock.github.client.gui.GuiLargeIngredientBuffer;
|
||||
import com.glodblock.github.util.Util;
|
||||
@@ -96,9 +95,6 @@ public class SPacketFluidUpdate implements IMessage {
|
||||
for (Map.Entry<Integer, IAEFluidStack> e : message.list.entrySet()) {
|
||||
((GuiFluidInterface) gs).update(e.getKey(), e.getValue());
|
||||
}
|
||||
} else if (gs instanceof GuiFluidStorageBus) {
|
||||
for (Map.Entry<Integer, IAEFluidStack> e : message.list.entrySet())
|
||||
((GuiFluidStorageBus) gs).update(e.getKey(), e.getValue());
|
||||
} else if (gs instanceof GuiFluidLevelEmitter) {
|
||||
for (Map.Entry<Integer, IAEFluidStack> e : message.list.entrySet()) {
|
||||
((GuiFluidLevelEmitter) gs).update(e.getKey(), e.getValue());
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
package com.glodblock.github.util;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import com.glodblock.github.inventory.InventoryHandler;
|
||||
import com.glodblock.github.inventory.gui.GuiType;
|
||||
|
||||
import appeng.container.PrimaryGui;
|
||||
|
||||
public class FluidPrimaryGui extends PrimaryGui {
|
||||
|
||||
public FluidPrimaryGui(Object gui, ItemStack guiIcon, TileEntity te, ForgeDirection side) {
|
||||
super(gui, guiIcon, te, side);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void open(EntityPlayer p) {
|
||||
if (gui instanceof GuiType gt) {
|
||||
if (te != null) {
|
||||
InventoryHandler.openGui(p, te.getWorldObj(), new BlockPos(te), Objects.requireNonNull(side), gt);
|
||||
} else {
|
||||
InventoryHandler.openGui(
|
||||
p,
|
||||
p.worldObj,
|
||||
new BlockPos(
|
||||
p.inventory.currentItem,
|
||||
Util.GuiHelper.encodeType(0, Util.GuiHelper.GuiType.ITEM),
|
||||
0),
|
||||
Objects.requireNonNull(side),
|
||||
gt);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@ package com.glodblock.github.util;
|
||||
|
||||
import static com.glodblock.github.common.item.ItemBaseWirelessTerminal.infinityBoosterCard;
|
||||
import static com.glodblock.github.common.item.ItemBaseWirelessTerminal.infinityEnergyCard;
|
||||
import static com.glodblock.github.common.item.ItemBaseWirelessTerminal.restockItems;
|
||||
import static com.glodblock.github.inventory.UltraTerminalButtons.restockItems;
|
||||
import static com.glodblock.github.util.Util.DimensionalCoordSide.hasEnergyCard;
|
||||
import static net.minecraft.init.Items.glass_bottle;
|
||||
|
||||
@@ -147,6 +147,13 @@ public final class Util {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void toggleRestock(ItemStack is) {
|
||||
if (is.getItem() instanceof ItemWirelessUltraTerminal) {
|
||||
NBTTagCompound data = Platform.openNbtData(is);
|
||||
data.setBoolean(restockItems, !data.getBoolean(restockItems));
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean hasInfinityBoosterCard(ItemStack is) {
|
||||
if (is.getItem() instanceof ItemBaseWirelessTerminal) {
|
||||
NBTTagCompound data = Platform.openNbtData(is);
|
||||
|
||||
Reference in new issue
Block a user