Compare commits

...
Author SHA1 Message Date
Yang Xizhi e8664328ed Merge pull request #102 from asdflj/terminal
fix cant Take/Put items in Universal Terminal
2023-03-04 13:10:41 +08:00
asdflj 84e395e470 fix cant Take/Put items in Universal Terminal 2023-03-04 08:36:21 +08:00
GlodBlock 0a01bb008b fix gl crash 2023-03-03 20:27:02 +08:00
Yang Xizhi f73f79da7b Merge pull request #100 from asdflj/terminal
terminal does not update view
2023-03-03 13:03:22 +08:00
asdflj 16f207ce80 terminal does not update view 2023-03-03 13:00:01 +08:00
GlodBlock 18f31ac3ef fix export bus exporting too much fluid 2023-03-02 16:46:35 +08:00
Yang Xizhi b205d3f53f Merge pull request #97 from asdflj/master
fluid packet decode add support to use conduit to export fluid
2023-02-28 12:24:33 +08:00
asdflj 6505967826 add fluid packet check 2023-02-28 09:06:06 +08:00
asdflj 78e9291fc6 Certus Quartz Tank add waila support
fluid packet decode add support to use conduit to export fluid
2023-02-27 16:50:29 +08:00
Yang Xizhi 6c4e12e968 Merge pull request #96 from asdflj/master
fluid export bus add schedule mode
2023-02-26 16:45:31 +08:00
asdflj ebf5a23ab9 fluid export bus add schedule mode 2023-02-26 10:46:55 +08:00
GlodBlock 161e38cbda fix fluid dupe from simulate drain 2023-02-25 22:06:29 +08:00
Yang Xizhi 948dcdcbce Merge pull request #95 from asdflj/master
fix can't be display in network details
2023-02-25 20:42:39 +08:00
asdflj 0b99ba974f fixed renamer bug 2023-02-25 19:21:52 +08:00
asdflj 2407653e96 fix universal terminal infinity connect bug 2023-02-25 11:43:21 +08:00
asdflj acfb5b1d48 add universal terminal more tips 2023-02-24 16:30:39 +08:00
asdflj 232b64e819 fix Universal terminal patten mode recipe transfer to slot item stack size error 2023-02-24 11:16:54 +08:00
asdflj 7438c7075c fix can't be display in network details 2023-02-24 09:40:21 +08:00
Yang Xizhi 9615e1cbf0 Merge pull request #86 from GTNewHorizons/blockingfix
Blockingfix
2023-02-23 20:40:23 +08:00
Martin Robertz 98c633e13d Merge pull request #94 from GTNewHorizons/master
merge from master
2023-02-22 12:12:18 +01:00
Yang Xizhi 704dbf6eec Merge pull request #92 from asdflj/master
fix bug
2023-02-22 18:35:31 +08:00
GlodBlock bf7190ce21 sa 2023-02-22 15:46:22 +08:00
GlodBlock 883ae61395 fix eio item conduit doesn't work 2023-02-22 15:44:28 +08:00
asdflj a203f2ff6b fix bug 2023-02-22 15:21:05 +08:00
GlodBlock fee5c6ee76 check gt pipe connection and fix eio fluid conduit 2023-02-21 18:22:53 +08:00
GlodBlock fb003da0a3 fix inventory check of gt machine 2023-02-21 15:36:10 +08:00
Martin Robertz 0e774f4e66 Merge pull request #91 from GTNewHorizons/master
merge master
2023-02-20 23:04:14 +01:00
Martin Robertz 25763691ca Merge pull request #90 from asdflj/master
fix fluid storage bus npe
2023-02-20 12:18:22 +01:00
asdflj bc053b2690 fix fluid storage bus crash 2023-02-20 18:19:47 +08:00
Martin Robertz 9761008907 Merge pull request #89 from GTNewHorizons/master
merge master
2023-02-18 23:25:05 +01:00
Martin Robertz 1a7acf4d28 Merge pull request #88 from asdflj/master
pattern terminal add auto fill blank pattern
2023-02-18 19:09:26 +01:00
asdflj c21752b80d fix bug 2023-02-18 14:18:22 +08:00
asdflj 80c364455d add Avaritia crafting table support 2023-02-18 14:16:40 +08:00
asdflj aef677868b add hotkey and baubles support 2023-02-17 22:34:06 +08:00
asdflj 09c1c49529 pattern terminal add auto fill blank pattern 2023-02-17 12:04:11 +08:00
Martin Robertz 18fb84de69 Merge branch 'master' into blockingfix 2023-02-16 20:41:21 +01:00
Yang Xizhi 271917c765 Merge pull request #85 from asdflj/nee
add nee support
2023-02-16 20:14:06 +08:00
GlodBlock e9c6c75ac9 ignore eio conduit in blocking check 2023-02-16 12:28:43 +08:00
asdflj 7d09bf606f add nee support 2023-02-16 11:29:34 +08:00
Martin Robertz 098561a01d Merge pull request #87 from GTNewHorizons/master
merge master
2023-02-15 17:36:17 +01:00
Yang Xizhi e292a4d35c Merge pull request #84 from asdflj/master
remove keep mouse pos
2023-02-15 18:02:13 +08:00
GlodBlock 52a985765c remove dep 2023-02-15 17:58:18 +08:00
GlodBlock 4f8811d376 make eio conduit consistant with ae2 2023-02-15 17:56:51 +08:00
asdflj bfcf33975c remove keep mouse pos 2023-02-15 09:30:13 +08:00
Yang Xizhi f3052c3353 Merge pull request #83 from asdflj/master
fix bug
2023-02-14 22:28:34 +08:00
GlodBlock b4a5c070e2 check every side in blocking mode 2023-02-14 22:20:47 +08:00
asdflj c8457bb7d3 fix bug 2023-02-14 22:12:40 +08:00
GlodBlock 0734dc4d0b add fluid name in certus tank name 2023-02-14 12:34:32 +08:00
GlodBlock 9f53884572 split client side hook code 2023-02-13 19:11:32 +08:00
Martin Robertz c9033aa93e Merge pull request #82 from asdflj/master
update zh language
2023-02-13 09:22:26 +01:00
GlodBlock 09df769db8 e 2023-02-13 15:02:04 +08:00
GlodBlock a5f7d8bed2 fix wireless terminal not usable at server 2023-02-13 14:59:31 +08:00
asdflj f66330d878 update zh language 2023-02-13 09:30:25 +08:00
Yang Xizhi 273ac040de Merge pull request #81 from GTNewHorizons/cell-housing
cell housing and multi fluid cell
2023-02-12 20:18:36 +08:00
GlodBlock 4f54c9bb28 add 5 type fluid cell 2023-02-12 20:12:23 +08:00
GlodBlock 96c7032523 add fluid cell housing 2023-02-12 19:04:04 +08:00
Yang Xizhi 7910578318 Merge pull request #80 from asdflj/cell
add cells
2023-02-12 17:10:38 +08:00
asdflj f7001d205e fix bug 2023-02-12 15:54:35 +08:00
asdflj a28bbe6e34 wireless interface terminal add switch crafting status button 2023-02-12 11:55:43 +08:00
Yang Xizhi 45e0dcbc05 Merge pull request #79 from asdflj/master
Universal wireless terminal support processing pattern terminal mode
2023-02-10 19:16:14 +08:00
Yang Xizhi 2812153280 Merge pull request #78 from asdflj/master
add wireless interface terminal
2023-02-09 12:38:03 +08:00
104 changed files with 2695 additions and 767 deletions

No files matched your search

+3 -3
View File
@@ -1,8 +1,8 @@
// Add your dependencies here
dependencies {
compile('com.github.GTNewHorizons:NotEnoughItems:2.3.21-GTNH:dev')
compile('com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-156-GTNH:dev')
compile('com.github.GTNewHorizons:NotEnoughItems:2.3.32-GTNH:dev')
compile('com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-171-GTNH:dev')
compile('curse.maven:cofh-core-69162:2388751')
compile('com.github.GTNewHorizons:waila:1.5.22:dev')
compileOnly('com.github.GTNewHorizons:ExtraCells2:2.5.32:dev') { transitive = false }
@@ -23,5 +23,5 @@ dependencies {
compileOnly('com.github.GTNewHorizons:GTplusplus:1.7.191:dev') { transitive = false }
compileOnly('com.github.GTNewHorizons:KekzTech:0.6.25:dev')
runtimeOnly('com.github.GTNewHorizons:Baubles:1.0.1.14:dev')
compile('com.github.GTNewHorizons:Baubles:1.0.1.14:dev')
}
@@ -28,7 +28,7 @@ import cpw.mods.fml.common.network.NetworkRegistry;
modid = FluidCraft.MODID,
version = FluidCraft.VERSION,
name = FluidCraft.MODNAME,
dependencies = "required-after:appliedenergistics2;required-after:CoFHCore;after:waila;after:thaumicenergistics;after:ae2wct")
dependencies = "required-after:appliedenergistics2;required-after:CoFHCore;required-after:Baubles;after:waila;after:thaumicenergistics;after:ae2wct")
public class FluidCraft {
public static final String MODID = "GRADLETOKEN_MODID";
@@ -57,6 +57,8 @@ public class GuiFCImgButton extends GuiButton implements ITooltip {
this.registerApp(13, "ESSENTIA_TEM", "YES", "essentia_terminal_w");
this.registerApp(14, "INTERFACE_TEM", "YES", "interface_terminal_w");
this.registerApp(15, "PATTERN_EX_TEM", "YES", "pattern_terminal_ex_w");
this.registerApp(16, "FILL_PATTERN", "DO_FILL", "fill_pattern");
this.registerApp(17, "NOT_FILL_PATTERN", "DONT_FILL", "not_fill_pattern");
}
}
@@ -3,11 +3,13 @@ package com.glodblock.github.client.gui;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.InventoryPlayer;
import appeng.api.config.Upgrades;
import appeng.api.storage.data.IAEFluidStack;
import appeng.client.gui.implementations.GuiUpgradeable;
import appeng.core.localization.GuiText;
import com.glodblock.github.client.gui.container.ContainerFluidIO;
import com.glodblock.github.common.parts.PartFluidExportBus;
import com.glodblock.github.common.parts.PartFluidImportBus;
import com.glodblock.github.common.parts.base.FCSharedFluidBus;
import com.glodblock.github.util.NameConst;
@@ -58,4 +60,13 @@ public class GuiFluidIO extends GuiUpgradeable {
this.schedulingMode.set(this.cvb.getSchedulingMode());
}
}
@Override
protected void handleButtonVisibility() {
super.handleButtonVisibility();
if (this.schedulingMode != null) {
this.schedulingMode.setVisibility(
this.bc.getInstalledUpgrades(Upgrades.CAPACITY) > 0 && this.bc instanceof PartFluidExportBus);
}
}
}
@@ -2,6 +2,9 @@ package com.glodblock.github.client.gui;
import net.minecraft.entity.player.InventoryPlayer;
import appeng.container.slot.AppEngSlot;
import appeng.container.slot.SlotDisabled;
import com.glodblock.github.inventory.item.IWirelessTerminal;
public class GuiFluidPatternExWireless extends GuiFluidPatternTerminalEx {
@@ -9,4 +12,13 @@ public class GuiFluidPatternExWireless extends GuiFluidPatternTerminalEx {
public GuiFluidPatternExWireless(InventoryPlayer inventoryPlayer, IWirelessTerminal te) {
super(inventoryPlayer, te);
}
@Override
protected void repositionSlot(final AppEngSlot s) {
if (s instanceof SlotDisabled || s.isPlayerSide()) {
s.yDisplayPosition = s.getY() + this.ySize - 78 - 5;
} else {
s.yDisplayPosition = s.getY() + this.ySize - 78 - 3;
}
}
}
@@ -20,6 +20,8 @@ import appeng.core.localization.GuiText;
import com.glodblock.github.client.gui.base.FCGuiEncodeTerminal;
import com.glodblock.github.client.gui.container.ContainerFluidPatternTerminal;
import com.glodblock.github.client.gui.container.ContainerFluidPatternWireless;
import com.glodblock.github.inventory.item.IWirelessTerminal;
import com.glodblock.github.util.ModAndClassUtil;
import com.glodblock.github.util.NameConst;
@@ -29,6 +31,10 @@ public class GuiFluidPatternTerminal extends FCGuiEncodeTerminal {
super(inventoryPlayer, te, new ContainerFluidPatternTerminal(inventoryPlayer, te));
}
public GuiFluidPatternTerminal(final InventoryPlayer inventoryPlayer, final IWirelessTerminal te) {
super(inventoryPlayer, te, new ContainerFluidPatternWireless(inventoryPlayer, te));
}
@Override
@SuppressWarnings("unchecked")
public void initGui() {
@@ -16,6 +16,7 @@ import com.glodblock.github.inventory.InventoryHandler;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.inventory.item.IWirelessTerminal;
import com.glodblock.github.inventory.item.WirelessFluidTerminalInventory;
import com.glodblock.github.inventory.item.WirelessInterfaceTerminalInventory;
import com.glodblock.github.inventory.item.WirelessPatternTerminalInventory;
import com.glodblock.github.loader.ItemAndBlockHolder;
import com.glodblock.github.util.Ae2ReflectClient;
@@ -44,6 +45,8 @@ public class GuiFluidPatternTerminalCraftingStatus extends GuiCraftingStatus {
Ae2ReflectClient.rewriteIcon(this, new ItemStack(ItemAndBlockHolder.WIRELESS_FLUID_TERM, 1));
} else if (host instanceof WirelessPatternTerminalInventory) {
Ae2ReflectClient.rewriteIcon(this, new ItemStack(ItemAndBlockHolder.WIRELESS_PATTERN_TERM, 1));
} else if (host instanceof WirelessInterfaceTerminalInventory) {
Ae2ReflectClient.rewriteIcon(this, new ItemStack(ItemAndBlockHolder.WIRELESS_INTERFACE_TERM, 1));
}
super.initGui();
originalGuiBtn = Ae2ReflectClient.getOriginalGuiButton(this);
@@ -62,6 +65,8 @@ public class GuiFluidPatternTerminalCraftingStatus extends GuiCraftingStatus {
InventoryHandler.switchGui(GuiType.WIRELESS_FLUID_TERMINAL);
else if (host instanceof WirelessPatternTerminalInventory)
InventoryHandler.switchGui(GuiType.WIRELESS_FLUID_PATTERN_TERMINAL);
else if (host instanceof WirelessInterfaceTerminalInventory)
InventoryHandler.switchGui(GuiType.WIRELESS_INTERFACE_TERMINAL);
} else {
super.actionPerformed(btn);
}
@@ -11,7 +11,9 @@ import appeng.client.gui.widgets.GuiImgButton;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.base.FCGuiEncodeTerminal;
import com.glodblock.github.client.gui.container.ContainerFluidPatternExWireless;
import com.glodblock.github.client.gui.container.ContainerFluidPatternTerminalEx;
import com.glodblock.github.inventory.item.IWirelessTerminal;
import com.glodblock.github.network.CPacketFluidPatternTermBtns;
import com.glodblock.github.util.ModAndClassUtil;
import com.glodblock.github.util.NameConst;
@@ -24,6 +26,12 @@ public class GuiFluidPatternTerminalEx extends FCGuiEncodeTerminal {
processingScrollBar.setTexture(FluidCraft.MODID, "gui/pattern3.png", 242, 0);
}
public GuiFluidPatternTerminalEx(final InventoryPlayer inventoryPlayer, final IWirelessTerminal te) {
super(inventoryPlayer, te, new ContainerFluidPatternExWireless(inventoryPlayer, te));
processingScrollBar.setHeight(70).setWidth(7).setLeft(6).setRange(0, 1, 1);
processingScrollBar.setTexture(FluidCraft.MODID, "gui/pattern3.png", 242, 0);
}
@Override
@SuppressWarnings("unchecked")
public void initGui() {
@@ -2,6 +2,9 @@ package com.glodblock.github.client.gui;
import net.minecraft.entity.player.InventoryPlayer;
import appeng.container.slot.AppEngSlot;
import appeng.container.slot.SlotDisabled;
import com.glodblock.github.inventory.item.IWirelessTerminal;
public class GuiFluidPatternWireless extends GuiFluidPatternTerminal {
@@ -9,4 +12,13 @@ public class GuiFluidPatternWireless extends GuiFluidPatternTerminal {
public GuiFluidPatternWireless(InventoryPlayer inventoryPlayer, IWirelessTerminal te) {
super(inventoryPlayer, te);
}
@Override
protected void repositionSlot(final AppEngSlot s) {
if (s instanceof SlotDisabled || s.isPlayerSide()) {
s.yDisplayPosition = s.getY() + this.ySize - 78 - 5;
} else {
s.yDisplayPosition = s.getY() + this.ySize - 78 - 3;
}
}
}
@@ -15,16 +15,9 @@ import org.lwjgl.input.Mouse;
import org.lwjgl.opengl.GL11;
import appeng.api.AEApi;
import appeng.api.config.ActionItems;
import appeng.api.config.Settings;
import appeng.api.config.TerminalStyle;
import appeng.api.config.YesNo;
import appeng.api.util.DimensionalCoord;
import appeng.api.config.*;
import appeng.api.util.WorldCoord;
import appeng.client.gui.widgets.GuiImgButton;
import appeng.client.gui.widgets.GuiScrollbar;
import appeng.client.gui.widgets.IDropToFillTextField;
import appeng.client.gui.widgets.MEGuiTextField;
import appeng.client.gui.widgets.*;
import appeng.client.me.ClientDCInternalInv;
import appeng.client.me.SlotDisconnected;
import appeng.client.render.BlockPosHighlighter;
@@ -43,9 +36,12 @@ import appeng.util.Platform;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.base.FCBaseMEGui;
import com.glodblock.github.client.gui.container.ContainerInterfaceWireless;
import com.glodblock.github.inventory.InventoryHandler;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.inventory.item.IWirelessTerminal;
import com.glodblock.github.network.CPacketRenamer;
import com.glodblock.github.util.ModAndClassUtil;
import com.glodblock.github.util.Util;
import com.google.common.collect.HashMultimap;
public class GuiInterfaceTerminalWireless extends FCBaseMEGui implements IDropToFillTextField {
@@ -56,7 +52,7 @@ public class GuiInterfaceTerminalWireless extends FCBaseMEGui implements IDropTo
private final HashMap<Long, ClientDCInternalInv> byId = new HashMap<>();
private final HashMultimap<String, ClientDCInternalInv> byName = HashMultimap.create();
private final HashMap<ClientDCInternalInv, DimensionalCoordSide> blockPosHashMap = new HashMap<>();
private final HashMap<ClientDCInternalInv, Util.DimensionalCoordSide> blockPosHashMap = new HashMap<>();
private final HashMap<GuiButton, ClientDCInternalInv> guiButtonHashMap = new HashMap<>();
private final ArrayList<String> names = new ArrayList<>();
private final ArrayList<Object> lines = new ArrayList<>();
@@ -78,6 +74,7 @@ public class GuiInterfaceTerminalWireless extends FCBaseMEGui implements IDropTo
private boolean refreshList = false;
protected static boolean onlyMolecularAssemblers = false;
protected static boolean onlyBrokenRecipes = false;
protected GuiTabButton craftingStatusBtn;
// private final IConfigManager configSrc;
private int rows = 3;
@@ -179,6 +176,14 @@ public class GuiInterfaceTerminalWireless extends FCBaseMEGui implements IDropTo
terminalStyleBox.xPosition = guiLeft - 18;
terminalStyleBox.yPosition = guiTop + 8;
this.buttonList.add(
this.craftingStatusBtn = new GuiTabButton(
this.guiLeft + this.xSize - 24,
this.guiTop - 4,
2 + 11 * 16,
GuiText.CraftingStatus.getLocal(),
itemRender));
this.craftingStatusBtn.setHideEdge(13); // GuiTabButton implementation //
if (ModAndClassUtil.isSearchBar && (AEConfig.instance.preserveSearchBar || this.isSubGui())) {
setSearchString();
@@ -296,6 +301,8 @@ public class GuiInterfaceTerminalWireless extends FCBaseMEGui implements IDropTo
buttonList.add(terminalStyleBox);
buttonList.add(searchStringSave);
buttonList.add(craftingStatusBtn);
this.guiButtonHashMap.clear();
addSwitchGuiBtns();
int offset = 51;
@@ -345,10 +352,15 @@ public class GuiInterfaceTerminalWireless extends FCBaseMEGui implements IDropTo
@Override
protected void actionPerformed(final GuiButton btn) {
if (guiButtonHashMap.containsKey(btn)) {
DimensionalCoordSide blockPos = blockPosHashMap.get(guiButtonHashMap.get(btn));
Util.DimensionalCoordSide blockPos = blockPosHashMap.get(guiButtonHashMap.get(btn));
if (btn instanceof GuiFCImgButton) {
FluidCraft.proxy.netHandler.sendToServer(
new CPacketRenamer(blockPos.x, blockPos.y, blockPos.z, blockPos.getDimension(), blockPos.side));
new CPacketRenamer(
blockPos.x,
blockPos.y,
blockPos.z,
blockPos.getDimension(),
blockPos.getSide()));
} else {
WorldCoord blockPos2 = new WorldCoord(
@@ -391,6 +403,8 @@ public class GuiInterfaceTerminalWireless extends FCBaseMEGui implements IDropTo
AEConfig.instance.settings.putSetting(Settings.SAVE_SEARCH, next);
this.searchStringSave.set(next);
} else if (btn == craftingStatusBtn) {
InventoryHandler.switchGui(GuiType.CRAFTING_STATUS);
} else if (btn instanceof GuiImgButton) {
final GuiImgButton iBtn = (GuiImgButton) btn;
if (iBtn.getSetting() != Settings.ACTIONS) {
@@ -488,17 +502,6 @@ public class GuiInterfaceTerminalWireless extends FCBaseMEGui implements IDropTo
return false;
}
private static class DimensionalCoordSide extends DimensionalCoord {
private ForgeDirection side = ForgeDirection.UNKNOWN;
public DimensionalCoordSide(final int _x, final int _y, final int _z, final int _dim, ForgeDirection side) {
super(_x, _y, _z, _dim);
this.side = side;
}
}
public void postUpdate(final NBTTagCompound in) {
if (in.getBoolean("clear")) {
this.byId.clear();
@@ -518,7 +521,9 @@ public class GuiInterfaceTerminalWireless extends FCBaseMEGui implements IDropTo
int Z = invData.getInteger("z");
int dim = invData.getInteger("dim");
ForgeDirection side = ForgeDirection.getOrientation(invData.getInteger("side"));
blockPosHashMap.put(current, new DimensionalCoordSide(X, Y, Z, dim, side));
blockPosHashMap.put(
current,
new Util.DimensionalCoordSide(X, Y, Z, dim, side, current.getUnlocalizedName()));
for (int x = 0; x < current.getInventory().getSizeInventory(); x++) {
final String which = Integer.toString(x);
@@ -0,0 +1,76 @@
package com.glodblock.github.client.gui;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
import appeng.api.storage.ITerminalHost;
import appeng.client.gui.AEBaseGui;
import appeng.client.gui.widgets.IDropToFillTextField;
import appeng.client.gui.widgets.MEGuiTextField;
import appeng.core.localization.GuiColors;
import appeng.core.localization.GuiText;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.container.ContainerRenamer;
import com.glodblock.github.network.CPacketRenamer;
public class GuiRenamer extends AEBaseGui implements IDropToFillTextField {
private MEGuiTextField textField;
public GuiRenamer(InventoryPlayer ip, ITerminalHost monitorable) {
super(new ContainerRenamer(ip, monitorable));
this.xSize = 256;
this.textField = new MEGuiTextField(230, 12);
this.textField.setMaxStringLength(32);
}
@Override
public void initGui() {
super.initGui();
FluidCraft.proxy.netHandler.sendToServer(new CPacketRenamer(CPacketRenamer.Action.GET_TEXT));
this.textField.x = this.guiLeft + 12;
this.textField.y = this.guiTop + 35;
this.textField.setFocused(true);
}
@Override
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY) {
this.fontRendererObj.drawString(GuiText.Renamer.getLocal(), 12, 8, GuiColors.RenamerTitle.getColor());
}
@Override
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY) {
this.bindTexture("guis/renamer.png");
this.drawTexturedModalRect(offsetX, offsetY, 0, 0, this.xSize, this.ySize);
this.textField.drawTextBox();
}
@Override
protected void mouseClicked(final int xCoord, final int yCoord, final int btn) {
this.textField.mouseClicked(xCoord, yCoord, btn);
super.mouseClicked(xCoord, yCoord, btn);
}
@Override
protected void keyTyped(final char character, final int key) {
if (key == 28) { // Enter
FluidCraft.proxy.netHandler.sendToServer(new CPacketRenamer(this.textField.getText()));
} else if (!this.textField.textboxKeyTyped(character, key)) {
super.keyTyped(character, key);
}
}
public boolean isOverTextField(final int mousex, final int mousey) {
return textField.isMouseIn(mousex, mousey);
}
public void setTextFieldValue(final String displayName, final int mousex, final int mousey, final ItemStack stack) {
textField.setText(displayName);
}
public void postUpdate(String text) {
this.textField.setText(text);
}
}
@@ -10,10 +10,11 @@ import net.minecraft.inventory.Container;
import appeng.client.gui.AEBaseMEGui;
import com.glodblock.github.client.gui.*;
import com.glodblock.github.client.gui.container.base.FCBaseContainer;
import com.glodblock.github.common.item.ItemWirelessUltraTerminal;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.inventory.item.IWirelessTerminal;
import com.glodblock.github.util.ModAndClassUtil;
import com.glodblock.github.util.Util;
public abstract class FCBaseMEGui extends AEBaseMEGui {
@@ -28,21 +29,23 @@ public abstract class FCBaseMEGui extends AEBaseMEGui {
public FCBaseMEGui(final InventoryPlayer inventoryPlayer, Container container) {
super(container);
if (inventoryPlayer.getCurrentItem() != null
&& inventoryPlayer.getCurrentItem().getItem() instanceof ItemWirelessUltraTerminal)
this.drawSwitchGuiBtn = true;
if (container instanceof FCBaseContainer) {
Object target = ((FCBaseContainer) container).getTarget();
if (target instanceof IWirelessTerminal
&& ((IWirelessTerminal) target).getItemStack().getItem() instanceof ItemWirelessUltraTerminal) {
this.drawSwitchGuiBtn = true;
}
}
}
@Override
public void onGuiClosed() {
super.onGuiClosed();
Util.MouseHandler.saveMousePos();
}
protected void initGuiDone() {
if (drawSwitchGuiBtn) {
drawSwitchGuiBtns();
Util.MouseHandler.loadMousePos();
}
}
@@ -138,14 +141,4 @@ public abstract class FCBaseMEGui extends AEBaseMEGui {
}
super.actionPerformed(btn);
}
@Override
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY) {
}
@Override
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY) {
}
}
@@ -51,6 +51,8 @@ public abstract class FCGuiEncodeTerminal extends GuiItemMonitor {
protected GuiImgButton beSubstitutionsDisabledBtn;
protected GuiFCImgButton combineEnableBtn;
protected GuiFCImgButton combineDisableBtn;
protected GuiFCImgButton autoFillPatternEnableBtn;
protected GuiFCImgButton autoFillPatternDisableBtn;
protected final GuiScrollbar processingScrollBar = new GuiScrollbar();
protected final AppEngRenderItem stackSizeRenderer = Ae2ReflectClient.getStackSizeRenderer(this);
@@ -62,6 +64,24 @@ public abstract class FCGuiEncodeTerminal extends GuiItemMonitor {
setReservedSpace(81);
}
@Override
public void initGui() {
super.initGui();
this.buttonList.add(
this.autoFillPatternEnableBtn = new GuiFCImgButton(
this.guiLeft - 18,
this.offsetY,
"FILL_PATTERN",
"DO_FILL"));
this.buttonList.add(
this.autoFillPatternDisableBtn = new GuiFCImgButton(
this.guiLeft - 18,
this.offsetY,
"NOT_FILL_PATTERN",
"DONT_FILL"));
this.offsetY += 20;
}
@Override
protected void actionPerformed(final GuiButton btn) {
super.actionPerformed(btn);
@@ -108,6 +128,11 @@ public abstract class FCGuiEncodeTerminal extends GuiItemMonitor {
} else if (ModAndClassUtil.isBeSubstitutionsButton && beSubstitutionsEnabledBtn == btn) {
FluidCraft.proxy.netHandler
.sendToServer(new CPacketFluidPatternTermBtns("PatternTerminal.beSubstitute", "0"));
} else if (this.autoFillPatternDisableBtn == btn || this.autoFillPatternEnableBtn == btn) {
FluidCraft.proxy.netHandler.sendToServer(
new CPacketFluidPatternTermBtns(
"PatternTerminal.AutoFillerPattern",
this.autoFillPatternDisableBtn == btn ? "1" : "0"));
}
}
@@ -124,6 +149,8 @@ public abstract class FCGuiEncodeTerminal extends GuiItemMonitor {
updateButton(this.beSubstitutionsDisabledBtn, !this.container.beSubstitute);
updateButton(this.fluidPrioritizedEnabledBtn, this.container.prioritize);
updateButton(this.fluidPrioritizedDisabledBtn, !this.container.prioritize);
updateButton(this.autoFillPatternEnableBtn, this.container.autoFillPattern);
updateButton(this.autoFillPatternDisableBtn, !this.container.autoFillPattern);
super.drawFG(offsetX, offsetY, mouseX, mouseY);
}
@@ -33,10 +33,8 @@ import appeng.core.AEConfig;
import appeng.core.AELog;
import appeng.core.localization.ButtonToolTips;
import appeng.core.localization.GuiText;
import appeng.core.sync.GuiBridge;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketInventoryAction;
import appeng.core.sync.packets.PacketSwitchGuis;
import appeng.core.sync.packets.PacketValueConfig;
import appeng.helpers.InventoryAction;
import appeng.integration.IntegrationRegistry;
@@ -50,6 +48,8 @@ import codechicken.nei.util.TextHistory;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.*;
import com.glodblock.github.client.gui.container.base.FCContainerMonitor;
import com.glodblock.github.inventory.InventoryHandler;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.network.CPacketInventoryAction;
import com.glodblock.github.util.Ae2ReflectClient;
import com.glodblock.github.util.ModAndClassUtil;
@@ -119,7 +119,7 @@ public abstract class FCGuiMonitor<T extends IAEStack<T>> extends FCBaseMEGui
@Override
protected void actionPerformed(final GuiButton btn) {
if (btn == this.craftingStatusBtn || btn == this.craftingStatusImgBtn) {
NetworkHandler.instance.sendToServer(new PacketSwitchGuis(GuiBridge.GUI_CRAFTING_STATUS));
InventoryHandler.switchGui(GuiType.CRAFTING_STATUS);
}
if (btn instanceof GuiImgButton) {
final boolean backwards = Mouse.isButtonDown(1);
@@ -314,7 +314,7 @@ public abstract class FCGuiMonitor<T extends IAEStack<T>> extends FCBaseMEGui
for (final Object s : this.inventorySlots.inventorySlots) {
if (s instanceof AppEngSlot) {
if (((Slot) s).xDisplayPosition < 195) {
if (((Slot) s).xDisplayPosition < 195 || s instanceof SlotDisabled) {
this.repositionSlot((AppEngSlot) s);
}
}
@@ -11,8 +11,10 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.ICrafting;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ChatComponentText;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import appeng.api.AEApi;
import appeng.api.config.Actionable;
@@ -37,10 +39,12 @@ import appeng.core.AELog;
import appeng.util.Platform;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.common.item.ItemBaseWirelessTerminal;
import com.glodblock.github.common.parts.PartFluidPatternTerminal;
import com.glodblock.github.common.parts.PartFluidPatternTerminalEx;
import com.glodblock.github.inventory.InventoryHandler;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.inventory.item.IWirelessTerminal;
import com.glodblock.github.network.SPacketMEInventoryUpdate;
import com.glodblock.github.util.Ae2Reflect;
import com.glodblock.github.util.BlockPos;
@@ -269,6 +273,12 @@ public class ContainerFluidCraftConfirm extends AEBaseContainer {
if (ah instanceof PartFluidPatternTerminalEx) {
originalGui = GuiType.FLUID_PATTERN_TERMINAL_EX;
}
if (ah instanceof IWirelessTerminal) {
ItemStack terminal = ((IWirelessTerminal) ah).getItemStack();
if (terminal.getItem() instanceof ItemBaseWirelessTerminal) {
originalGui = ((ItemBaseWirelessTerminal) terminal.getItem()).guiGuiType(terminal);
}
}
if (this.result != null && !this.isSimulation() && getGrid() != null) {
final ICraftingGrid cc = this.getGrid().getCache(ICraftingGrid.class);
@@ -279,13 +289,22 @@ public class ContainerFluidCraftConfirm extends AEBaseContainer {
true,
this.getActionSrc());
this.setAutoStart(false);
if (g != null && originalGui != null && this.getOpenContext() != null) {
InventoryHandler.openGui(
this.getInventoryPlayer().player,
getWorld(),
new BlockPos(this.getOpenContext().getTile()),
Objects.requireNonNull(this.getOpenContext().getSide()),
originalGui);
if (g != null && originalGui != null) {
if (ah instanceof IWirelessTerminal) {
InventoryHandler.openGui(
this.getInventoryPlayer().player,
getWorld(),
new BlockPos(((IWirelessTerminal) ah).getInventorySlot(), 0, 0),
ForgeDirection.UNKNOWN,
originalGui);
} else if (this.getOpenContext() != null) {
InventoryHandler.openGui(
this.getInventoryPlayer().player,
getWorld(),
new BlockPos(this.getOpenContext().getTile()),
Objects.requireNonNull(this.getOpenContext().getSide()),
originalGui);
}
}
}
}
@@ -2,6 +2,7 @@ package com.glodblock.github.client.gui.container;
import net.minecraft.entity.player.InventoryPlayer;
import appeng.api.config.SchedulingMode;
import appeng.api.config.Settings;
import appeng.api.config.YesNo;
import appeng.api.util.IConfigManager;
@@ -35,6 +36,11 @@ public class ContainerFluidIO extends FCContainerFluidConfigurable {
super.loadSettingsFromHost(cm);
if (Ae2Reflect.getUpgradeableHost(this) instanceof PartFluidExportBus) {
this.setCraftingMode((YesNo) cm.getSetting(Settings.CRAFT_ONLY));
this.setSchedulingMode((SchedulingMode) cm.getSetting(Settings.SCHEDULING_MODE));
}
}
public void setSchedulingMode(final SchedulingMode schedulingMode) {
this.schedulingMode = schedulingMode;
}
}
@@ -18,8 +18,6 @@ import org.apache.commons.lang3.tuple.MutablePair;
import appeng.api.AEApi;
import appeng.api.config.Actionable;
import appeng.api.implementations.guiobjects.IPortableCell;
import appeng.api.implementations.tiles.IMEChest;
import appeng.api.implementations.tiles.IViewCellStorage;
import appeng.api.networking.IGrid;
import appeng.api.networking.IGridHost;
@@ -28,6 +26,7 @@ import appeng.api.networking.energy.IEnergyGrid;
import appeng.api.networking.energy.IEnergySource;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.networking.storage.IBaseMonitor;
import appeng.api.networking.storage.IStorageGrid;
import appeng.api.storage.ITerminalHost;
import appeng.api.storage.data.IAEFluidStack;
import appeng.api.storage.data.IItemList;
@@ -42,7 +41,6 @@ import appeng.util.item.AEItemStack;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.container.base.FCContainerMonitor;
import com.glodblock.github.common.item.ItemFluidDrop;
import com.glodblock.github.inventory.item.IFluidPortableCell;
import com.glodblock.github.network.CPacketFluidUpdate;
import com.glodblock.github.network.SPacketFluidUpdate;
import com.glodblock.github.network.SPacketMEInventoryUpdate;
@@ -61,27 +59,28 @@ public class ContainerFluidMonitor extends FCContainerMonitor<IAEFluidStack> {
super(ip, monitorable, bindInventory);
if (Platform.isServer()) {
this.serverCM = monitorable.getConfigManager();
this.monitor = monitorable.getFluidInventory();
if (this.monitor != null) {
this.monitor.addListener(this, null);
if (monitorable instanceof IFluidPortableCell) {
this.setPowerSource((IEnergySource) monitorable);
} else if (monitorable instanceof IPortableCell) {
this.setPowerSource((IEnergySource) monitorable);
} else if (monitorable instanceof IMEChest) {
this.setPowerSource((IEnergySource) monitorable);
} else if (monitorable instanceof IGridHost) {
final IGridNode node = ((IGridHost) monitorable).getGridNode(ForgeDirection.UNKNOWN);
if (node != null) {
this.networkNode = node;
final IGrid g = node.getGrid();
if (g != null) {
this.setPowerSource(new ChannelPowerSrc(this.networkNode, g.getCache(IEnergyGrid.class)));
if (monitorable instanceof IGridHost) {
final IGridNode node = ((IGridHost) monitorable).getGridNode(ForgeDirection.UNKNOWN);
if (node != null) {
this.networkNode = node;
final IGrid g = node.getGrid();
if (g != null) {
this.setPowerSource(new ChannelPowerSrc(this.networkNode, g.getCache(IEnergyGrid.class)));
IStorageGrid storageGrid = g.getCache(IStorageGrid.class);
this.monitor = storageGrid.getFluidInventory();
if (this.monitor == null) {
this.setValidContainer(false);
} else {
this.monitor.addListener(this, null);
}
}
} else {
this.setValidContainer(false);
}
} else {
this.setValidContainer(false);
this.monitor = monitorable.getFluidInventory();
this.monitor.addListener(this, null);
this.setPowerSource((IEnergySource) monitorable);
}
} else {
this.monitor = null;
@@ -151,11 +150,6 @@ public class ContainerFluidMonitor extends FCContainerMonitor<IAEFluidStack> {
}
}
@Override
protected boolean isInvalid() {
return this.monitor != this.host.getFluidInventory();
}
@Override
protected void queueInventory(final ICrafting c) {
if (Platform.isServer() && c instanceof EntityPlayer && this.monitor != null) {
@@ -224,26 +218,38 @@ public class ContainerFluidMonitor extends FCContainerMonitor<IAEFluidStack> {
MutablePair<Integer, ItemStack> fillStack = Util.FluidUtil.fillStack(out, toExtract.getFluidStack());
if (fillStack.right == null || fillStack.left <= 0) continue;
toExtract.setStackSize((long) fillStack.left * fluidContainer.stackSize);
IAEFluidStack tmp = this.host.getFluidInventory()
.extractItems(toExtract, Actionable.SIMULATE, this.getActionSource());
if (tmp == null) continue;
fillStack.right.stackSize = (int) (tmp.getStackSize() / fillStack.left);
this.dropItem(fillStack.right);
out.stackSize = fillStack.right.stackSize;
// The real result may don't match simulation result.
if (fillStack.right.getItem() instanceof IFluidContainerItem) {
this.host.getFluidInventory().extractItems(toExtract, Actionable.MODULATE, this.getActionSource());
if ((int) (tmp.getStackSize() % fillStack.left) > 0) {
IAEFluidStack real = this.host.getFluidInventory()
.extractItems(toExtract, Actionable.MODULATE, this.getActionSource());
if (real == null) continue;
// Refill the container
out = fluidContainer.copy();
out.stackSize = 1;
fillStack = Util.FluidUtil.fillStack(out, real.getFluidStack());
fillStack.right.stackSize = (int) (real.getStackSize() / fillStack.left);
out.stackSize = fillStack.right.stackSize;
if ((int) (real.getStackSize() % fillStack.left) > 0) {
this.dropItem(
Util.FluidUtil.setFluidContainerAmount(
fillStack.right,
(int) (tmp.getStackSize() % fillStack.left)),
(int) (real.getStackSize() % fillStack.left)),
1);
out.stackSize++;
}
} else if (FluidContainerRegistry.isContainer(fillStack.right)) {
IAEFluidStack real = this.host.getFluidInventory()
.extractItems(toExtract, Actionable.MODULATE, this.getActionSource());
if (real == null) continue;
// Refill the container
out = fluidContainer.copy();
out.stackSize = 1;
fillStack = Util.FluidUtil.fillStack(out, real.getFluidStack());
fillStack.right.stackSize = (int) (real.getStackSize() / fillStack.left);
out.stackSize = fillStack.right.stackSize;
toExtract.setStackSize((long) fillStack.right.stackSize * fillStack.left);
this.host.getFluidInventory().extractItems(toExtract, Actionable.MODULATE, this.getActionSource());
}
this.dropItem(fillStack.right);
} else if (!Util.FluidUtil.isEmpty(fluidContainer)) {
// add fluid to ae network
AEFluidStack fluidStack = Util.getAEFluidFromItem(fluidContainer);
@@ -9,8 +9,6 @@ import net.minecraft.inventory.ICrafting;
import net.minecraftforge.common.util.ForgeDirection;
import appeng.api.AEApi;
import appeng.api.implementations.guiobjects.IPortableCell;
import appeng.api.implementations.tiles.IMEChest;
import appeng.api.implementations.tiles.IViewCellStorage;
import appeng.api.networking.IGrid;
import appeng.api.networking.IGridHost;
@@ -19,6 +17,7 @@ import appeng.api.networking.energy.IEnergyGrid;
import appeng.api.networking.energy.IEnergySource;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.networking.storage.IBaseMonitor;
import appeng.api.networking.storage.IStorageGrid;
import appeng.api.storage.ITerminalHost;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IItemList;
@@ -43,26 +42,30 @@ public class ContainerItemMonitor extends FCContainerMonitor<IAEItemStack> {
super(ip, monitorable, bindInventory);
if (Platform.isServer()) {
this.serverCM = monitorable.getConfigManager();
this.monitor = monitorable.getItemInventory();
if (this.monitor != null) {
this.monitor.addListener(this, null);
this.setCellInventory(this.monitor);
if (monitorable instanceof IPortableCell) {
this.setPowerSource((IEnergySource) monitorable);
} else if (monitorable instanceof IMEChest) {
this.setPowerSource((IEnergySource) monitorable);
} else if (monitorable instanceof IGridHost) {
final IGridNode node = ((IGridHost) monitorable).getGridNode(ForgeDirection.UNKNOWN);
if (node != null) {
this.networkNode = node;
final IGrid g = node.getGrid();
if (g != null) {
this.setPowerSource(new ChannelPowerSrc(this.networkNode, g.getCache(IEnergyGrid.class)));
if (monitorable instanceof IGridHost) {
final IGridNode node = ((IGridHost) monitorable).getGridNode(ForgeDirection.UNKNOWN);
if (node != null) {
this.networkNode = node;
final IGrid g = node.getGrid();
if (g != null) {
this.setPowerSource(new ChannelPowerSrc(this.networkNode, g.getCache(IEnergyGrid.class)));
IStorageGrid storageGrid = g.getCache(IStorageGrid.class);
this.monitor = storageGrid.getItemInventory();
if (this.monitor == null) {
this.setValidContainer(false);
} else {
this.monitor.addListener(this, null);
this.setCellInventory(this.monitor);
}
}
} else {
this.setValidContainer(false);
}
} else {
this.setValidContainer(false);
this.monitor = monitorable.getItemInventory();
this.monitor.addListener(this, null);
this.setCellInventory(this.monitor);
this.setPowerSource((IEnergySource) monitorable);
}
} else {
this.monitor = null;
@@ -0,0 +1,13 @@
package com.glodblock.github.client.gui.container;
import net.minecraft.entity.player.InventoryPlayer;
import appeng.api.storage.ITerminalHost;
import appeng.container.AEBaseContainer;
public class ContainerRenamer extends AEBaseContainer {
public ContainerRenamer(InventoryPlayer ip, ITerminalHost monitorable) {
super(ip, monitorable);
}
}
@@ -29,7 +29,9 @@ public abstract class FCBaseContainer extends AEBaseContainer {
if (isWirelessTerminal()) {
if (this.host != null) {
final int slotIndex = this.host.getInventorySlot();
this.lockPlayerInventorySlot(slotIndex);
if (Util.GuiHelper.decodeInvType(slotIndex).getLeft() == Util.GuiHelper.InvType.PLAYER_INV) {
this.lockPlayerInventorySlot(slotIndex);
}
return slotIndex;
} else {
this.lockPlayerInventorySlot(ip.currentItem);
@@ -18,6 +18,7 @@ import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.IFluidContainerItem;
import appeng.api.AEApi;
import appeng.api.config.Actionable;
import appeng.api.definitions.IDefinitions;
import appeng.api.storage.ITerminalHost;
import appeng.api.storage.data.IAEItemStack;
@@ -75,6 +76,9 @@ public abstract class FCContainerEncodeTerminal extends ContainerItemMonitor
@GuiSync(91)
public boolean prioritize = false;
@GuiSync(90)
public boolean autoFillPattern = false;
public FCContainerEncodeTerminal(final InventoryPlayer ip, final ITerminalHost monitorable) {
super(ip, monitorable);
this.patternTerminal = (IItemPatternTerminal) monitorable;
@@ -302,6 +306,7 @@ public abstract class FCContainerEncodeTerminal extends ContainerItemMonitor
}
this.patternSlotOUT.putStack(null);
}
fillPattern();
}
public void encodeAllItemAndMoveToInventory() {
@@ -315,9 +320,38 @@ public abstract class FCContainerEncodeTerminal extends ContainerItemMonitor
this.patternSlotOUT.putStack(null);
this.patternSlotIN.putStack(null);
}
fillPattern();
}
private void fillPattern() {
if (this.autoFillPattern && this.getHost().getItemInventory() != null) {
// try to use me network item to fill pattern input slot
final IDefinitions definitions = AEApi.instance().definitions();
int fillStackSize = this.patternSlotIN.getHasStack() ? 64 - this.patternSlotIN.getStack().stackSize : 64;
if (fillStackSize == 0) return;
for (ItemStack blankPattern : definitions.materials().blankPattern().maybeStack(fillStackSize).asSet()) {
IAEItemStack iBlankPattern = AEApi.instance().storage().createItemStack(blankPattern);
if (this.patternSlotIN.getHasStack() && !iBlankPattern.isSameType(this.patternSlotIN.getStack()))
continue;
IAEItemStack out = this.getHost().getItemInventory()
.extractItems(iBlankPattern, Actionable.MODULATE, this.getActionSource());
if (out != null) {
ItemStack outPattern;
if (this.patternSlotIN.getHasStack()) {
outPattern = this.patternSlotIN.getStack().copy();
outPattern.stackSize += out.getItemStack().stackSize;
} else {
outPattern = out.getItemStack();
}
this.patternSlotIN.putStack(outPattern);
return;
}
}
}
}
public void encode() {
fillPattern();
if (!checkHasFluidPattern()) {
encodeItemPattern();
return;
@@ -454,6 +488,7 @@ public abstract class FCContainerEncodeTerminal extends ContainerItemMonitor
this.combine = this.patternTerminal.shouldCombine();
this.beSubstitute = this.patternTerminal.canBeSubstitute();
this.prioritize = this.patternTerminal.isPrioritize();
this.autoFillPattern = this.patternTerminal.isAutoFillPattern();
}
}
@@ -112,7 +112,7 @@ public abstract class FCContainerMonitor<T extends IAEStack<T>> extends FCBaseCo
protected abstract void processItemList();
protected boolean isInvalid() {
return this.monitor != this.host.getItemInventory();
return this.monitor == null;
}
protected void updatePowerStatus() {
@@ -10,6 +10,9 @@ import net.minecraft.tileentity.TileEntity;
import appeng.block.AEBaseTileBlock;
import appeng.core.features.AEFeature;
import appeng.core.features.ActivityState;
import appeng.core.features.BlockStackSrc;
import appeng.tile.AEBaseTile;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.loader.IRegister;
@@ -27,6 +30,7 @@ public abstract class FCBaseBlock extends AEBaseTileBlock implements IRegister<F
@Override
public void setTileEntity(final Class<? extends TileEntity> clazz) {
AEBaseTile.registerTileItem(clazz, new BlockStackSrc(this, 0, ActivityState.Enabled));
super.setTileEntity(clazz);
}
@@ -0,0 +1,270 @@
package com.glodblock.github.common.item;
import java.text.NumberFormat;
import java.util.EnumSet;
import java.util.List;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.StatCollector;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import appeng.api.AEApi;
import appeng.api.config.FuzzyMode;
import appeng.api.config.IncludeExclude;
import appeng.api.implementations.items.IUpgradeModule;
import appeng.api.storage.IMEInventoryHandler;
import appeng.api.storage.StorageChannel;
import appeng.api.storage.data.IAEFluidStack;
import appeng.api.storage.data.IItemList;
import appeng.core.features.AEFeature;
import appeng.core.localization.GuiText;
import appeng.items.AEBaseItem;
import appeng.items.contents.CellConfig;
import appeng.items.contents.CellUpgrades;
import appeng.util.InventoryAdaptor;
import appeng.util.Platform;
import appeng.util.ReadableNumberConverter;
import com.glodblock.github.common.Config;
import com.glodblock.github.common.storage.CellType;
import com.glodblock.github.common.storage.IFluidCellInventory;
import com.glodblock.github.common.storage.IFluidCellInventoryHandler;
import com.glodblock.github.common.storage.IStorageFluidCell;
import com.glodblock.github.loader.ItemAndBlockHolder;
import com.glodblock.github.util.ModAndClassUtil;
import com.glodblock.github.util.NameConst;
import com.google.common.base.Optional;
public abstract class FCBaseItemCell extends AEBaseItem implements IStorageFluidCell {
protected CellType component;
protected long totalBytes;
protected int perType;
protected double idleDrain;
protected int maxType = 1;
private final ReadableNumberConverter format = ReadableNumberConverter.INSTANCE;
@SuppressWarnings("Guava")
public FCBaseItemCell(long bytes, int perType, int totalType, double drain) {
super(Optional.of(bytes / 1024 + "k"));
this.setFeature(EnumSet.of(AEFeature.StorageCells));
this.setMaxStackSize(1);
this.totalBytes = bytes;
this.perType = perType;
this.idleDrain = drain;
this.maxType = totalType;
this.component = null;
}
@SuppressWarnings("all")
public FCBaseItemCell(final Optional<String> subName) {
super(subName);
}
public ItemStack getHousing() {
return ItemAndBlockHolder.CELL_HOUSING.stack();
}
public ItemStack getComponent() {
return component.stack(1);
}
@Override
public long getBytes(ItemStack cellItem) {
return this.totalBytes;
}
@Override
public int getBytesPerType(ItemStack cellItem) {
return this.perType;
}
@Override
public boolean isBlackListed(ItemStack cellItem, IAEFluidStack requestedAddition) {
if (Config.blacklistEssentiaGas && ModAndClassUtil.ThE && requestedAddition != null) {
return ModAndClassUtil.essentiaGas.isInstance(requestedAddition.getFluid());
}
return false;
}
@Override
public void addCheckedInformation(final ItemStack stack, final EntityPlayer player, final List<String> lines,
final boolean displayMoreInfo) {
final IMEInventoryHandler<?> inventory = AEApi.instance().registries().cell()
.getCellInventory(stack, null, StorageChannel.FLUIDS);
if (inventory instanceof IFluidCellInventoryHandler) {
final IFluidCellInventoryHandler handler = (IFluidCellInventoryHandler) inventory;
final IFluidCellInventory cellInventory = handler.getCellInv();
if (cellInventory != null) {
lines.add(
EnumChatFormatting.WHITE + String.valueOf(cellInventory.getUsedBytes())
+ EnumChatFormatting.GRAY
+ " "
+ GuiText.Of.getLocal()
+ " "
+ EnumChatFormatting.DARK_GREEN
+ NumberFormat.getInstance().format(cellInventory.getTotalBytes())
+ " "
+ EnumChatFormatting.GRAY
+ GuiText.BytesUsed.getLocal());
lines.add(
EnumChatFormatting.WHITE + String.valueOf(cellInventory.getStoredFluidTypes())
+ EnumChatFormatting.GRAY
+ " "
+ GuiText.Of.getLocal()
+ " "
+ EnumChatFormatting.DARK_GREEN
+ cellInventory.getTotalFluidTypes()
+ " "
+ EnumChatFormatting.GRAY
+ GuiText.Types.getLocal());
if (GuiScreen.isCtrlKeyDown()) {
if (cellInventory.getStoredFluidTypes() > 0) {
lines.add(StatCollector.translateToLocal(NameConst.TT_CELL_CONTENTS));
for (IAEFluidStack fluid : cellInventory.getContents()) {
if (fluid != null) {
lines.add(
String.format(
" %s x%s mB",
fluid.getFluidStack().getLocalizedName(),
format.toWideReadableForm(fluid.getStackSize())));
}
}
} else {
lines.add(StatCollector.translateToLocal(NameConst.TT_CELL_EMPTY));
}
} else {
lines.add(StatCollector.translateToLocal(NameConst.TT_CTRL_FOR_MORE));
}
if (handler.isPreformatted()) {
final String list = (handler.getIncludeExcludeMode() == IncludeExclude.WHITELIST ? GuiText.Included
: GuiText.Excluded).getLocal();
lines.add(GuiText.Partitioned.getLocal() + " - " + list + ' ' + GuiText.Precise.getLocal());
if (GuiScreen.isShiftKeyDown()) {
lines.add(GuiText.Filter.getLocal() + ": ");
for (IAEFluidStack aeFluidStack : handler.getPartitionInv()) {
if (aeFluidStack != null) lines.add(" " + aeFluidStack.getFluidStack().getLocalizedName());
}
} else {
lines.add(StatCollector.translateToLocal(NameConst.TT_SHIFT_FOR_MORE));
}
}
}
}
}
@Override
public boolean storableInStorageCell() {
return false;
}
@Override
public boolean isStorageCell(ItemStack i) {
return true;
}
@Override
public double getIdleDrain() {
return this.idleDrain;
}
@Override
public int getTotalTypes(final ItemStack cellItem) {
return this.maxType;
}
@Override
public boolean isEditable(ItemStack is) {
return true;
}
@Override
public IInventory getUpgradesInventory(ItemStack is) {
return new CellUpgrades(is, 0);
}
@Override
public IInventory getConfigInventory(ItemStack is) {
return new CellConfig(is);
}
@Override
public FuzzyMode getFuzzyMode(ItemStack is) {
final String fz = Platform.openNbtData(is).getString("FuzzyMode");
try {
return FuzzyMode.valueOf(fz);
} catch (final Throwable t) {
return FuzzyMode.IGNORE_ALL;
}
}
@Override
public void setFuzzyMode(ItemStack is, FuzzyMode fzMode) {
Platform.openNbtData(is).setString("FuzzyMode", fzMode.name());
}
@SuppressWarnings("unchecked")
protected boolean disassembleDrive(final ItemStack stack, final World world, final EntityPlayer player) {
if (player.isSneaking()) {
if (Platform.isClient()) {
return false;
}
final InventoryPlayer playerInventory = player.inventory;
final IMEInventoryHandler<?> inv = AEApi.instance().registries().cell()
.getCellInventory(stack, null, StorageChannel.FLUIDS);
if (inv != null && playerInventory.getCurrentItem() == stack) {
final InventoryAdaptor ia = InventoryAdaptor.getAdaptor(player, ForgeDirection.UNKNOWN);
final IItemList<IAEFluidStack> list = inv.getAvailableItems(StorageChannel.FLUIDS.createList());
if (list.isEmpty() && ia != null) {
playerInventory.setInventorySlotContents(playerInventory.currentItem, null);
// drop core
final ItemStack extraB = ia.addItems(this.component.stack(1));
if (extraB != null) {
player.dropPlayerItemWithRandomChoice(extraB, false);
}
// drop upgrades
final IInventory upgradesInventory = this.getUpgradesInventory(stack);
for (int upgradeIndex = 0; upgradeIndex < upgradesInventory.getSizeInventory(); upgradeIndex++) {
final ItemStack upgradeStack = upgradesInventory.getStackInSlot(upgradeIndex);
final ItemStack leftStack = ia.addItems(upgradeStack);
if (leftStack != null && upgradeStack.getItem() instanceof IUpgradeModule) {
player.dropPlayerItemWithRandomChoice(upgradeStack, false);
}
}
// drop empty storage cell case
final ItemStack extraA = ia.addItems(this.getHousing());
if (extraA != null) {
player.dropPlayerItemWithRandomChoice(this.getHousing(), false);
}
if (player.inventoryContainer != null) {
player.inventoryContainer.detectAndSendChanges();
}
return true;
}
}
}
return false;
}
public ItemStack stack(int size) {
return new ItemStack(this, size);
}
public ItemStack stack() {
return new ItemStack(this, 1);
}
}
@@ -11,6 +11,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.event.ForgeEventFactory;
import appeng.api.AEApi;
import appeng.api.features.ILocatable;
@@ -18,6 +19,7 @@ import appeng.api.features.IWirelessTermHandler;
import appeng.api.features.IWirelessTermRegistry;
import appeng.core.localization.PlayerMessages;
import appeng.items.tools.powered.ToolWirelessTerminal;
import appeng.util.Platform;
import com.glodblock.github.inventory.InventoryHandler;
import com.glodblock.github.inventory.gui.GuiType;
@@ -41,32 +43,37 @@ public class ItemBaseWirelessTerminal extends ToolWirelessTerminal implements II
@Override
public ItemStack onItemRightClick(final ItemStack item, final World w, final EntityPlayer player) {
if (player.isSneaking()) return removeInfinityBoosterCard(player, item);
IWirelessTermRegistry term = AEApi.instance().registries().wireless();
if (!term.isWirelessTerminal(item)) {
player.addChatMessage(PlayerMessages.DeviceNotWirelessTerminal.get());
return item;
}
final IWirelessTermHandler handler = term.getWirelessTerminalHandler(item);
final String unparsedKey = handler.getEncryptionKey(item);
if (unparsedKey.isEmpty()) {
player.addChatMessage(PlayerMessages.DeviceNotLinked.get());
return item;
}
final long parsedKey = Long.parseLong(unparsedKey);
final ILocatable securityStation = AEApi.instance().registries().locatable().getLocatableBy(parsedKey);
if (securityStation == null) {
player.addChatMessage(PlayerMessages.StationCanNotBeLocated.get());
return item;
}
if (handler.hasPower(player, 0.5, item)) {
InventoryHandler.openGui(
player,
w,
new BlockPos(player.inventory.currentItem, 0, 0),
ForgeDirection.UNKNOWN,
this.guiGuiType(item));
} else {
player.addChatMessage(PlayerMessages.DeviceNotPowered.get());
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.get());
return item;
}
final IWirelessTermHandler handler = term.getWirelessTerminalHandler(item);
final String unparsedKey = handler.getEncryptionKey(item);
if (unparsedKey.isEmpty()) {
player.addChatMessage(PlayerMessages.DeviceNotLinked.get());
return item;
}
final long parsedKey = Long.parseLong(unparsedKey);
final ILocatable securityStation = AEApi.instance().registries().locatable().getLocatableBy(parsedKey);
if (securityStation == null) {
player.addChatMessage(PlayerMessages.StationCanNotBeLocated.get());
return item;
}
if (handler.hasPower(player, 0.5, item)) {
InventoryHandler.openGui(
player,
w,
new BlockPos(player.inventory.currentItem, 0, 0),
ForgeDirection.UNKNOWN,
this.guiGuiType(item));
} else {
player.addChatMessage(PlayerMessages.DeviceNotPowered.get());
}
}
return item;
@@ -99,7 +106,7 @@ public class ItemBaseWirelessTerminal extends ToolWirelessTerminal implements II
@Override
public boolean canHandle(final ItemStack is) {
return is.getItem() == this;
return is.getItem() instanceof ItemBaseWirelessTerminal;
}
public ItemStack stack() {
@@ -1,51 +1,28 @@
package com.glodblock.github.common.item;
import java.text.NumberFormat;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.List;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.IIcon;
import net.minecraft.util.StatCollector;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.event.ForgeEventFactory;
import appeng.api.AEApi;
import appeng.api.config.FuzzyMode;
import appeng.api.config.IncludeExclude;
import appeng.api.exceptions.MissingDefinition;
import appeng.api.implementations.items.IUpgradeModule;
import appeng.api.storage.IMEInventoryHandler;
import appeng.api.storage.StorageChannel;
import appeng.api.storage.data.IAEFluidStack;
import appeng.api.storage.data.IItemList;
import appeng.core.AEConfig;
import appeng.core.features.AEFeature;
import appeng.core.localization.GuiText;
import appeng.items.AEBaseItem;
import appeng.items.contents.CellConfig;
import appeng.items.contents.CellUpgrades;
import appeng.util.InventoryAdaptor;
import appeng.util.Platform;
import appeng.util.ReadableNumberConverter;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.common.Config;
import com.glodblock.github.common.storage.CellType;
import com.glodblock.github.common.storage.IFluidCellInventory;
import com.glodblock.github.common.storage.IFluidCellInventoryHandler;
import com.glodblock.github.common.storage.IStorageFluidCell;
import com.glodblock.github.common.tabs.FluidCraftingTabs;
import com.glodblock.github.loader.IRegister;
import com.glodblock.github.util.ModAndClassUtil;
import com.glodblock.github.loader.ItemAndBlockHolder;
import com.glodblock.github.util.NameConst;
import com.google.common.base.Optional;
@@ -53,24 +30,21 @@ import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class ItemBasicFluidStorageCell extends AEBaseItem
public class ItemBasicFluidStorageCell extends FCBaseItemCell
implements IStorageFluidCell, IRegister<ItemBasicFluidStorageCell> {
private final CellType component;
private final long totalBytes;
private final int perType;
private final double idleDrain;
private final ReadableNumberConverter format = ReadableNumberConverter.INSTANCE;
private static final HashMap<Integer, IIcon> icon = new HashMap<>();
private final int housingValue;
@SuppressWarnings("Guava")
public ItemBasicFluidStorageCell(final CellType whichCell, final long kilobytes) {
public ItemBasicFluidStorageCell(final CellType whichCell, final int housingValue, final long kilobytes) {
super(Optional.of(kilobytes + "k"));
setUnlocalizedName(NameConst.ITEM_FLUID_STORAGE + kilobytes);
this.setFeature(EnumSet.of(AEFeature.StorageCells));
this.setMaxStackSize(1);
this.totalBytes = kilobytes * 1024;
this.component = whichCell;
this.housingValue = housingValue;
setUnlocalizedName(NameConst.ITEM_FLUID_STORAGE + kilobytes);
switch (this.component) {
case Cell1kPart:
@@ -105,22 +79,15 @@ public class ItemBasicFluidStorageCell extends AEBaseItem
this.idleDrain = 4.0;
this.perType = 8;
break;
case Cell131072kPart:
this.idleDrain = 4.5;
this.perType = 8;
break;
case Cell554160890921312kPart:
this.idleDrain = 5.0;
this.perType = 8;
break;
default:
this.idleDrain = 0.0;
this.perType = 8;
}
}
public ItemStack getComponent() {
return component.stack(1);
@Override
public ItemStack getHousing() {
return ItemAndBlockHolder.CELL_HOUSING.stack(1, this.housingValue);
}
@Override
@@ -147,200 +114,12 @@ public class ItemBasicFluidStorageCell extends AEBaseItem
return icon.get(id);
}
@Override
public void addCheckedInformation(final ItemStack stack, final EntityPlayer player, final List<String> lines,
final boolean displayMoreInfo) {
final IMEInventoryHandler<?> inventory = AEApi.instance().registries().cell()
.getCellInventory(stack, null, StorageChannel.FLUIDS);
if (inventory instanceof IFluidCellInventoryHandler) {
final IFluidCellInventoryHandler handler = (IFluidCellInventoryHandler) inventory;
final IFluidCellInventory cellInventory = handler.getCellInv();
if (cellInventory != null) {
lines.add(
EnumChatFormatting.WHITE + String.valueOf(cellInventory.getUsedBytes())
+ EnumChatFormatting.GRAY
+ " "
+ GuiText.Of.getLocal()
+ " "
+ EnumChatFormatting.DARK_GREEN
+ NumberFormat.getInstance().format(cellInventory.getTotalBytes())
+ " "
+ EnumChatFormatting.GRAY
+ GuiText.BytesUsed.getLocal());
lines.add(
EnumChatFormatting.WHITE + String.valueOf(cellInventory.getStoredFluidTypes())
+ EnumChatFormatting.GRAY
+ " "
+ GuiText.Of.getLocal()
+ " "
+ EnumChatFormatting.DARK_GREEN
+ cellInventory.getTotalFluidTypes()
+ " "
+ EnumChatFormatting.GRAY
+ GuiText.Types.getLocal());
if (GuiScreen.isCtrlKeyDown()) {
if (cellInventory.getStoredFluidTypes() > 0) {
lines.add(StatCollector.translateToLocal(NameConst.TT_CELL_CONTENTS));
for (IAEFluidStack fluid : cellInventory.getContents()) {
if (fluid != null) {
lines.add(
String.format(
" %s x%s mB",
fluid.getFluidStack().getLocalizedName(),
format.toWideReadableForm(fluid.getStackSize())));
}
}
} else {
lines.add(StatCollector.translateToLocal(NameConst.TT_CELL_EMPTY));
}
} else {
lines.add(StatCollector.translateToLocal(NameConst.TT_CTRL_FOR_MORE));
}
if (handler.isPreformatted()) {
final String list = (handler.getIncludeExcludeMode() == IncludeExclude.WHITELIST ? GuiText.Included
: GuiText.Excluded).getLocal();
lines.add(GuiText.Partitioned.getLocal() + " - " + list + ' ' + GuiText.Precise.getLocal());
if (GuiScreen.isShiftKeyDown()) {
lines.add(GuiText.Filter.getLocal() + ": ");
for (IAEFluidStack aeFluidStack : handler.getPartitionInv()) {
if (aeFluidStack != null) lines.add(" " + aeFluidStack.getFluidStack().getLocalizedName());
}
} else {
lines.add(StatCollector.translateToLocal(NameConst.TT_SHIFT_FOR_MORE));
}
}
}
}
}
@Override
public long getBytes(final ItemStack cellItem) {
return this.totalBytes;
}
@Override
public int getBytesPerType(final ItemStack cellItem) {
return this.perType;
}
@Override
public boolean isBlackListed(ItemStack cellItem, IAEFluidStack requestedAddition) {
if (Config.blacklistEssentiaGas && ModAndClassUtil.ThE && requestedAddition != null) {
return ModAndClassUtil.essentiaGas.isInstance(requestedAddition.getFluid());
}
return false;
}
@Override
public int getTotalTypes(final ItemStack cellItem) {
return 1;
}
@Override
public boolean storableInStorageCell() {
return false;
}
@Override
public boolean isStorageCell(final ItemStack i) {
return true;
}
@Override
public double getIdleDrain() {
return this.idleDrain;
}
@Override
public boolean isEditable(final ItemStack is) {
return true;
}
@Override
public IInventory getUpgradesInventory(final ItemStack is) {
return new CellUpgrades(is, 0);
}
@Override
public IInventory getConfigInventory(final ItemStack is) {
return new CellConfig(is);
}
@Override
public FuzzyMode getFuzzyMode(final ItemStack is) {
final String fz = Platform.openNbtData(is).getString("FuzzyMode");
try {
return FuzzyMode.valueOf(fz);
} catch (final Throwable t) {
return FuzzyMode.IGNORE_ALL;
}
}
@Override
public void setFuzzyMode(final ItemStack is, final FuzzyMode fzMode) {
Platform.openNbtData(is).setString("FuzzyMode", fzMode.name());
}
@Override
public ItemStack onItemRightClick(final ItemStack stack, final World world, final EntityPlayer player) {
this.disassembleDrive(stack, world, player);
return stack;
}
@SuppressWarnings("unchecked")
private boolean disassembleDrive(final ItemStack stack, final World world, final EntityPlayer player) {
if (player.isSneaking()) {
if (Platform.isClient()) {
return false;
}
final InventoryPlayer playerInventory = player.inventory;
final IMEInventoryHandler<?> inv = AEApi.instance().registries().cell()
.getCellInventory(stack, null, StorageChannel.FLUIDS);
if (inv != null && playerInventory.getCurrentItem() == stack) {
final InventoryAdaptor ia = InventoryAdaptor.getAdaptor(player, ForgeDirection.UNKNOWN);
final IItemList<IAEFluidStack> list = inv.getAvailableItems(StorageChannel.FLUIDS.createList());
if (list.isEmpty() && ia != null) {
playerInventory.setInventorySlotContents(playerInventory.currentItem, null);
// drop core
final ItemStack extraB = ia.addItems(this.component.stack(1));
if (extraB != null) {
player.dropPlayerItemWithRandomChoice(extraB, false);
}
// drop upgrades
final IInventory upgradesInventory = this.getUpgradesInventory(stack);
for (int upgradeIndex = 0; upgradeIndex < upgradesInventory.getSizeInventory(); upgradeIndex++) {
final ItemStack upgradeStack = upgradesInventory.getStackInSlot(upgradeIndex);
final ItemStack leftStack = ia.addItems(upgradeStack);
if (leftStack != null && upgradeStack.getItem() instanceof IUpgradeModule) {
player.dropPlayerItemWithRandomChoice(upgradeStack, false);
}
}
// drop empty storage cell case
for (final ItemStack storageCellStack : AEApi.instance().definitions().materials()
.emptyStorageCell().maybeStack(1).asSet()) {
final ItemStack extraA = ia.addItems(storageCellStack);
if (extraA != null) {
player.dropPlayerItemWithRandomChoice(extraA, false);
}
}
if (player.inventoryContainer != null) {
player.inventoryContainer.detectAndSendChanges();
}
return true;
}
}
}
return false;
}
@Override
public boolean onItemUseFirst(final ItemStack stack, final EntityPlayer player, final World world, final int x,
final int y, final int z, final int side, final float hitX, final float hitY, final float hitZ) {
@@ -350,9 +129,8 @@ public class ItemBasicFluidStorageCell extends AEBaseItem
@Override
public ItemStack getContainerItem(final ItemStack itemStack) {
for (final ItemStack stack : AEApi.instance().definitions().materials().emptyStorageCell().maybeStack(1)
.asSet()) {
return stack;
if (this.getHousing() != null) {
return this.getHousing();
}
throw new MissingDefinition("Tried to use empty storage cells while basic storage cells are defined.");
}
@@ -369,12 +147,4 @@ public class ItemBasicFluidStorageCell extends AEBaseItem
setCreativeTab(FluidCraftingTabs.INSTANCE);
return this;
}
public ItemStack stack(int size) {
return new ItemStack(this, size);
}
public ItemStack stack() {
return new ItemStack(this, 1);
}
}
@@ -34,7 +34,7 @@ public class ItemBasicFluidStoragePart extends FCBaseItem {
@Override
@SideOnly(Side.CLIENT)
@SuppressWarnings("unchecked")
@SuppressWarnings({ "unchecked", "rawtypes" })
public void getSubItems(Item item, CreativeTabs tab, List list) {
for (int i = 0; i < types; ++i) {
list.add(new ItemStack(item, 1, i));
@@ -4,6 +4,7 @@ import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.StatCollector;
import net.minecraft.world.World;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.IFluidContainerItem;
@@ -18,6 +19,15 @@ public class ItemCertusQuartzTank extends BaseItemBlockContainer implements IFlu
super(block);
}
@Override
public String getItemStackDisplayName(ItemStack stack) {
FluidStack fluid = getFluid(stack);
if (fluid == null) {
return StatCollector.translateToLocal("tile.certus_quartz_tank_empty.name");
}
return StatCollector.translateToLocalFormatted("tile.certus_quartz_tank.name", fluid.getLocalizedName());
}
@Override
public FluidStack drain(ItemStack container, int maxDrain, boolean doDrain) {
if (container.stackSize != 1 || container.stackTagCompound == null
@@ -0,0 +1,55 @@
package com.glodblock.github.common.item;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.common.Config;
import com.glodblock.github.common.storage.IStorageFluidCell;
import com.glodblock.github.common.tabs.FluidCraftingTabs;
import com.glodblock.github.loader.IRegister;
import cpw.mods.fml.common.registry.GameRegistry;
public class ItemFluidExtremeStorageCell extends FCBaseItemCell
implements IStorageFluidCell, IRegister<ItemFluidExtremeStorageCell> {
private final String name;
public ItemFluidExtremeStorageCell(String name, long bytes, int perType, int totalTypes, double drain) {
super(bytes, perType, totalTypes, drain);
setUnlocalizedName(name);
this.name = name;
setTextureName(FluidCraft.resource(name).toString());
}
@Override
public ItemStack onItemRightClick(final ItemStack stack, final World world, final EntityPlayer player) {
return stack;
}
@Override
public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side,
float hitX, float hitY, float hitZ) {
return false;
}
@Override
public ItemStack getContainerItem(final ItemStack itemStack) {
return null;
}
@Override
public boolean hasContainerItem(final ItemStack stack) {
return false;
}
@Override
public ItemFluidExtremeStorageCell register() {
if (!Config.fluidCells) return null;
GameRegistry.registerItem(this, this.name, FluidCraft.MODID);
setCreativeTab(FluidCraftingTabs.INSTANCE);
return this;
}
}
@@ -0,0 +1,70 @@
package com.glodblock.github.common.item;
import java.util.HashMap;
import java.util.List;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraft.util.StatCollector;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.common.Config;
import com.glodblock.github.common.tabs.FluidCraftingTabs;
import com.glodblock.github.util.NameConst;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class ItemFluidStorageHousing extends FCBaseItem {
public static final int types = 4;
private static final HashMap<Integer, IIcon> icon = new HashMap<>();
public ItemFluidStorageHousing() {
super();
setHasSubtypes(true);
setUnlocalizedName(NameConst.ITEM_FLUID_STORAGE_HOUSING);
}
@Override
@SideOnly(Side.CLIENT)
@SuppressWarnings({ "unchecked", "rawtypes" })
public void getSubItems(Item item, CreativeTabs tab, List list) {
for (int i = 0; i < types; ++i) {
list.add(new ItemStack(item, 1, i));
}
}
@Override
public String getItemStackDisplayName(ItemStack stack) {
int meta = stack.getItemDamage();
return StatCollector.translateToLocalFormatted("item.fluid_storage_housing." + meta + ".name");
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IIconRegister iconRegister) {
for (int i = 0; i < types; i++) {
icon.put(i, iconRegister.registerIcon(NameConst.RES_KEY + NameConst.ITEM_FLUID_STORAGE_HOUSING + "." + i));
}
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIconFromDamage(int meta) {
return icon.get(meta);
}
@Override
public ItemFluidStorageHousing register() {
if (!Config.fluidCells) return null;
GameRegistry.registerItem(this, NameConst.ITEM_FLUID_STORAGE_HOUSING, FluidCraft.MODID);
setCreativeTab(FluidCraftingTabs.INSTANCE);
return this;
}
}
@@ -0,0 +1,151 @@
package com.glodblock.github.common.item;
import java.util.EnumSet;
import java.util.HashMap;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.IIcon;
import net.minecraft.util.StatCollector;
import net.minecraft.world.World;
import net.minecraftforge.event.ForgeEventFactory;
import appeng.api.exceptions.MissingDefinition;
import appeng.core.AEConfig;
import appeng.core.features.AEFeature;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.common.Config;
import com.glodblock.github.common.storage.CellType;
import com.glodblock.github.common.storage.IStorageFluidCell;
import com.glodblock.github.common.tabs.FluidCraftingTabs;
import com.glodblock.github.loader.IRegister;
import com.glodblock.github.loader.ItemAndBlockHolder;
import com.glodblock.github.util.NameConst;
import com.google.common.base.Optional;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class ItemMultiFluidStorageCell extends FCBaseItemCell
implements IStorageFluidCell, IRegister<ItemMultiFluidStorageCell> {
private static final HashMap<Integer, IIcon> icon = new HashMap<>();
private final int housingValue;
@SuppressWarnings("Guava")
public ItemMultiFluidStorageCell(final CellType whichCell, final int housingValue, final long kilobytes) {
super(Optional.of(kilobytes + "k"));
this.setFeature(EnumSet.of(AEFeature.StorageCells));
this.setMaxStackSize(1);
this.totalBytes = kilobytes * 1024;
this.component = whichCell;
this.housingValue = housingValue;
this.maxType = 5;
setUnlocalizedName(NameConst.ITEM_MULTI_FLUID_STORAGE + kilobytes);
switch (this.component) {
case Cell1kPart:
this.idleDrain = 0.5;
this.perType = 8;
break;
case Cell4kPart:
this.idleDrain = 1.0;
this.perType = 32;
break;
case Cell16kPart:
this.idleDrain = 1.5;
this.perType = 128;
break;
case Cell64kPart:
this.idleDrain = 2.0;
this.perType = 512;
break;
case Cell256kPart:
this.idleDrain = 2.5;
this.perType = 2048;
break;
case Cell1024kPart:
this.idleDrain = 3.0;
this.perType = 8192;
break;
case Cell4096kPart:
this.idleDrain = 3.5;
this.perType = 32768;
break;
case Cell16384kPart:
this.idleDrain = 4.0;
this.perType = 131072;
break;
default:
this.idleDrain = 0.0;
this.perType = 8;
}
}
@Override
public ItemStack getHousing() {
return ItemAndBlockHolder.CELL_HOUSING.stack(1, this.housingValue);
}
@Override
public String getItemStackDisplayName(ItemStack stack) {
return StatCollector.translateToLocalFormatted(
"item.multi_fluid_storage." + this.totalBytes / 1024 + ".name",
CellType.getTypeColor(this.component),
EnumChatFormatting.RESET);
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IIconRegister iconRegister) {
icon.put(
(int) (this.totalBytes / 1024),
iconRegister.registerIcon(
NameConst.RES_KEY + NameConst.ITEM_MULTI_FLUID_STORAGE + "." + this.totalBytes / 1024));
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIconFromDamage(int meta) {
int id = (int) (this.totalBytes / 1024);
return icon.get(id);
}
@Override
public ItemStack onItemRightClick(final ItemStack stack, final World world, final EntityPlayer player) {
this.disassembleDrive(stack, world, player);
return stack;
}
@Override
public boolean onItemUseFirst(final ItemStack stack, final EntityPlayer player, final World world, final int x,
final int y, final int z, final int side, final float hitX, final float hitY, final float hitZ) {
if (ForgeEventFactory.onItemUseStart(player, stack, 1) <= 0) return true;
return this.disassembleDrive(stack, world, player);
}
@Override
public boolean hasContainerItem(final ItemStack stack) {
return AEConfig.instance.isFeatureEnabled(AEFeature.EnableDisassemblyCrafting);
}
@Override
public ItemStack getContainerItem(final ItemStack itemStack) {
if (this.getHousing() != null) {
return this.getHousing();
}
throw new MissingDefinition("Tried to use empty storage cells while basic storage cells are defined.");
}
@Override
public ItemMultiFluidStorageCell register() {
if (!Config.fluidCells) return null;
GameRegistry.registerItem(this, NameConst.ITEM_MULTI_FLUID_STORAGE + this.totalBytes / 1024, FluidCraft.MODID);
setCreativeTab(FluidCraftingTabs.INSTANCE);
return this;
}
}
@@ -10,7 +10,6 @@ import appeng.api.AEApi;
import appeng.api.networking.IGridNode;
import appeng.core.features.AEFeature;
import appeng.core.localization.PlayerMessages;
import appeng.util.Platform;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.common.tabs.FluidCraftingTabs;
@@ -43,11 +42,9 @@ public class ItemWirelessFluidTerminal extends ItemBaseWirelessTerminal
public Object getInventory(ItemStack stack, World world, int x, int y, int z, EntityPlayer player) {
try {
IGridNode gridNode = Util.getWirelessGrid(stack);
if (gridNode != null) {
return new WirelessFluidTerminalInventory(stack, x, gridNode, player);
}
return new WirelessFluidTerminalInventory(stack, x, gridNode, player);
} catch (Exception e) {
if (Platform.isClient()) player.addChatMessage(PlayerMessages.OutOfRange.get());
player.addChatMessage(PlayerMessages.OutOfRange.get());
}
return null;
}
@@ -10,7 +10,6 @@ import appeng.api.AEApi;
import appeng.api.networking.IGridNode;
import appeng.core.features.AEFeature;
import appeng.core.localization.PlayerMessages;
import appeng.util.Platform;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.common.tabs.FluidCraftingTabs;
@@ -43,11 +42,9 @@ public class ItemWirelessInterfaceTerminal extends ItemBaseWirelessTerminal
public Object getInventory(ItemStack stack, World world, int x, int y, int z, EntityPlayer player) {
try {
IGridNode gridNode = Util.getWirelessGrid(stack);
if (gridNode != null) {
return new WirelessInterfaceTerminalInventory(stack, x, gridNode, player);
}
return new WirelessInterfaceTerminalInventory(stack, x, gridNode, player);
} catch (Exception e) {
if (Platform.isClient()) player.addChatMessage(PlayerMessages.OutOfRange.get());
player.addChatMessage(PlayerMessages.OutOfRange.get());
}
return null;
}
@@ -10,7 +10,6 @@ import appeng.api.AEApi;
import appeng.api.networking.IGridNode;
import appeng.core.features.AEFeature;
import appeng.core.localization.PlayerMessages;
import appeng.util.Platform;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.common.tabs.FluidCraftingTabs;
@@ -43,11 +42,9 @@ public class ItemWirelessPatternTerminal extends ItemBaseWirelessTerminal
public Object getInventory(ItemStack stack, World world, int x, int y, int z, EntityPlayer player) {
try {
IGridNode gridNode = Util.getWirelessGrid(stack);
if (gridNode != null) {
return new WirelessPatternTerminalInventory(stack, x, gridNode, player);
}
return new WirelessPatternTerminalInventory(stack, x, gridNode, player);
} catch (Exception e) {
if (Platform.isClient()) player.addChatMessage(PlayerMessages.OutOfRange.get());
player.addChatMessage(PlayerMessages.OutOfRange.get());
}
return null;
}
@@ -3,9 +3,11 @@ package com.glodblock.github.common.item;
import static net.minecraft.client.gui.GuiScreen.isShiftKeyDown;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.EnumSet;
import java.util.List;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
@@ -13,11 +15,15 @@ import net.minecraft.util.StatCollector;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import org.apache.commons.lang3.tuple.ImmutablePair;
import appeng.api.AEApi;
import appeng.api.networking.IGridNode;
import appeng.core.features.AEFeature;
import appeng.core.localization.PlayerMessages;
import appeng.util.Platform;
import baubles.api.BaubleType;
import baubles.api.IBauble;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.common.tabs.FluidCraftingTabs;
@@ -36,7 +42,7 @@ import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class ItemWirelessUltraTerminal extends ItemBaseWirelessTerminal
implements IRegister<ItemWirelessUltraTerminal> {
implements IBauble, IRegister<ItemWirelessUltraTerminal> {
public final static String MODE = "mode_main";
private final static List<GuiType> guis = new ArrayList<>();
@@ -72,6 +78,8 @@ public class ItemWirelessUltraTerminal extends ItemBaseWirelessTerminal
if (isShiftKeyDown()) {
lines.add(StatCollector.translateToLocal(NameConst.TT_ULTRA_TERMINAL));
lines.add(StatCollector.translateToLocal(NameConst.TT_ULTRA_TERMINAL + "." + guiGuiType(stack)));
lines.add(NameConst.i18n(NameConst.TT_ULTRA_TERMINAL_TIPS));
lines.addAll(Arrays.asList(NameConst.i18n(NameConst.TT_ULTRA_TERMINAL_TIPS_DESC).split("\\\\n")));
} else {
lines.add(NameConst.i18n(NameConst.TT_SHIFT_FOR_MORE));
}
@@ -86,32 +94,30 @@ public class ItemWirelessUltraTerminal extends ItemBaseWirelessTerminal
public Object getInventory(ItemStack stack, World world, int x, int y, int z, EntityPlayer player) {
try {
IGridNode gridNode = Util.getWirelessGrid(stack);
if (gridNode != null) {
final GuiType gui;
if (Util.GuiHelper.decodeType(y).getLeft() == Util.GuiHelper.GuiType.ITEM && z > 0) {
gui = getGuis().get(Util.GuiHelper.decodeType(y).getRight());
} else {
gui = readMode(stack);
}
if (gui == GuiType.WIRELESS_FLUID_PATTERN_TERMINAL) {
return new WirelessPatternTerminalInventory(stack, x, gridNode, player);
} else if (gui == GuiType.WIRELESS_CRAFTING_TERMINAL) {
return new WirelessCraftingTerminalInventory(stack, x, gridNode, player);
} else if (ModAndClassUtil.ThE && gui == GuiType.WIRELESS_ESSENTIA_TERMINAL) {
return new WirelessFluidTerminalInventory(stack, x, gridNode, player);
} else if (gui == GuiType.WIRELESS_FLUID_TERMINAL) {
return new WirelessFluidTerminalInventory(stack, x, gridNode, player);
} else if (gui == GuiType.WIRELESS_INTERFACE_TERMINAL) {
return new WirelessInterfaceTerminalInventory(stack, x, gridNode, player);
} else if (gui == GuiType.WIRELESS_FLUID_PATTERN_TERMINAL_EX) {
return new WirelessPatternTerminalExInventory(stack, x, gridNode, player);
} else {
this.setMode(GuiType.WIRELESS_FLUID_TERMINAL, stack); // set as default mode
return new WirelessFluidTerminalInventory(stack, x, gridNode, player);
}
final GuiType gui;
if (Util.GuiHelper.decodeType(y).getLeft() == Util.GuiHelper.GuiType.ITEM && z > 0) {
gui = getGuis().get(Util.GuiHelper.decodeType(y).getRight());
} else {
gui = readMode(stack);
}
if (gui == GuiType.WIRELESS_FLUID_PATTERN_TERMINAL) {
return new WirelessPatternTerminalInventory(stack, x, gridNode, player);
} else if (gui == GuiType.WIRELESS_CRAFTING_TERMINAL) {
return new WirelessCraftingTerminalInventory(stack, x, gridNode, player);
} else if (ModAndClassUtil.ThE && gui == GuiType.WIRELESS_ESSENTIA_TERMINAL) {
return new WirelessFluidTerminalInventory(stack, x, gridNode, player);
} else if (gui == GuiType.WIRELESS_FLUID_TERMINAL) {
return new WirelessFluidTerminalInventory(stack, x, gridNode, player);
} else if (gui == GuiType.WIRELESS_INTERFACE_TERMINAL) {
return new WirelessInterfaceTerminalInventory(stack, x, gridNode, player);
} else if (gui == GuiType.WIRELESS_FLUID_PATTERN_TERMINAL_EX) {
return new WirelessPatternTerminalExInventory(stack, x, gridNode, player);
} else {
this.setMode(GuiType.WIRELESS_FLUID_TERMINAL, stack); // set as default mode
return new WirelessFluidTerminalInventory(stack, x, gridNode, player);
}
} catch (Exception e) {
if (Platform.isClient()) player.addChatMessage(PlayerMessages.OutOfRange.get());
player.addChatMessage(PlayerMessages.OutOfRange.get());
}
return null;
}
@@ -164,9 +170,10 @@ public class ItemWirelessUltraTerminal extends ItemBaseWirelessTerminal
}
public static void switchTerminal(EntityPlayer player, GuiType guiType) {
if (player.inventory.getCurrentItem().getItem() instanceof ItemWirelessUltraTerminal) {
((ItemWirelessUltraTerminal) player.inventory.getCurrentItem().getItem())
.setMode(guiType, player.inventory.getCurrentItem());
ImmutablePair<Integer, ItemStack> term = Util.getUltraWirelessTerm(player);
if (term == null) return;
if (term.getRight().getItem() instanceof ItemWirelessUltraTerminal) {
((ItemWirelessUltraTerminal) term.getRight().getItem()).setMode(guiType, term.getRight());
}
if (Platform.isClient()) {
FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(guiType, true));
@@ -175,7 +182,7 @@ public class ItemWirelessUltraTerminal extends ItemBaseWirelessTerminal
player,
player.worldObj,
new BlockPos(
player.inventory.currentItem,
term.getLeft(),
Util.GuiHelper.encodeType(
guis.indexOf(GuiType.valueOf(guiType.toString())),
Util.GuiHelper.GuiType.ITEM),
@@ -193,4 +200,34 @@ public class ItemWirelessUltraTerminal extends ItemBaseWirelessTerminal
public GuiType guiGuiType(ItemStack stack) {
return readMode(stack);
}
@Override
public BaubleType getBaubleType(ItemStack itemStack) {
return BaubleType.RING;
}
@Override
public void onWornTick(ItemStack itemStack, EntityLivingBase entityLivingBase) {
}
@Override
public void onEquipped(ItemStack itemStack, EntityLivingBase entityLivingBase) {
}
@Override
public void onUnequipped(ItemStack itemStack, EntityLivingBase entityLivingBase) {
}
@Override
public boolean canEquip(ItemStack itemStack, EntityLivingBase entityLivingBase) {
return true;
}
@Override
public boolean canUnequip(ItemStack itemStack, EntityLivingBase entityLivingBase) {
return true;
}
}
@@ -1,6 +1,7 @@
package com.glodblock.github.common.parts;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
@@ -26,6 +27,7 @@ import appeng.core.AELog;
import appeng.helpers.MultiCraftingTracker;
import appeng.me.GridAccessException;
import appeng.util.InventoryAdaptor;
import appeng.util.Platform;
import appeng.util.item.AEFluidStack;
import appeng.util.item.AEItemStack;
@@ -43,6 +45,9 @@ public class PartFluidExportBus extends FCSharedFluidBus implements ICraftingReq
private final BaseActionSource source;
private final MultiCraftingTracker craftingTracker = new MultiCraftingTracker(this, 9);
private int nextSlot = 0;
private long fluidToSend = 1000;
private boolean didSomething;
public PartFluidExportBus(ItemStack is) {
super(is);
@@ -73,12 +78,33 @@ public class PartFluidExportBus extends FCSharedFluidBus implements ICraftingReq
return this.getProxy().isActive();
}
private int getStartingSlot(final SchedulingMode schedulingMode, final int x) {
if (schedulingMode == SchedulingMode.RANDOM) {
return Platform.getRandom().nextInt(this.availableSlots());
}
if (schedulingMode == SchedulingMode.ROUNDROBIN) {
return (this.nextSlot + x) % this.availableSlots();
}
return x;
}
private int availableSlots() {
return Math.min(1 + this.getInstalledUpgrades(Upgrades.CAPACITY) * 4, this.getInv().getSizeInventory());
}
private IInventory getInv() {
return this.getInventoryByName("config");
}
@Override
protected TickRateModulation doBusWork() {
if (!this.canDoBusWork()) {
return TickRateModulation.IDLE;
}
this.didSomething = false;
this.fluidToSend = this.calculateAmountToSend();
final TileEntity te = this.getConnectedTE();
if (te instanceof IFluidHandler) {
@@ -87,10 +113,11 @@ public class PartFluidExportBus extends FCSharedFluidBus implements ICraftingReq
final ICraftingGrid cg = this.getProxy().getCrafting();
final IFluidHandler fh = (IFluidHandler) te;
final IMEMonitor<IAEFluidStack> inv = this.getProxy().getStorage().getFluidInventory();
for (int i = 0; i < this.getInventoryByName("config").getSizeInventory(); i++) {
int i;
for (i = 0; i < this.availableSlots() && this.fluidToSend > 0; i++) {
final int slotToExport = this.getStartingSlot(this.getSchedulingMode(), i);
IAEFluidStack fluid = AEFluidStack
.create(ItemFluidPacket.getFluidStack(this.getInventoryByName("config").getStackInSlot(i)));
.create(ItemFluidPacket.getFluidStack(getInv().getStackInSlot(slotToExport)));
if (fluid != null) {
boolean isAllowed = true;
@@ -110,20 +137,18 @@ public class PartFluidExportBus extends FCSharedFluidBus implements ICraftingReq
this.source);
}
final IAEFluidStack out = inv.extractItems(toExtract, Actionable.SIMULATE, this.source);
if (out != null && isAllowed) {
int wasInserted = fh.fill(this.getSide().getOpposite(), out.getFluidStack(), true);
if (wasInserted > 0) {
toExtract.setStackSize(wasInserted);
inv.extractItems(toExtract, Actionable.MODULATE, this.source);
return TickRateModulation.FASTER;
int space = fh.fill(this.getSide().getOpposite(), toExtract.getFluidStack(), false);
toExtract.setStackSize(space);
final IAEFluidStack real = inv.extractItems(toExtract, Actionable.MODULATE, this.source);
if (real != null && isAllowed) {
int realInserted = fh.fill(this.getSide().getOpposite(), real.getFluidStack(), true);
if (realInserted < real.getStackSize()) {
toExtract.setStackSize(real.getStackSize() - realInserted);
inv.injectItems(toExtract, Actionable.MODULATE, this.source);
}
}
if (this.isCraftingEnabled()) {
this.fluidToSend -= realInserted;
didSomething = true;
} else if (this.isCraftingEnabled()) {
this.craftingTracker.handleCrafting(
i,
toExtract.getStackSize(),
@@ -136,8 +161,8 @@ public class PartFluidExportBus extends FCSharedFluidBus implements ICraftingReq
}
}
}
return TickRateModulation.SLOWER;
this.updateSchedulingMode(this.getSchedulingMode(), i);
return didSomething ? TickRateModulation.FASTER : TickRateModulation.SLOWER;
} catch (GridAccessException e) {
// Ignore
}
@@ -146,6 +171,12 @@ public class PartFluidExportBus extends FCSharedFluidBus implements ICraftingReq
return TickRateModulation.SLEEP;
}
private void updateSchedulingMode(final SchedulingMode schedulingMode, final int x) {
if (schedulingMode == SchedulingMode.ROUNDROBIN) {
this.nextSlot = (this.nextSlot + x) % this.availableSlots();
}
}
@Override
public void getBoxes(final IPartCollisionHelper bch) {
bch.addBox(4, 4, 12, 12, 12, 14);
@@ -216,6 +247,10 @@ public class PartFluidExportBus extends FCSharedFluidBus implements ICraftingReq
return (RedstoneMode) this.getConfigManager().getSetting(Settings.REDSTONE_CONTROLLED);
}
public SchedulingMode getSchedulingMode() {
return (SchedulingMode) this.getConfigManager().getSetting(Settings.SCHEDULING_MODE);
}
private boolean craftOnly() {
return this.getConfigManager().getSetting(Settings.CRAFT_ONLY) == YesNo.YES;
}
@@ -259,7 +259,9 @@ public class PartFluidStorageBus extends PartUpgradeable
@Override
public void onNeighborChanged() {
BlockPos neighbor = new BlockPos(this.getTile()).getOffSet(this.getSide());
TileEntity tile = this.getTile();
if (tile == null || this.getProxy() == null || !this.getProxy().isActive()) return;
BlockPos neighbor = new BlockPos(tile).getOffSet(this.getSide());
final TileEntity te = neighbor.getTileEntity();
// In case the TE was destroyed, we have to do a full reset immediately.
if (te instanceof TileCableBus) {
@@ -288,6 +290,7 @@ public class PartFluidStorageBus extends PartUpgradeable
} else {
this.resetCache(false);
}
}
@Override
@@ -25,6 +25,7 @@ public abstract class FCFluidEncodeTerminal extends FCPart implements IItemPatte
protected boolean prioritize = false;
protected boolean inverted = false;
protected boolean beSubstitute = false;
protected boolean autoFillPattern = false;
protected int activePage = 0;
public FCFluidEncodeTerminal(ItemStack is) {
@@ -51,6 +52,7 @@ public abstract class FCFluidEncodeTerminal extends FCPart implements IItemPatte
this.setPrioritization(data.getBoolean("priorization"));
this.setInverted(data.getBoolean("inverted"));
this.setActivePage(data.getInteger("activePage"));
this.setAutoFillPattern(data.getBoolean("autoFillPattern"));
this.pattern.readFromNBT(data, "pattern");
this.output.readFromNBT(data, "outputList");
this.crafting.readFromNBT(data, "craftingGrid");
@@ -66,6 +68,7 @@ public abstract class FCFluidEncodeTerminal extends FCPart implements IItemPatte
data.setBoolean("substitute", this.substitute);
data.setBoolean("inverted", this.inverted);
data.setInteger("activePage", this.activePage);
data.setBoolean("autoFillPattern", this.autoFillPattern);
this.pattern.writeToNBT(data, "pattern");
this.output.writeToNBT(data, "outputList");
this.crafting.writeToNBT(data, "craftingGrid");
@@ -204,4 +207,14 @@ public abstract class FCFluidEncodeTerminal extends FCPart implements IItemPatte
}
saveChanges();
}
@Override
public boolean isAutoFillPattern() {
return this.autoFillPattern;
}
@Override
public void setAutoFillPattern(boolean canFill) {
this.autoFillPattern = canFill;
}
}
@@ -35,6 +35,7 @@ import appeng.client.texture.CableBusTextures;
import appeng.core.AELog;
import appeng.core.localization.PlayerMessages;
import appeng.helpers.Reflected;
import appeng.hooks.TickHandler;
import appeng.me.GridAccessException;
import appeng.parts.reporting.AbstractPartDisplay;
import appeng.parts.reporting.PartPanel;
@@ -199,7 +200,7 @@ public abstract class FCPartMonitor extends AbstractPartDisplay implements IPart
super.finalize();
if (this.dspList != null) {
GLAllocation.deleteDisplayLists(this.dspList);
TickHandler.INSTANCE.scheduleCallListDelete(this.dspList);
}
}
@@ -17,9 +17,7 @@ public enum CellType {
Cell256kPart(4, AEFeature.StorageCells),
Cell1024kPart(5, AEFeature.StorageCells),
Cell4096kPart(6, AEFeature.StorageCells),
Cell16384kPart(7, AEFeature.StorageCells),
Cell131072kPart(8, AEFeature.StorageCells),
Cell554160890921312kPart(9, AEFeature.StorageCells);
Cell16384kPart(7, AEFeature.StorageCells);
private final EnumSet<AEFeature> features;
private int damageValue;
@@ -76,10 +74,6 @@ public enum CellType {
return EnumChatFormatting.RED;
case Cell16384kPart:
return EnumChatFormatting.DARK_PURPLE;
case Cell131072kPart:
return EnumChatFormatting.DARK_GRAY;
case Cell554160890921312kPart:
return EnumChatFormatting.DARK_RED;
}
return EnumChatFormatting.WHITE;
}
@@ -1,14 +1,17 @@
package com.glodblock.github.common.tile;
import net.minecraft.block.Block;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.NetworkManager;
import net.minecraft.network.Packet;
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.*;
import com.glodblock.github.loader.ChannelLoader;
import com.glodblock.github.util.BlockPos;
public class TileCertusQuartzTank extends TileEntity implements IFluidHandler {
@@ -26,6 +29,7 @@ public class TileCertusQuartzTank extends TileEntity implements IFluidHandler {
return this;
}
};
private boolean hasUpdate;
@Override
public boolean canDrain(ForgeDirection from, Fluid fluid) {
@@ -191,6 +195,40 @@ public class TileCertusQuartzTank extends TileEntity implements IFluidHandler {
return (float) this.tank.getFluidAmount() / this.tank.getCapacity();
}
private void onComparatorUpdate(World world, int x, int y, int z, Block block) {
world.func_147453_f(x, y, z, block);
}
@Override
public void updateEntity() {
super.updateEntity();
if (this.tank.getFluid() != null) {
TileCertusQuartzTank below = getTankBelow(this);
if (below != null) {
FluidStack filled = this.tank.getFluid().copy();
filled.amount = below.fill(this.tank.getFluid(), true, true);
if (filled.amount >= 0) {
this.drain(filled, true, true);
this.hasUpdate = true;
below.hasUpdate = true;
}
}
}
if (this.hasUpdate) {
onComparatorUpdate(this.worldObj, this.xCoord, this.yCoord, this.zCoord, this.getBlockType());
this.hasUpdate = false;
}
}
private TileCertusQuartzTank getTankBelow(TileEntity tile) {
TileEntity tank = new BlockPos(tile).getOffSet(0, -1, 0).getTileEntity();
if (tank != null && tank instanceof TileCertusQuartzTank) {
return (TileCertusQuartzTank) tank;
}
return null;
}
public FluidTankInfo[] getTankInfo(boolean goToMainTank) {
if (!goToMainTank) return new FluidTankInfo[] { this.tank.getInfo() };
@@ -212,12 +250,12 @@ public class TileCertusQuartzTank extends TileEntity implements IFluidHandler {
break;
}
yOff = 0;
offTE = this.worldObj.getTileEntity(this.xCoord, this.yCoord + yOff, this.zCoord);
yOff -= 1;
offTE = this.worldObj.getTileEntity(this.xCoord, this.yCoord - yOff, this.zCoord);
while (true) {
if (offTE instanceof TileCertusQuartzTank) {
mainTank = (TileCertusQuartzTank) offTE;
if (mainTank.getFluid() == null || mainTank.getFluid() == getFluid()) {
if (mainTank.getFluid() == null || getFluid() == null || mainTank.getFluid() == getFluid()) {
FluidTankInfo info = mainTank.getTankInfo(false)[0];
if (info != null) {
capacity += info.capacity;
@@ -226,8 +264,7 @@ public class TileCertusQuartzTank extends TileEntity implements IFluidHandler {
if (info.fluid.getFluid() != null) fluid = info.fluid.getFluid();
}
}
yOff++;
offTE = this.worldObj.getTileEntity(this.xCoord, this.yCoord + yOff, this.zCoord);
offTE = new BlockPos(offTE).getOffSet(0, 1, 0).getTileEntity();
continue;
}
}
@@ -274,4 +311,8 @@ public class TileCertusQuartzTank extends TileEntity implements IFluidHandler {
public void writeToNBTWithoutCoords(NBTTagCompound tag) {
this.tank.writeToNBT(tag);
}
public FluidTankInfo[] getInternalFluid() {
return this.getTankInfo(true);
}
}
@@ -4,7 +4,8 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.*;
import appeng.api.networking.GridFlags;
import appeng.api.networking.IGridNode;
@@ -30,7 +31,8 @@ import appeng.util.item.AEFluidStack;
import com.glodblock.github.common.item.ItemFluidPacket;
public class TileFluidPacketDecoder extends AENetworkTile implements IGridTickable, IAEAppEngInventory, IInventory {
public class TileFluidPacketDecoder extends AENetworkTile
implements IGridTickable, IAEAppEngInventory, IInventory, IFluidHandler {
private final AppEngInternalInventory inventory = new AppEngInternalInventory(this, 1);
private final BaseActionSource ownActionSource = new MachineSource(this);
@@ -164,4 +166,68 @@ public class TileFluidPacketDecoder extends AENetworkTile implements IGridTickab
public boolean isItemValidForSlot(int slot, ItemStack stack) {
return stack.getItem() instanceof ItemFluidPacket;
}
@Override
public int fill(ForgeDirection from, FluidStack resource, boolean doFill) {
return 0;
}
@Override
public FluidStack drain(ForgeDirection from, FluidStack requestFluid, boolean doDrain) {
return this.drain(requestFluid, doDrain);
}
private FluidStack drain(FluidStack requestFluid, boolean doDrain) {
if (requestFluid == null || requestFluid.amount <= 0) return null;
ItemStack fluidPacket = this.inventory.getStackInSlot(0);
if (fluidPacket != null) {
FluidStack fs = ItemFluidPacket.getFluidStack(fluidPacket);
if (fs == null) return null;
if (fs.isFluidEqual(requestFluid)) {
if (fs.amount > requestFluid.amount) {
fs.amount -= requestFluid.amount;
if (doDrain) this.inventory.setInventorySlotContents(0, ItemFluidPacket.newStack(fs));
return requestFluid;
} else {
if (doDrain) this.inventory.setInventorySlotContents(0, null);
return fs;
}
}
}
return null;
}
@Override
public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) {
ItemStack fluidPacket = this.inventory.getStackInSlot(0);
if (fluidPacket != null) {
FluidStack requestFluid = ItemFluidPacket.getFluidStack(fluidPacket);
if (requestFluid == null) return null;
requestFluid.amount = maxDrain;
return this.drain(requestFluid, doDrain);
}
return null;
}
@Override
public boolean canFill(ForgeDirection from, Fluid fluid) {
return false;
}
@Override
public boolean canDrain(ForgeDirection from, Fluid fluid) {
return true;
}
@Override
public FluidTankInfo[] getTankInfo(ForgeDirection from) {
ItemStack fluidPacket = this.inventory.getStackInSlot(0);
if (fluidPacket == null) {
return new FluidTankInfo[0];
} else {
FluidStack fs = ItemFluidPacket.getFluidStack(fluidPacket);
if (fs == null) return new FluidTankInfo[0];
return new FluidTankInfo[] { new FluidTankInfo(fs, fs.amount) };
}
}
}
@@ -40,9 +40,6 @@ public class FCClassTransformer implements IClassTransformer {
case "appeng.core.sync.packets.PacketCompressedNBT":
tform = PacketCompressedNBTTransformer.INSTANCE;
break;
case "appeng.client.gui.implementations.GuiRenamer":
tform = GuiRenamerTransformer.INSTANCE;
break;
default:
return code;
}
@@ -5,13 +5,9 @@ import java.util.Set;
import javax.annotation.Nullable;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.FluidStack;
@@ -32,20 +28,14 @@ import appeng.parts.misc.PartInterface;
import appeng.tile.misc.TileInterface;
import appeng.util.InventoryAdaptor;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.GuiFluidCraftConfirm;
import com.glodblock.github.client.gui.GuiInterfaceTerminalWireless;
import com.glodblock.github.common.item.ItemFluidDrop;
import com.glodblock.github.common.item.ItemFluidPacket;
import com.glodblock.github.common.item.ItemWirelessInterfaceTerminal;
import com.glodblock.github.common.item.ItemWirelessUltraTerminal;
import com.glodblock.github.common.parts.PartFluidInterface;
import com.glodblock.github.common.tile.TileFluidInterface;
import com.glodblock.github.inventory.FluidConvertingInventoryAdaptor;
import com.glodblock.github.inventory.FluidConvertingInventoryCrafting;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.loader.ItemAndBlockHolder;
import com.glodblock.github.network.CPacketSwitchGuis;
import com.glodblock.github.util.Ae2Reflect;
import com.glodblock.github.util.SetBackedMachineSet;
import com.google.common.collect.Sets;
@@ -198,19 +188,4 @@ public class CoreModHooks {
}
return true;
}
public static void clientPacketData(NBTTagCompound data) {
GuiScreen gs = Minecraft.getMinecraft().currentScreen;
if (gs instanceof GuiInterfaceTerminalWireless) {
((GuiInterfaceTerminalWireless) gs).postUpdate(data);
}
}
public static void reopenInterfaceTerminal() {
EntityPlayer p = Minecraft.getMinecraft().thePlayer;
ItemStack c = p.getCurrentEquippedItem();
if (c.getItem() instanceof ItemWirelessInterfaceTerminal || c.getItem() instanceof ItemWirelessUltraTerminal) {
FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(GuiType.WIRELESS_INTERFACE_TERMINAL, true));
}
}
}
@@ -0,0 +1,22 @@
package com.glodblock.github.coremod.hooker;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.nbt.NBTTagCompound;
import com.glodblock.github.client.gui.GuiInterfaceTerminalWireless;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class CoreModHooksClient {
public static void clientPacketData(NBTTagCompound data) {
GuiScreen gs = Minecraft.getMinecraft().currentScreen;
if (gs instanceof GuiInterfaceTerminalWireless) {
((GuiInterfaceTerminalWireless) gs).postUpdate(data);
}
}
}
@@ -1,59 +0,0 @@
package com.glodblock.github.coremod.transform;
import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.MethodVisitor;
import org.objectweb.asm.Opcodes;
import com.glodblock.github.coremod.FCClassTransformer;
public class GuiRenamerTransformer extends FCClassTransformer.ClassMapper {
public static final GuiRenamerTransformer INSTANCE = new GuiRenamerTransformer();
private GuiRenamerTransformer() {
// NO-OP
}
@Override
protected ClassVisitor getClassMapper(ClassVisitor downstream) {
return new GuiRenamerTransformer.TransformGuiRenamer(Opcodes.ASM5, downstream);
}
private static class TransformGuiRenamer extends ClassVisitor {
TransformGuiRenamer(int api, ClassVisitor cv) {
super(api, cv);
}
@Override
public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
if (name.equals("keyTyped")) {
return new GuiRenamerTransformer.TransformKeyTyped(
api,
super.visitMethod(access, name, desc, signature, exceptions));
}
return super.visitMethod(access, name, desc, signature, exceptions);
}
}
private static class TransformKeyTyped extends MethodVisitor {
TransformKeyTyped(int api, MethodVisitor mv) {
super(api, mv);
}
@Override
public void visitMethodInsn(int opcode, String owner, String name, String desc, boolean itf) {
super.visitMethodInsn(opcode, owner, name, desc, itf);
if (owner.equals("net/minecraft/client/entity/EntityClientPlayerMP") && name.equals("closeScreen")) {
super.visitMethodInsn(
Opcodes.INVOKESTATIC,
"com/glodblock/github/coremod/hooker/CoreModHooks",
"reopenInterfaceTerminal",
"()V",
false);
}
}
}
}
@@ -51,7 +51,7 @@ public class PacketCompressedNBTTransformer extends FCClassTransformer.ClassMapp
"Lnet/minecraft/nbt/NBTTagCompound;");
super.visitMethodInsn(
Opcodes.INVOKESTATIC,
"com/glodblock/github/coremod/hooker/CoreModHooks",
"com/glodblock/github/coremod/hooker/CoreModHooksClient",
"clientPacketData",
"(Lnet/minecraft/nbt/NBTTagCompound;)V",
false);
@@ -15,6 +15,14 @@ public class Tooltip {
return String.format("%s: %s mB", name, NumberFormat.getInstance().format(amount));
}
public static String fluidFormat(String name, long amount, long capacity) {
return String.format(
"%s: %s mB / %s mB",
name,
NumberFormat.getInstance().format(amount),
NumberFormat.getInstance().format(capacity));
}
public static String partFluidBusFormat(int amount) {
return String
.format("%s: %s mB/t", I18n.format(NameConst.WAILA_SPEED), NumberFormat.getInstance().format(amount));
@@ -0,0 +1,71 @@
package com.glodblock.github.crossmod.waila;
import java.util.List;
import mcp.mobius.waila.api.IWailaConfigHandler;
import mcp.mobius.waila.api.IWailaDataAccessor;
import mcp.mobius.waila.api.IWailaDataProvider;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import com.glodblock.github.crossmod.waila.vanilla.FluidInvWailaDataProvider;
import com.google.common.collect.Lists;
public class VanillaTileWailaDataProvider implements IWailaDataProvider {
private final List<IWailaDataProvider> providers;
public VanillaTileWailaDataProvider() {
final IWailaDataProvider fluidInv = new FluidInvWailaDataProvider();
this.providers = Lists.newArrayList(fluidInv);
}
@Override
public ItemStack getWailaStack(final IWailaDataAccessor accessor, final IWailaConfigHandler config) {
return null;
}
@Override
public List<String> getWailaHead(final ItemStack itemStack, final List<String> currentToolTip,
final IWailaDataAccessor accessor, final IWailaConfigHandler config) {
for (final IWailaDataProvider provider : this.providers) {
provider.getWailaHead(itemStack, currentToolTip, accessor, config);
}
return currentToolTip;
}
@Override
public List<String> getWailaBody(final ItemStack itemStack, final List<String> currentToolTip,
final IWailaDataAccessor accessor, final IWailaConfigHandler config) {
for (final IWailaDataProvider provider : this.providers) {
provider.getWailaBody(itemStack, currentToolTip, accessor, config);
}
return currentToolTip;
}
@Override
public List<String> getWailaTail(final ItemStack itemStack, final List<String> currentToolTip,
final IWailaDataAccessor accessor, final IWailaConfigHandler config) {
for (final IWailaDataProvider provider : this.providers) {
provider.getWailaTail(itemStack, currentToolTip, accessor, config);
}
return currentToolTip;
}
@Override
public NBTTagCompound getNBTData(final EntityPlayerMP player, final TileEntity te, final NBTTagCompound tag,
final World world, final int x, final int y, final int z) {
for (final IWailaDataProvider provider : this.providers) {
provider.getNBTData(player, te, tag, world, x, y, z);
}
return tag;
}
}
@@ -2,6 +2,9 @@ package com.glodblock.github.crossmod.waila;
import mcp.mobius.waila.api.IWailaDataProvider;
import mcp.mobius.waila.api.IWailaRegistrar;
import net.minecraft.tileentity.TileEntity;
import appeng.api.parts.IPartHost;
import appeng.tile.AEBaseTile;
import appeng.util.Platform;
@@ -23,5 +26,10 @@ public class WailaInit {
final IWailaDataProvider tile = new TileWailaDataProvider();
registrar.registerBodyProvider(tile, AEBaseTile.class);
registrar.registerNBTProvider(tile, AEBaseTile.class);
final IWailaDataProvider vanillaTile = new VanillaTileWailaDataProvider();
registrar.registerBodyProvider(vanillaTile, TileEntity.class);
registrar.registerNBTProvider(vanillaTile, TileEntity.class);
}
}
@@ -0,0 +1,51 @@
package com.glodblock.github.crossmod.waila.vanilla;
import java.util.List;
import mcp.mobius.waila.api.IWailaConfigHandler;
import mcp.mobius.waila.api.IWailaDataAccessor;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.fluids.FluidTankInfo;
import appeng.integration.modules.waila.BaseWailaDataProvider;
import com.glodblock.github.common.tile.TileCertusQuartzTank;
import com.glodblock.github.crossmod.waila.Tooltip;
import com.glodblock.github.util.Util;
public class FluidInvWailaDataProvider extends BaseWailaDataProvider {
@Override
public List<String> getWailaBody(final ItemStack itemStack, final List<String> currentToolTip,
final IWailaDataAccessor accessor, final IWailaConfigHandler config) {
final TileEntity te = accessor.getTileEntity();
if (te instanceof TileCertusQuartzTank) {
if (accessor.getNBTData().hasKey("fluidInv")) {
NBTTagCompound data = (NBTTagCompound) accessor.getNBTData().getTag("fluidInv");
for (FluidTankInfo info : Util.FluidUtil.fluidTankInfoReadFromNBT(data)) {
if (info.fluid == null) continue;
currentToolTip
.add(Tooltip.fluidFormat(info.fluid.getLocalizedName(), info.fluid.amount, info.capacity));
}
}
}
return currentToolTip;
}
@Override
public NBTTagCompound getNBTData(final EntityPlayerMP player, final TileEntity te, final NBTTagCompound tag,
final World world, final int x, final int y, final int z) {
if (te instanceof TileCertusQuartzTank) {
NBTTagCompound data = new NBTTagCompound();
Util.FluidUtil.fluidTankInfoWriteToNBT(((TileCertusQuartzTank) te).getInternalFluid(), data);
tag.setTag("fluidInv", data);
te.writeToNBT(tag);
}
return tag;
}
}
@@ -1,9 +1,8 @@
package com.glodblock.github.inventory;
import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.*;
import javax.annotation.Nullable;
@@ -16,9 +15,14 @@ import net.minecraftforge.fluids.IFluidHandler;
import appeng.api.config.FuzzyMode;
import appeng.api.config.InsertionMode;
import appeng.api.parts.IPart;
import appeng.helpers.DualityInterface;
import appeng.helpers.IInterfaceHost;
import appeng.me.GridAccessException;
import appeng.me.helpers.AENetworkProxy;
import appeng.parts.p2p.PartP2PLiquids;
import appeng.tile.misc.TileInterface;
import appeng.tile.networking.TileCableBus;
import appeng.util.InventoryAdaptor;
import appeng.util.inv.IInventoryDestination;
import appeng.util.inv.ItemSlot;
@@ -34,24 +38,47 @@ import com.glodblock.github.util.BlockPos;
import com.glodblock.github.util.ModAndClassUtil;
import com.glodblock.github.util.Util;
import crazypants.enderio.conduit.item.IItemConduit;
import gregtech.api.interfaces.metatileentity.IMetaTileEntity;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
import gregtech.api.metatileentity.MetaPipeEntity;
public class FluidConvertingInventoryAdaptor extends InventoryAdaptor {
// facing is the target TE direction
// |T|-facing->|I|
public FluidConvertingInventoryAdaptor(@Nullable InventoryAdaptor invItems, @Nullable IFluidHandler invFluids,
ForgeDirection facing, BlockPos pos, boolean isOnmi, Object eioConduct) {
ForgeDirection facing, BlockPos pos, boolean isOnmi) {
this.invItems = invItems;
this.invFluids = invFluids;
this.side = facing;
this.posInterface = pos;
this.eioDuct = eioConduct;
this.onmi = isOnmi;
this.selfInterface = getInterfaceTE(pos.getTileEntity(), facing.getOpposite());
}
private final InventoryAdaptor invItems;
private final IFluidHandler invFluids;
private final ForgeDirection side;
private final BlockPos posInterface;
private final Object eioDuct;
@Nullable
private final IInterfaceHost selfInterface;
private final boolean onmi;
private static Method eioTypeCheck;
private static Class<?> conduitClazz;
static {
if (ModAndClassUtil.EIO) {
try {
conduitClazz = Class.forName("crazypants.enderio.conduit.TileConduitBundle");
eioTypeCheck = conduitClazz.getDeclaredMethod("getConduit", Class.class);
} catch (ClassNotFoundException | NoSuchMethodException e) {
eioTypeCheck = null;
}
} else {
eioTypeCheck = null;
}
}
public static InventoryAdaptor wrap(TileEntity capProvider, ForgeDirection face) {
// sometimes i wish 1.7.10 has cap system.
@@ -69,31 +96,69 @@ public class FluidConvertingInventoryAdaptor extends InventoryAdaptor {
if (inter instanceof TileInterface) {
onmi = ((TileInterface) inter).getTargets().size() > 1;
}
Object conduct = null;
if (ModAndClassUtil.COFH && capProvider instanceof IItemDuct) {
conduct = capProvider;
}
return new FluidConvertingInventoryAdaptor(item, fluid, face, new BlockPos(inter), onmi, conduct);
return new FluidConvertingInventoryAdaptor(item, fluid, face, new BlockPos(inter), onmi);
}
public ItemStack addItems(ItemStack toBeAdded, InsertionMode insertionMode) {
FluidStack fluid = Util.getFluidFromVirtual(toBeAdded);
if (fluid != null) {
if (invFluids != null) {
if (invFluids.canFill(side, fluid.getFluid())) {
int filled = invFluids.fill(side, fluid, true);
if (filled > 0) {
fluid.amount -= filled;
return ItemFluidPacket.newStack(fluid);
}
}
if (!this.onmi) {
if (!checkValidSide(
this.posInterface.getOffSet(this.side.getOpposite()).getTileEntity(),
this.side.getOpposite())) {
return toBeAdded;
}
if (fluid != null) {
int filled = fillSideFluid(fluid, this.invFluids, this.side, true);
fluid.amount -= filled;
return ItemFluidPacket.newStack(fluid);
} else {
ItemStack notFilled = fillSideItem(toBeAdded, this.invItems, insertionMode, true);
if (notFilled != null) {
// Fill EIO Conduit at last.
return fillEIOConduit(
notFilled,
this.posInterface.getOffSet(this.side.getOpposite()).getTileEntity(),
this.side);
}
return null;
}
} else {
if (fluid != null) {
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
if (fluid.amount <= 0) {
return null;
}
if (!checkValidSide(this.posInterface.getOffSet(dir).getTileEntity(), dir)) {
continue;
}
int filled = fillSideFluid(fluid, getSideFluid(dir), dir.getOpposite(), true);
fluid.amount -= filled;
}
return ItemFluidPacket.newStack(fluid);
} else {
ItemStack item = toBeAdded.copy();
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
if (item == null || item.stackSize <= 0) {
return null;
}
if (!checkValidSide(this.posInterface.getOffSet(dir).getTileEntity(), dir)) {
continue;
}
item = fillSideItem(item, getSideItem(dir), insertionMode, true);
}
// Fill EIO Conduit at last.
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
if (item == null || item.stackSize <= 0) {
return null;
}
if (!checkValidSide(this.posInterface.getOffSet(dir).getTileEntity(), dir)) {
continue;
}
item = fillEIOConduit(item, this.posInterface.getOffSet(dir).getTileEntity(), dir.getOpposite());
}
return item;
}
return toBeAdded;
}
if (eioDuct != null) {
return ((IItemDuct) eioDuct).insertItem(side, toBeAdded);
}
return invItems != null ? invItems.addItems(toBeAdded, insertionMode) : toBeAdded;
}
@Override
@@ -109,35 +174,56 @@ public class FluidConvertingInventoryAdaptor extends InventoryAdaptor {
@Override
public ItemStack simulateAdd(ItemStack toBeSimulated, InsertionMode insertionMode) {
FluidStack fluid = Util.getFluidFromVirtual(toBeSimulated);
if (fluid != null) {
if (onmi) {
boolean sus = false;
for (ForgeDirection dir : ForgeDirection.values()) {
TileEntity te = posInterface.getOffSet(dir).getTileEntity();
if (te instanceof IFluidHandler) {
int filled = ((IFluidHandler) te).fill(dir.getOpposite(), fluid, false);
if (filled > 0) {
sus = true;
break;
}
if (!this.onmi) {
if (!checkValidSide(
this.posInterface.getOffSet(this.side.getOpposite()).getTileEntity(),
this.side.getOpposite())) {
return toBeSimulated;
}
if (fluid != null) {
int filled = fillSideFluid(fluid, this.invFluids, this.side, false);
fluid.amount -= filled;
return ItemFluidPacket.newStack(fluid);
} else {
// Assert EIO conduit can hold all item, as it is the origin practice in AE2
if (isConduit(this.posInterface.getOffSet(this.side.getOpposite()).getTileEntity())) {
return null;
} else {
return fillSideItem(toBeSimulated, this.invItems, insertionMode, false);
}
}
} else {
// In onmi mode, fluid/item only need to be partly inserted.
boolean sus = false;
if (fluid != null) {
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
if (!checkValidSide(this.posInterface.getOffSet(dir).getTileEntity(), dir)) {
continue;
}
int filled = fillSideFluid(fluid, getSideFluid(dir), dir.getOpposite(), false);
if (filled > 0) {
sus = true;
break;
}
}
return sus ? null : toBeSimulated;
}
if (invFluids != null) {
int filled = invFluids.fill(side, fluid, false);
if (filled > 0) {
fluid.amount -= filled;
return ItemFluidPacket.newStack(fluid);
} else {
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
if (!checkValidSide(this.posInterface.getOffSet(dir).getTileEntity(), dir)) {
continue;
}
// Assert EIO conduit can hold all item, as it is the origin practice in AE2
if (isConduit(this.posInterface.getOffSet(dir).getTileEntity())) {
return null;
}
ItemStack notFilled = fillSideItem(toBeSimulated, getSideItem(dir), insertionMode, false);
if (notFilled == null || notFilled.stackSize < toBeSimulated.stackSize) {
sus = true;
break;
}
}
}
return toBeSimulated;
return sus ? null : toBeSimulated;
}
// Assert EIO conduct can hold all item, as it is the origin practice in AE2
if (eioDuct != null) {
return null;
}
return invItems != null ? invItems.simulateAdd(toBeSimulated, insertionMode) : toBeSimulated;
}
@Override
@@ -164,15 +250,123 @@ public class FluidConvertingInventoryAdaptor extends InventoryAdaptor {
@Override
public boolean containsItems() {
if (invFluids == null && invItems == null) {
// If this entity doesn't have fluid or item inventory, we just view it as full of things.
return true;
if (!this.onmi) {
// If there is no fluid tank or item inventory, it shouldn't send stuff here.
return checkItemFluids(this.invFluids, this.invItems, this.side) > 0;
}
if (invFluids != null && invFluids.getTankInfo(this.side) != null) {
boolean anyValid = false;
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
// Avoid sending stuff into itself me network
if (checkValidSide(this.posInterface.getOffSet(dir).getTileEntity(), dir)
&& !isItemConduit(this.posInterface.getOffSet(dir).getTileEntity())) {
final int result = checkItemFluids(this.getSideFluid(dir), this.getSideItem(dir), dir.getOpposite());
if (result == 1) {
return true;
}
if (result != 2) {
anyValid = true;
}
}
}
// Same here. if there is no fluid tank or item inventory existed, it shouldn't send stuff here.
return !anyValid;
}
public boolean hasSlots() {
return (invFluids != null && invFluids.getTankInfo(side).length > 0) || (invItems != null);
}
@Override
public Iterator<ItemSlot> iterator() {
return new SlotIterator(
invFluids != null ? invFluids.getTankInfo(side) : new FluidTankInfo[0],
invItems != null ? invItems.iterator() : Collections.emptyIterator());
}
private IFluidHandler getSideFluid(ForgeDirection direction) {
TileEntity te = this.posInterface.getOffSet(direction).getTileEntity();
if (te instanceof IFluidHandler) {
return (IFluidHandler) te;
}
return null;
}
private int fillSideFluid(FluidStack fluid, IFluidHandler tank, ForgeDirection direction, boolean doFill) {
if (tank != null) {
return tank.fill(direction, fluid, doFill);
}
return 0;
}
// EIO conduit isn't considered here
private ItemStack fillSideItem(ItemStack item, InventoryAdaptor inv, InsertionMode mode, boolean doFill) {
if (inv != null) {
if (doFill) {
return inv.addItems(item, mode);
} else {
return inv.simulateAdd(item, mode);
}
}
return item;
}
private int gtMachineCircuitCheck(InventoryAdaptor ad) {
if (ad == null) {
return 0;
}
for (ItemSlot i : ad) {
ItemStack is = i.getItemStack();
if (is == null || Objects.requireNonNull(is.getItem()).getUnlocalizedName().equals("gt.integrated_circuit"))
continue;
return 1;
}
return 0;
}
private boolean isGTMachine(Object o) {
return ModAndClassUtil.GT5 && o instanceof TileEntity
&& ((TileEntity) o).getBlockType().getUnlocalizedName().equals("gt.blockmachines");
}
private boolean isItemConduit(TileEntity te) {
if (ModAndClassUtil.EIO && conduitClazz.isInstance(te)) {
try {
return eioTypeCheck.invoke(te, IItemConduit.class) != null;
} catch (InvocationTargetException | IllegalAccessException e) {
return false;
}
}
return false;
}
private boolean isConduit(TileEntity te) {
return ModAndClassUtil.EIO && te instanceof IItemDuct;
}
private ItemStack fillEIOConduit(ItemStack item, TileEntity te, ForgeDirection direction) {
if (isConduit(te)) {
return ((IItemDuct) te).insertItem(direction, item);
}
return item;
}
private InventoryAdaptor getSideItem(ForgeDirection direction) {
TileEntity te = this.posInterface.getOffSet(direction).getTileEntity();
return InventoryAdaptor.getAdaptor(te, direction.getOpposite());
}
// 0 - It is empty
// 1 - It contains item/fluid
// 2 - It doesn't exist
private int checkItemFluids(IFluidHandler tank, InventoryAdaptor inv, ForgeDirection direction) {
if (tank == null && inv == null) {
return 2;
}
if (tank != null && tank.getTankInfo(direction) != null) {
List<FluidTankInfo[]> tankInfos = new LinkedList<>();
if (Util.getPart(invFluids, this.side) instanceof PartP2PLiquids) {
if (Util.getPart(tank, direction) instanceof PartP2PLiquids) {
// read other ends of p2p for blocking mode
PartP2PLiquids invFluidsP2P = (PartP2PLiquids) Util.getPart(invFluids, this.side);
PartP2PLiquids invFluidsP2P = (PartP2PLiquids) Util.getPart(tank, direction);
try {
Iterator<PartP2PLiquids> it = invFluidsP2P.getOutputs().iterator();
boolean checkedInput = false;
@@ -191,35 +385,72 @@ public class FluidConvertingInventoryAdaptor extends InventoryAdaptor {
}
} catch (GridAccessException ignore) {}
} else {
tankInfos.add(invFluids.getTankInfo(this.side));
tankInfos.add(tank.getTankInfo(direction));
}
boolean hasTank = false;
for (FluidTankInfo[] tankInfoArray : tankInfos) {
for (FluidTankInfo tank : tankInfoArray) {
for (FluidTankInfo tankInfo : tankInfoArray) {
hasTank = true;
FluidStack fluid = tank.fluid;
FluidStack fluid = tankInfo.fluid;
if (fluid != null && fluid.amount > 0) {
return true;
return 1;
}
}
}
if (!hasTank && invItems == null) {
// If this entity doesn't have fluid or item inventory, we just view it as full of things.
if (!hasTank && inv == null) {
return 2;
}
}
if (isGTMachine(tank)) {
return gtMachineCircuitCheck(inv);
}
return inv != null && inv.containsItems() ? 1 : 0;
}
private boolean checkValidSide(TileEntity te, ForgeDirection direction) {
if (isGTMachine(te)) {
return checkGTPipeConnection(te, direction.getOpposite());
}
return isDifferentGrid(getInterfaceTE(te, direction.getOpposite()));
}
private boolean checkGTPipeConnection(TileEntity te, ForgeDirection direction) {
if (te instanceof IGregTechTileEntity) {
IMetaTileEntity mte = ((IGregTechTileEntity) te).getMetaTileEntity();
if (mte instanceof MetaPipeEntity) {
return ((MetaPipeEntity) mte).isConnectedAtSide(direction.ordinal());
}
}
return true;
}
private static IInterfaceHost getInterfaceTE(TileEntity te, ForgeDirection face) {
if (te instanceof IInterfaceHost) {
return (IInterfaceHost) te;
} else if (te instanceof TileCableBus) {
IPart part = ((TileCableBus) te).getPart(face);
if (part instanceof IInterfaceHost) {
return (IInterfaceHost) part;
}
}
return null;
}
private boolean isDifferentGrid(IInterfaceHost target) {
if (this.selfInterface != null && target != null) {
DualityInterface other = target.getInterfaceDuality();
DualityInterface self = this.selfInterface.getInterfaceDuality();
try {
AENetworkProxy proxy1 = Ae2Reflect.getInterfaceProxy(other);
AENetworkProxy proxy2 = Ae2Reflect.getInterfaceProxy(self);
if (proxy1.getGrid() == proxy2.getGrid()) {
return false;
}
} catch (GridAccessException e) {
return true;
}
}
return invItems != null && invItems.containsItems();
}
public boolean hasSlots() {
return (invFluids != null && invFluids.getTankInfo(side).length > 0) || (invItems != null);
}
@Override
public Iterator<ItemSlot> iterator() {
return new SlotIterator(
invFluids != null ? invFluids.getTankInfo(side) : new FluidTankInfo[0],
invItems != null ? invItems.iterator() : Collections.emptyIterator());
return true;
}
private static class SlotIterator implements Iterator<ItemSlot> {
@@ -6,6 +6,8 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import appeng.util.Platform;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.network.CPacketSwitchGuis;
@@ -22,6 +24,9 @@ public class InventoryHandler implements IGuiHandler {
}
public static void openGui(EntityPlayer player, World world, BlockPos pos, ForgeDirection face, GuiType guiType) {
if (Platform.isClient()) {
return;
}
player.openGui(
FluidCraft.INSTANCE,
(guiType.ordinal() << 3) | face.ordinal(),
@@ -19,6 +19,14 @@ public class ItemBiggerAppEngInventory extends BiggerAppEngInventory {
this.readFromNBT(Platform.openNbtData(is), name);
}
public void setCraftingMode(boolean mode) {
Platform.openNbtData(is).setBoolean("craftingMode", mode);
}
public boolean getCraftingMode(boolean mode) {
return Platform.openNbtData(is).getBoolean("craftingMode");
}
@Override
public void markDirty() {
boolean isCraft = Platform.openNbtData(is).getBoolean("craftingMode");
@@ -3,20 +3,54 @@ package com.glodblock.github.inventory;
import net.minecraft.item.ItemStack;
import appeng.tile.inventory.AppEngInternalInventory;
import appeng.tile.inventory.InvOperation;
import appeng.util.Platform;
import com.glodblock.github.inventory.item.IWirelessPatternTerminal;
public class WirelessFluidPatternTerminalPatterns extends AppEngInternalInventory {
private final ItemStack is;
private final IWirelessPatternTerminal terminal;
public WirelessFluidPatternTerminalPatterns(final ItemStack is) {
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 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();
}
}
@@ -27,6 +27,18 @@ import com.google.common.collect.ImmutableList;
public enum GuiType {
RENAMER(new PartOrItemGuiFactory<ITerminalHost>(ITerminalHost.class) {
@Override
protected Object createServerGui(EntityPlayer player, ITerminalHost inv) {
return new ContainerRenamer(player.inventory, inv);
}
@Override
protected Object createClientGui(EntityPlayer player, ITerminalHost inv) {
return new GuiRenamer(player.inventory, inv);
}
}),
FLUID_AUTO_FILLER(new TileGuiFactory<TileFluidAutoFiller>(TileFluidAutoFiller.class) {
@Override
@@ -12,6 +12,7 @@ import appeng.container.AEBaseContainer;
import appeng.container.ContainerOpenContext;
import com.glodblock.github.inventory.item.IItemInventory;
import com.glodblock.github.util.Util;
public abstract class ItemGuiFactory<T> implements IGuiFactory {
@@ -29,7 +30,7 @@ public abstract class ItemGuiFactory<T> implements IGuiFactory {
@Nullable
@Override
public Object createServerGui(EntityPlayer player, World world, int x, int y, int z, ForgeDirection face) {
ItemStack item = player.getHeldItem();
ItemStack item = Util.getWirelessTerminal(player, x);
if (item == null || !(item.getItem() instanceof IItemInventory)) {
return null;
}
@@ -56,7 +57,7 @@ public abstract class ItemGuiFactory<T> implements IGuiFactory {
@Nullable
@Override
public Object createClientGui(EntityPlayer player, World world, int x, int y, int z, ForgeDirection face) {
ItemStack item = player.getHeldItem();
ItemStack item = Util.getWirelessTerminal(player, x);
if (item == null || !(item.getItem() instanceof IItemInventory)) {
return null;
}
@@ -30,9 +30,8 @@ public abstract class PartOrItemGuiFactory<T> extends PartGuiFactory<T> {
@Override
public Object createServerGui(EntityPlayer player, World world, int x, int y, int z, ForgeDirection face) {
ImmutablePair<Util.GuiHelper.GuiType, Integer> result = Util.GuiHelper.decodeType(y);
if (result.getLeft() == Util.GuiHelper.GuiType.ITEM) {
ItemStack item = player.getHeldItem();
ItemStack item = Util.getWirelessTerminal(player, x);
if (item == null || !(item.getItem() instanceof IItemInventory)) {
return null;
}
@@ -63,7 +62,7 @@ public abstract class PartOrItemGuiFactory<T> extends PartGuiFactory<T> {
public Object createClientGui(EntityPlayer player, World world, int x, int y, int z, ForgeDirection face) {
ImmutablePair<Util.GuiHelper.GuiType, Integer> result = Util.GuiHelper.decodeType(y);
if (result.left == Util.GuiHelper.GuiType.ITEM) {
ItemStack item = player.getHeldItem();
ItemStack item = Util.getWirelessTerminal(player, x);
if (item == null || !(item.getItem() instanceof IItemInventory)) {
return null;
}
@@ -35,4 +35,8 @@ public interface IItemPatternTerminal extends IItemTerminal {
boolean isCraftingRecipe();
void sortCraftingItems();
boolean isAutoFillPattern();
void setAutoFillPattern(boolean canFill);
}
@@ -1,4 +1,10 @@
package com.glodblock.github.inventory.item;
import com.glodblock.github.util.Util;
public interface IWirelessInterfaceTerminal extends IWirelessTerminal {
void setClickedInterface(Util.DimensionalCoordSide tile);
Util.DimensionalCoordSide getClickedInterface();
}
@@ -88,6 +88,7 @@ public class WirelessFluidTerminalInventory extends MEMonitorHandler<IAEFluidSta
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;
}
@@ -1,5 +1,7 @@
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;
@@ -10,6 +12,7 @@ import appeng.api.config.*;
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;
@@ -19,18 +22,38 @@ import appeng.tile.inventory.InvOperation;
import appeng.util.ConfigManager;
import appeng.util.Platform;
import com.glodblock.github.util.Util;
public class WirelessInterfaceTerminalInventory implements IWirelessInterfaceTerminal {
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
@@ -108,4 +131,15 @@ public class WirelessInterfaceTerminalInventory implements IWirelessInterfaceTer
ItemStack newStack) {
}
@Override
public void setClickedInterface(Util.DimensionalCoordSide tile) {
this.tile = tile;
this.writeToNBT();
}
@Override
public Util.DimensionalCoordSide getClickedInterface() {
return this.tile;
}
}
@@ -11,8 +11,10 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.util.ForgeDirection;
import appeng.api.config.*;
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.IMEInventoryHandler;
import appeng.api.storage.IMEMonitor;
import appeng.api.storage.MEMonitorHandler;
@@ -28,6 +30,7 @@ import appeng.tile.inventory.InvOperation;
import appeng.util.ConfigManager;
import appeng.util.Platform;
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;
@@ -53,6 +56,7 @@ public class WirelessPatternTerminalExInventory extends MEMonitorHandler<IAEItem
protected boolean prioritize = false;
protected boolean inverted = false;
protected boolean beSubstitute = false;
protected boolean autoFillPattern = false;
protected int activePage = 0;
@SuppressWarnings("unchecked")
@@ -67,7 +71,7 @@ public class WirelessPatternTerminalExInventory extends MEMonitorHandler<IAEItem
this.inventorySlot = slot;
this.viewCell = new WirelessTerminalViewCells(is);
this.channel = StorageChannel.ITEMS;
this.pattern = new WirelessFluidPatternTerminalPatterns(is);
this.pattern = new WirelessFluidPatternTerminalPatterns(is, this);
this.crafting = new ItemBiggerAppEngInventory(is, "crafting_ex", 32);
this.output = new ItemBiggerAppEngInventory(is, "output_ex", 32);
}
@@ -108,6 +112,7 @@ public class WirelessPatternTerminalExInventory extends MEMonitorHandler<IAEItem
this.setPrioritization(data.getBoolean("priorization"));
this.setInverted(data.getBoolean("inverted"));
this.setActivePage(data.getInteger("activePage"));
this.setAutoFillPattern(data.getBoolean("autoFillPattern"));
}
public void writeToNBT() {
@@ -118,6 +123,7 @@ public class WirelessPatternTerminalExInventory extends MEMonitorHandler<IAEItem
data.setBoolean("priorization", this.prioritize);
data.setBoolean("inverted", this.inverted);
data.setInteger("activePage", this.activePage);
data.setBoolean("autoFillPattern", this.autoFillPattern);
}
@Override
@@ -167,7 +173,84 @@ public class WirelessPatternTerminalExInventory extends MEMonitorHandler<IAEItem
@Override
public void onChangeInventory(IInventory inv, int slot, InvOperation mc, ItemStack removedStack,
ItemStack newStack) {
// NO-OP
if (inv == this.pattern && slot == 1) {
final ItemStack is = inv.getStackInSlot(1);
if (is != null && is.getItem() instanceof ICraftingPatternItem) {
final ICraftingPatternItem pattern = (ICraftingPatternItem) is.getItem();
final ICraftingPatternDetails details = pattern
.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() {
@@ -243,6 +326,8 @@ public class WirelessPatternTerminalExInventory extends MEMonitorHandler<IAEItem
public void setCraftingRecipe(boolean craftingMode) {
this.craftingMode = craftingMode;
this.fixCraftingRecipes();
// force update crafting mode
((ItemBiggerAppEngInventory) this.crafting).setCraftingMode(craftingMode);
}
@Override
@@ -316,6 +401,16 @@ public class WirelessPatternTerminalExInventory extends MEMonitorHandler<IAEItem
saveChanges();
}
@Override
public boolean isAutoFillPattern() {
return this.autoFillPattern;
}
@Override
public void setAutoFillPattern(boolean canFill) {
this.autoFillPattern = canFill;
}
@Override
public void saveSettings() {
this.writeToNBT();
@@ -11,8 +11,10 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.util.ForgeDirection;
import appeng.api.config.*;
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.IMEInventoryHandler;
import appeng.api.storage.IMEMonitor;
import appeng.api.storage.MEMonitorHandler;
@@ -28,6 +30,7 @@ import appeng.tile.inventory.InvOperation;
import appeng.util.ConfigManager;
import appeng.util.Platform;
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;
@@ -53,6 +56,7 @@ public class WirelessPatternTerminalInventory extends MEMonitorHandler<IAEItemSt
protected boolean prioritize = false;
protected boolean inverted = false;
protected boolean beSubstitute = false;
protected boolean autoFillPattern = false;
protected int activePage = 0;
@SuppressWarnings("unchecked")
@@ -67,7 +71,7 @@ public class WirelessPatternTerminalInventory extends MEMonitorHandler<IAEItemSt
this.inventorySlot = slot;
this.viewCell = new WirelessTerminalViewCells(is);
this.channel = StorageChannel.ITEMS;
this.pattern = new WirelessFluidPatternTerminalPatterns(is);
this.pattern = new WirelessFluidPatternTerminalPatterns(is, this);
this.crafting = new ItemBiggerAppEngInventory(is, "crafting", 9);
this.output = new ItemBiggerAppEngInventory(is, "output", 3);
}
@@ -106,9 +110,8 @@ public class WirelessPatternTerminalInventory extends MEMonitorHandler<IAEItemSt
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() {
@@ -117,9 +120,8 @@ public class WirelessPatternTerminalInventory extends MEMonitorHandler<IAEItemSt
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
@@ -169,7 +171,58 @@ public class WirelessPatternTerminalInventory extends MEMonitorHandler<IAEItemSt
@Override
public void onChangeInventory(IInventory inv, int slot, InvOperation mc, ItemStack removedStack,
ItemStack newStack) {
// NO-OP
if (inv == this.pattern && slot == 1) {
final ItemStack is = inv.getStackInSlot(1);
if (is != null && is.getItem() instanceof ICraftingPatternItem) {
final ICraftingPatternItem pattern = (ICraftingPatternItem) is.getItem();
final ICraftingPatternDetails details = pattern
.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() {
@@ -185,7 +238,7 @@ public class WirelessPatternTerminalInventory extends MEMonitorHandler<IAEItemSt
@Override
public boolean isInverted() {
return this.inverted;
return false;
}
@Override
@@ -212,7 +265,7 @@ public class WirelessPatternTerminalInventory extends MEMonitorHandler<IAEItemSt
@Override
public boolean isPrioritize() {
return this.prioritize;
return false;
}
@Override
@@ -245,6 +298,8 @@ public class WirelessPatternTerminalInventory extends MEMonitorHandler<IAEItemSt
public void setCraftingRecipe(boolean craftingMode) {
this.craftingMode = craftingMode;
this.fixCraftingRecipes();
// force update crafting mode
((ItemBiggerAppEngInventory) this.crafting).setCraftingMode(craftingMode);
}
@Override
@@ -318,6 +373,16 @@ public class WirelessPatternTerminalInventory extends MEMonitorHandler<IAEItemSt
saveChanges();
}
@Override
public boolean isAutoFillPattern() {
return this.autoFillPattern;
}
@Override
public void setAutoFillPattern(boolean canFill) {
this.autoFillPattern = canFill;
}
@Override
public void saveSettings() {
this.writeToNBT();
@@ -54,6 +54,8 @@ public class ChannelLoader implements Runnable {
.registerMessage(new SPacketSetItemAmount.Handler(), SPacketSetItemAmount.class, id++, Side.CLIENT);
FluidCraft.proxy.netHandler
.registerMessage(new CPacketRenamer.Handler(), CPacketRenamer.class, id++, Side.SERVER);
FluidCraft.proxy.netHandler
.registerMessage(new SPacketStringUpdate.Handler(), SPacketStringUpdate.class, id++, Side.CLIENT);
}
public static void sendPacketToAllPlayers(Packet packet, World world) {
@@ -1,9 +1,12 @@
package com.glodblock.github.loader;
import static com.glodblock.github.common.storage.FluidCellInventory.singleByteAmount;
import com.glodblock.github.common.Config;
import com.glodblock.github.common.block.*;
import com.glodblock.github.common.item.*;
import com.glodblock.github.common.storage.CellType;
import com.glodblock.github.util.NameConst;
public class ItemAndBlockHolder {
@@ -38,28 +41,57 @@ public class ItemAndBlockHolder {
public static ItemWirelessInterfaceTerminal WIRELESS_INTERFACE_TERM = new ItemWirelessInterfaceTerminal()
.register();
public static ItemFluidPacket PACKET = new ItemFluidPacket().register();
public static ItemBasicFluidStorageCell CELL1K = new ItemBasicFluidStorageCell(CellType.Cell1kPart, 1).register();
public static ItemBasicFluidStorageCell CELL4K = new ItemBasicFluidStorageCell(CellType.Cell4kPart, 4).register();
public static ItemBasicFluidStorageCell CELL16K = new ItemBasicFluidStorageCell(CellType.Cell16kPart, 16)
public static ItemBasicFluidStorageCell CELL1K = new ItemBasicFluidStorageCell(CellType.Cell1kPart, 0, 1)
.register();
public static ItemBasicFluidStorageCell CELL64K = new ItemBasicFluidStorageCell(CellType.Cell64kPart, 64)
public static ItemBasicFluidStorageCell CELL4K = new ItemBasicFluidStorageCell(CellType.Cell4kPart, 0, 4)
.register();
public static ItemBasicFluidStorageCell CELL256K = new ItemBasicFluidStorageCell(CellType.Cell256kPart, 256)
public static ItemBasicFluidStorageCell CELL16K = new ItemBasicFluidStorageCell(CellType.Cell16kPart, 0, 16)
.register();
public static ItemBasicFluidStorageCell CELL1024K = new ItemBasicFluidStorageCell(CellType.Cell1024kPart, 1024)
public static ItemBasicFluidStorageCell CELL64K = new ItemBasicFluidStorageCell(CellType.Cell64kPart, 0, 64)
.register();
public static ItemBasicFluidStorageCell CELL4096K = new ItemBasicFluidStorageCell(CellType.Cell4096kPart, 4096)
public static ItemBasicFluidStorageCell CELL256K = new ItemBasicFluidStorageCell(CellType.Cell256kPart, 1, 256)
.register();
public static ItemBasicFluidStorageCell CELL16384K = new ItemBasicFluidStorageCell(CellType.Cell16384kPart, 16384)
public static ItemBasicFluidStorageCell CELL1024K = new ItemBasicFluidStorageCell(CellType.Cell1024kPart, 1, 1024)
.register();
public static ItemBasicFluidStorageCell CELL131072K = new ItemBasicFluidStorageCell(
CellType.Cell131072kPart,
131072).register();
public static ItemBasicFluidStorageCell CELL554160890921312K = new ItemBasicFluidStorageCell(
CellType.Cell554160890921312kPart,
554160890921312L).register();
public static ItemBasicFluidStorageCell CELL4096K = new ItemBasicFluidStorageCell(CellType.Cell4096kPart, 1, 4096)
.register();
public static ItemBasicFluidStorageCell CELL16384K = new ItemBasicFluidStorageCell(
CellType.Cell16384kPart,
1,
16384).register();
public static ItemMultiFluidStorageCell CELL1KM = new ItemMultiFluidStorageCell(CellType.Cell1kPart, 2, 1)
.register();
public static ItemMultiFluidStorageCell CELL4KM = new ItemMultiFluidStorageCell(CellType.Cell4kPart, 2, 4)
.register();
public static ItemMultiFluidStorageCell CELL16KM = new ItemMultiFluidStorageCell(CellType.Cell16kPart, 2, 16)
.register();
public static ItemMultiFluidStorageCell CELL64KM = new ItemMultiFluidStorageCell(CellType.Cell64kPart, 2, 64)
.register();
public static ItemMultiFluidStorageCell CELL256KM = new ItemMultiFluidStorageCell(CellType.Cell256kPart, 3, 256)
.register();
public static ItemMultiFluidStorageCell CELL1024KM = new ItemMultiFluidStorageCell(CellType.Cell1024kPart, 3, 1024)
.register();
public static ItemMultiFluidStorageCell CELL4096KM = new ItemMultiFluidStorageCell(CellType.Cell4096kPart, 3, 4096)
.register();
public static ItemMultiFluidStorageCell CELL16384KM = new ItemMultiFluidStorageCell(
CellType.Cell16384kPart,
3,
16384).register();
public static ItemFluidExtremeStorageCell QUANTUM_CELL = new ItemFluidExtremeStorageCell(
NameConst.ITEM_QUANTUM_FLUID_STORAGE,
Integer.MAX_VALUE / 16,
8,
5,
4.5).register();
public static ItemFluidExtremeStorageCell SINGULARITY_CELL = new ItemFluidExtremeStorageCell(
NameConst.ITEM_SINGULARITY_FLUID_STORAGE,
Long.MAX_VALUE / (singleByteAmount * 2),
8,
1,
5).register();
public static ItemCreativeFluidStorageCell CREATIVE_CELL = new ItemCreativeFluidStorageCell().register();
public static ItemBasicFluidStoragePart CELL_PART = new ItemBasicFluidStoragePart().register();
public static ItemFluidStorageHousing CELL_HOUSING = new ItemFluidStorageHousing().register();
public static void loadSetting() {
if (!Config.fluidCells) return;
@@ -0,0 +1,50 @@
package com.glodblock.github.loader;
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.EntityClientPlayerMP;
import net.minecraft.client.settings.KeyBinding;
import net.minecraft.item.ItemStack;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.lwjgl.input.Keyboard;
import com.glodblock.github.common.item.ItemWirelessUltraTerminal;
import com.glodblock.github.util.Util;
import cpw.mods.fml.client.registry.ClientRegistry;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.InputEvent;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class KeybindLoader implements Runnable {
public static KeyBinding openTerminal;
@Override
public void run() {
openTerminal = new KeyBinding("key.OpenTerminal", Keyboard.CHAR_NONE, "itemGroup.ae2fc");
ClientRegistry.registerKeyBinding(openTerminal);
FMLCommonHandler.instance().bus().register(this);
}
@SubscribeEvent
public void onKeyInput(InputEvent.KeyInputEvent event) {
if (Minecraft.getMinecraft().currentScreen != null) return;
EntityClientPlayerMP p = Minecraft.getMinecraft().thePlayer;
if (p.openContainer == null) {
return;
}
if (openTerminal.isPressed()) {
ImmutablePair<Integer, ItemStack> term = Util.getUltraWirelessTerm(p);
if (term != null && term.getRight().getItem() instanceof ItemWirelessUltraTerminal) {
ItemWirelessUltraTerminal.switchTerminal(
p,
((ItemWirelessUltraTerminal) term.getRight().getItem()).guiGuiType(term.getRight()));
}
}
}
}
@@ -2,6 +2,7 @@ package com.glodblock.github.loader;
import static com.glodblock.github.common.storage.CellType.Cell16384kPart;
import static com.glodblock.github.loader.ItemAndBlockHolder.*;
import static com.glodblock.github.loader.ItemAndBlockHolder.CELL4KM;
import static net.minecraft.init.Blocks.redstone_torch;
import static net.minecraft.init.Items.fish;
@@ -16,7 +17,7 @@ import net.minecraftforge.oredict.ShapedOreRecipe;
import net.minecraftforge.oredict.ShapelessOreRecipe;
import com.glodblock.github.common.Config;
import com.glodblock.github.common.item.ItemBasicFluidStorageCell;
import com.glodblock.github.common.item.FCBaseItemCell;
import com.glodblock.github.common.storage.CellType;
import com.glodblock.github.loader.recipe.WirelessTerminalRecipe;
import com.glodblock.github.util.ModAndClassUtil;
@@ -66,10 +67,6 @@ public class RecipeLoader implements Runnable {
.findItemStack("appliedenergistics2", "tile.BlockQuartzGlass", 1);
public static final ItemStack AE2_LAMP_GLASS = GameRegistry
.findItemStack("appliedenergistics2", "tile.BlockQuartzLamp", 1);
public static final ItemStack AE2_CELL_HOUSING = new ItemStack(
GameRegistry.findItem("appliedenergistics2", "item.ItemMultiMaterial"),
1,
39);
public static final ItemStack AE2_CELL_1K = new ItemStack(
GameRegistry.findItem("appliedenergistics2", "item.ItemMultiMaterial"),
1,
@@ -397,11 +394,12 @@ public class RecipeLoader implements Runnable {
'G',
AE2_LAMP_GLASS));
ItemBasicFluidStorageCell[] cells = new ItemBasicFluidStorageCell[] { CELL1K, CELL4K, CELL16K, CELL64K,
CELL256K, CELL1024K, CELL4096K, CELL16384K };
FCBaseItemCell[] cells = new FCBaseItemCell[] { CELL1K, CELL4K, CELL16K, CELL64K, CELL256K, CELL1024K,
CELL4096K, CELL16384K, CELL1KM, CELL4KM, CELL16KM, CELL64KM, CELL256KM, CELL1024KM, CELL4096KM,
CELL16384KM };
GameRegistry.addRecipe(
new ShapedOreRecipe(
CELL131072K.stack(),
QUANTUM_CELL.stack(),
"RCR",
"CEC",
"RCR",
@@ -413,31 +411,126 @@ public class RecipeLoader implements Runnable {
AE2_QUANTUM_RING));
GameRegistry.addRecipe(
new ShapedOreRecipe(
CELL554160890921312K.stack(),
SINGULARITY_CELL.stack(),
"CCC",
"CMC",
"CCC",
'C',
CELL131072K,
QUANTUM_CELL,
'M',
AE2_MATTER_CONDENSER));
for (ItemBasicFluidStorageCell cell : cells) {
GameRegistry.addRecipe(
new ShapedOreRecipe(
cell,
"GDG",
"DCD",
"III",
'D',
"dustRedstone",
'G',
AE2_QUARTZ_GLASS,
'C',
cell.getComponent(),
'I',
"ingotIron"));
GameRegistry.addRecipe(new ShapelessOreRecipe(cell, AE2_CELL_HOUSING, cell.getComponent()));
for (FCBaseItemCell cell : cells) {
if (cell.getHousing().getItemDamage() == 0) {
GameRegistry.addRecipe(
new ShapedOreRecipe(
cell,
"GDG",
"DCD",
"III",
'D',
"dyeRed",
'G',
AE2_QUARTZ_GLASS,
'C',
cell.getComponent(),
'I',
"ingotIron"));
} else if (cell.getHousing().getItemDamage() == 1) {
GameRegistry.addRecipe(
new ShapedOreRecipe(
cell,
"GDG",
"DCD",
"III",
'D',
"dustRedstone",
'G',
AE2_LAMP_GLASS,
'C',
cell.getComponent(),
'I',
"gemDiamond"));
} else if (cell.getHousing().getItemDamage() == 2) {
GameRegistry.addRecipe(
new ShapedOreRecipe(
cell,
"GDG",
"DCD",
"III",
'D',
"dyeBlue",
'G',
AE2_QUARTZ_GLASS,
'C',
cell.getComponent(),
'I',
"ingotIron"));
} else if (cell.getHousing().getItemDamage() == 3) {
GameRegistry.addRecipe(
new ShapedOreRecipe(
cell,
"GDG",
"DCD",
"III",
'D',
"dustGlowstone",
'G',
AE2_LAMP_GLASS,
'C',
cell.getComponent(),
'I',
"gemDiamond"));
}
GameRegistry.addRecipe(new ShapelessOreRecipe(cell, cell.getHousing(), cell.getComponent()));
}
GameRegistry.addRecipe(
new ShapedOreRecipe(
CELL_HOUSING.stack(1, 0),
"GDG",
"D D",
"III",
'D',
"dyeRed",
'G',
AE2_QUARTZ_GLASS,
'I',
"ingotIron"));
GameRegistry.addRecipe(
new ShapedOreRecipe(
CELL_HOUSING.stack(1, 1),
"GDG",
"D D",
"III",
'D',
"dustRedstone",
'G',
AE2_LAMP_GLASS,
'I',
"gemDiamond"));
GameRegistry.addRecipe(
new ShapedOreRecipe(
CELL_HOUSING.stack(1, 2),
"GDG",
"D D",
"III",
'D',
"dyeBlue",
'G',
AE2_QUARTZ_GLASS,
'I',
"ingotIron"));
GameRegistry.addRecipe(
new ShapedOreRecipe(
CELL_HOUSING.stack(1, 3),
"GDG",
"D D",
"III",
'D',
"dustGlowstone",
'G',
AE2_LAMP_GLASS,
'I',
"gemDiamond"));
}
if (Config.fluidIOBus) {
@@ -46,9 +46,9 @@ public class NEIItemFilter implements SearchField.ISearchProvider {
final IFluidCellInventory cellInventory = handler.getCellInv();
if (cellInventory != null) {
for (IAEFluidStack fluid : cellInventory.getContents()) {
if (fluid != null) {
return pattern.matcher(fluid.getFluidStack().getLocalizedName().toLowerCase()).find();
}
boolean result = pattern.matcher(fluid.getFluidStack().getLocalizedName().toLowerCase())
.find();
if (result) return true;
}
}
@@ -6,6 +6,7 @@ import codechicken.nei.api.IConfigureNEI;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.*;
import com.glodblock.github.nei.recipes.FluidRecipe;
import com.glodblock.github.util.ModAndClassUtil;
public class NEI_FC_Config implements IConfigureNEI {
@@ -13,27 +14,46 @@ public class NEI_FC_Config implements IConfigureNEI {
public void loadConfig() {
API.registerNEIGuiHandler(new NEIGuiHandler());
API.addSearchProvider(new NEIItemFilter());
if (ModAndClassUtil.AVARITIA) {
API.registerGuiOverlay(GuiFluidPatternWireless.class, "extreme", null);
API.registerGuiOverlay(GuiFluidPatternExWireless.class, "extreme", null);
API.registerGuiOverlay(GuiFluidPatternTerminal.class, "extreme", null);
API.registerGuiOverlay(GuiFluidPatternTerminalEx.class, "extreme", null);
}
for (String identifier : FluidRecipe.getSupportRecipes()) {
API.registerGuiOverlayHandler(
GuiFluidCraftingWireless.class,
FluidCraftingTransferHandler.INSTANCE,
identifier);
API.registerGuiOverlayHandler(
GuiFluidPatternWireless.class,
FluidPatternTerminalRecipeTransferHandler.INSTANCE,
identifier);
API.registerGuiOverlayHandler(
GuiFluidPatternExWireless.class,
FluidPatternTerminalRecipeTransferHandler.INSTANCE,
identifier);
API.registerGuiOverlayHandler(
GuiFluidPatternTerminal.class,
FluidPatternTerminalRecipeTransferHandler.INSTANCE,
identifier);
API.registerGuiOverlayHandler(
GuiFluidPatternTerminalEx.class,
FluidPatternTerminalRecipeTransferHandler.INSTANCE,
identifier);
// that NEE handlers take priority
if (!API.hasGuiOverlayHandler(GuiFluidCraftingWireless.class, identifier)) {
API.registerGuiOverlayHandler(
GuiFluidCraftingWireless.class,
FluidCraftingTransferHandler.INSTANCE,
identifier);
}
if (!API.hasGuiOverlayHandler(GuiFluidPatternWireless.class, identifier)) {
API.registerGuiOverlayHandler(
GuiFluidPatternWireless.class,
FluidPatternTerminalRecipeTransferHandler.INSTANCE,
identifier);
}
if (!API.hasGuiOverlayHandler(GuiFluidPatternExWireless.class, identifier)) {
API.registerGuiOverlayHandler(
GuiFluidPatternExWireless.class,
FluidPatternTerminalRecipeTransferHandler.INSTANCE,
identifier);
}
if (!API.hasGuiOverlayHandler(GuiFluidPatternTerminal.class, identifier)) {
API.registerGuiOverlayHandler(
GuiFluidPatternTerminal.class,
FluidPatternTerminalRecipeTransferHandler.INSTANCE,
identifier);
}
if (!API.hasGuiOverlayHandler(GuiFluidPatternTerminalEx.class, identifier)) {
API.registerGuiOverlayHandler(
GuiFluidPatternTerminalEx.class,
FluidPatternTerminalRecipeTransferHandler.INSTANCE,
identifier);
}
}
}
@@ -50,6 +50,10 @@ public class DefaultExtractorLoader implements Runnable {
FluidRecipe.addRecipeMap("EnderIOVat", new EnderIORecipeExtractor());
}
if (ModAndClassUtil.AVARITIA) {
FluidRecipe.addRecipeMap("extreme", new AvaritiaRecipeExtractor());
}
if (ModAndClassUtil.FTR) {
// GTNH
FluidRecipe.addRecipeMap("forestry.bottler", new ForestryRecipeExtractor(new NEIHandlerBottler()));
@@ -0,0 +1,36 @@
package com.glodblock.github.nei.recipes.extractor;
import java.util.List;
import codechicken.nei.PositionedStack;
import codechicken.nei.recipe.IRecipeHandler;
import com.glodblock.github.nei.NEIUtils;
import com.glodblock.github.nei.object.IRecipeExtractor;
import com.glodblock.github.nei.object.OrderStack;
public class AvaritiaRecipeExtractor implements IRecipeExtractor {
public AvaritiaRecipeExtractor() {}
@Override
public List<OrderStack<?>> getInputIngredients(List<PositionedStack> rawInputs, IRecipeHandler recipe, int index) {
return getInputIngredients(rawInputs);
}
@Override
public List<OrderStack<?>> getOutputIngredients(List<PositionedStack> rawOutputs, IRecipeHandler recipe,
int index) {
return getOutputIngredients(rawOutputs);
}
@Override
public List<OrderStack<?>> getInputIngredients(List<PositionedStack> rawInputs) {
return NEIUtils.compress(ExtractorUtil.packItemStack(rawInputs));
}
@Override
public List<OrderStack<?>> getOutputIngredients(List<PositionedStack> rawOutputs) {
return ExtractorUtil.packItemStack(rawOutputs);
}
}
@@ -21,6 +21,7 @@ import appeng.core.AELog;
import com.glodblock.github.client.gui.container.ContainerFluidCraftConfirm;
import com.glodblock.github.inventory.InventoryHandler;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.inventory.item.IWirelessTerminal;
import com.glodblock.github.util.BlockPos;
import cpw.mods.fml.common.network.simpleimpl.IMessage;
@@ -97,11 +98,11 @@ public class CPacketCraftRequest implements IMessage {
new BlockPos(te),
Objects.requireNonNull(context.getSide()),
GuiType.FLUID_CRAFTING_CONFIRM);
} else {
} else if (target instanceof IWirelessTerminal) {
InventoryHandler.openGui(
player,
player.worldObj,
new BlockPos(player.inventory.currentItem, 0, 0),
new BlockPos(((IWirelessTerminal) target).getInventorySlot(), 0, 0),
Objects.requireNonNull(context.getSide()),
GuiType.FLUID_CRAFTING_CONFIRM_ITEM);
}
@@ -116,6 +116,9 @@ public class CPacketFluidPatternTermBtns implements IMessage {
break;
}
break;
case "PatternTerminal.AutoFillerPattern":
cpt.getPatternTerminal().setAutoFillPattern(Value.equals("1"));
break;
}
cpt.getPatternTerminal().saveSettings();
} else if (Name.equals("Terminal.Cpu") && c instanceof ContainerFluidCraftConfirm) {
@@ -22,6 +22,7 @@ import com.glodblock.github.client.gui.container.ContainerPatternValueAmount;
import com.glodblock.github.common.item.ItemFluidPacket;
import com.glodblock.github.inventory.InventoryHandler;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.inventory.item.IWirelessTerminal;
import com.glodblock.github.util.BlockPos;
import com.glodblock.github.util.Util;
@@ -94,6 +95,7 @@ public class CPacketInventoryAction implements IMessage {
final EntityPlayerMP sender = ctx.getServerHandler().playerEntity;
if (sender.openContainer instanceof AEBaseContainer) {
final AEBaseContainer baseContainer = (AEBaseContainer) sender.openContainer;
Object target = baseContainer.getTarget();
if (message.action == InventoryAction.AUTO_CRAFT) {
final ContainerOpenContext context = baseContainer.getOpenContext();
if (context != null) {
@@ -105,12 +107,12 @@ public class CPacketInventoryAction implements IMessage {
new BlockPos(te),
Objects.requireNonNull(baseContainer.getOpenContext().getSide()),
GuiType.FLUID_CRAFTING_AMOUNT);
} else {
} else if (target instanceof IWirelessTerminal) {
InventoryHandler.openGui(
sender,
sender.worldObj,
new BlockPos(
sender.inventory.currentItem,
((IWirelessTerminal) target).getInventorySlot(),
Util.GuiHelper.encodeType(0, Util.GuiHelper.GuiType.ITEM),
0),
ForgeDirection.UNKNOWN,
@@ -136,12 +138,12 @@ public class CPacketInventoryAction implements IMessage {
new BlockPos(te),
Objects.requireNonNull(baseContainer.getOpenContext().getSide()),
GuiType.PATTERN_VALUE_SET);
} else {
} else if (target instanceof IWirelessTerminal) {
InventoryHandler.openGui(
sender,
sender.worldObj,
new BlockPos(
sender.inventory.currentItem,
((IWirelessTerminal) target).getInventorySlot(),
Util.GuiHelper.encodeType(0, Util.GuiHelper.GuiType.ITEM),
0),
ForgeDirection.UNKNOWN,
@@ -18,6 +18,7 @@ import com.glodblock.github.common.item.ItemFluidPacket;
import com.glodblock.github.inventory.InventoryHandler;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.inventory.gui.PartOrItemGuiFactory;
import com.glodblock.github.inventory.item.IWirelessTerminal;
import com.glodblock.github.util.BlockPos;
import com.glodblock.github.util.Util;
@@ -85,11 +86,11 @@ public class CPacketPatternValueSet implements IMessage {
0),
Objects.requireNonNull(context.getSide()),
message.originGui);
} else {
} else if (target instanceof IWirelessTerminal) {
InventoryHandler.openGui(
player,
player.worldObj,
new BlockPos(player.inventory.currentItem, 0, 0),
new BlockPos(((IWirelessTerminal) target).getInventorySlot(), 0, 0),
Objects.requireNonNull(context.getSide()),
message.originGui);
}
@@ -1,12 +1,23 @@
package com.glodblock.github.network;
import static com.glodblock.github.common.item.ItemWirelessUltraTerminal.getGuis;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.DimensionManager;
import net.minecraftforge.common.util.ForgeDirection;
import appeng.core.sync.GuiBridge;
import appeng.util.Platform;
import appeng.container.AEBaseContainer;
import appeng.helpers.ICustomNameObject;
import appeng.tile.networking.TileCableBus;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.inventory.InventoryHandler;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.inventory.item.IWirelessInterfaceTerminal;
import com.glodblock.github.util.BlockPos;
import com.glodblock.github.util.Util;
import cpw.mods.fml.common.network.simpleimpl.IMessage;
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
@@ -19,10 +30,28 @@ public class CPacketRenamer implements IMessage {
private int z;
private int dim;
private ForgeDirection side;
private Action action;
private String text;
public enum Action {
OPEN,
GET_TEXT,
SET_TEXT,
}
public CPacketRenamer() {}
public CPacketRenamer(String text) {
this.action = Action.SET_TEXT;
this.text = text;
}
public CPacketRenamer(Action a) {
this.action = a;
}
public CPacketRenamer(int x, int y, int z, int dim, ForgeDirection side) {
this.action = Action.OPEN;
this.x = x;
this.y = y;
this.z = z;
@@ -32,31 +61,114 @@ public class CPacketRenamer implements IMessage {
@Override
public void fromBytes(ByteBuf buf) {
this.x = buf.readInt();
this.y = buf.readInt();
this.z = buf.readInt();
this.dim = buf.readInt();
this.side = ForgeDirection.getOrientation(buf.readInt());
this.action = Action.values()[buf.readInt()];
if (this.action == Action.OPEN) {
this.x = buf.readInt();
this.y = buf.readInt();
this.z = buf.readInt();
this.dim = buf.readInt();
this.side = ForgeDirection.getOrientation(buf.readInt());
} else if (this.action == Action.SET_TEXT) {
int leName = buf.readInt();
StringBuilder sb = new StringBuilder();
for (int i = 0; i < leName; i++) {
sb.append(buf.readChar());
}
this.text = sb.toString();
}
}
@Override
public void toBytes(ByteBuf buf) {
buf.writeInt(this.x);
buf.writeInt(this.y);
buf.writeInt(this.z);
buf.writeInt(this.dim);
buf.writeInt(side.ordinal());
buf.writeInt(this.action.ordinal());
if (this.action == Action.OPEN) {
buf.writeInt(this.x);
buf.writeInt(this.y);
buf.writeInt(this.z);
buf.writeInt(this.dim);
buf.writeInt(side.ordinal());
} else if (this.action == Action.SET_TEXT) {
buf.writeInt(this.text.length());
for (int i = 0; i < this.text.length(); i++) {
buf.writeChar(this.text.charAt(i));
}
}
}
public static class Handler implements IMessageHandler<CPacketRenamer, IMessage> {
private String getName(TileEntity tile, ForgeDirection side) {
if (tile instanceof TileCableBus) {
return ((ICustomNameObject) ((TileCableBus) tile).getPart(side)).getCustomName();
} else {
return ((ICustomNameObject) tile).getCustomName();
}
}
private void setName(TileEntity tile, ForgeDirection side, String text) {
if (tile instanceof TileCableBus) {
((ICustomNameObject) ((TileCableBus) tile).getPart(side)).setCustomName(text);
} else {
((ICustomNameObject) tile).setCustomName(text);
}
}
@Override
public IMessage onMessage(CPacketRenamer message, MessageContext ctx) {
EntityPlayerMP player = ctx.getServerHandler().playerEntity;
TileEntity tile = DimensionManager.getWorld(message.dim).getTileEntity(message.x, message.y, message.z);
if (tile != null) {
Platform.openGUI(player, tile, message.side, GuiBridge.GUI_RENAMER);
AEBaseContainer con = (AEBaseContainer) player.openContainer;
TileEntity tile;
if (message.action == Action.OPEN) {
tile = DimensionManager.getWorld(message.dim).getTileEntity(message.x, message.y, message.z);
if (tile != null && con.getTarget() instanceof IWirelessInterfaceTerminal
&& tile instanceof ICustomNameObject) {
String name = getName(tile, message.side);
((IWirelessInterfaceTerminal) con.getTarget()).setClickedInterface(
new Util.DimensionalCoordSide(
message.x,
message.y,
message.z,
message.dim,
message.side,
name));
InventoryHandler.openGui(
player,
player.worldObj,
new BlockPos(
((IWirelessInterfaceTerminal) con.getTarget()).getInventorySlot(),
Util.GuiHelper.encodeType(0, Util.GuiHelper.GuiType.ITEM),
1),
message.side,
GuiType.RENAMER);
}
} else {
if (con.getTarget() instanceof IWirelessInterfaceTerminal) {
Util.DimensionalCoordSide intMsg = ((IWirelessInterfaceTerminal) con.getTarget())
.getClickedInterface();
tile = DimensionManager.getWorld(intMsg.getDimension()).getTileEntity(intMsg.x, intMsg.y, intMsg.z);
if (message.action == Action.GET_TEXT) {
FluidCraft.proxy.netHandler
.sendTo(new SPacketStringUpdate(this.getName(tile, intMsg.getSide())), player);
} else {
this.setName(tile, intMsg.getSide(), message.text);
InventoryHandler.openGui(
player,
player.worldObj,
new BlockPos(
((IWirelessInterfaceTerminal) con.getTarget()).getInventorySlot(),
Util.GuiHelper.encodeType(
getGuis().indexOf(
GuiType.valueOf(
GuiType.WIRELESS_INTERFACE_TERMINAL.toString())),
Util.GuiHelper.GuiType.ITEM),
0),
ForgeDirection.UNKNOWN,
GuiType.WIRELESS_INTERFACE_TERMINAL);
}
}
}
return null;
}
}
@@ -14,6 +14,7 @@ import appeng.container.ContainerOpenContext;
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;
import com.glodblock.github.util.BlockPos;
import com.glodblock.github.util.Util;
@@ -84,12 +85,12 @@ public class CPacketSwitchGuis implements IMessage {
new BlockPos(te),
Objects.requireNonNull(context.getSide()),
message.guiType);
} else {
} else if (((AEBaseContainer) cont).getTarget() instanceof IWirelessTerminal) {
InventoryHandler.openGui(
player,
player.worldObj,
new BlockPos(
player.inventory.currentItem,
((IWirelessTerminal) ((AEBaseContainer) cont).getTarget()).getInventorySlot(),
Util.GuiHelper.encodeType(0, Util.GuiHelper.GuiType.ITEM),
0),
Objects.requireNonNull(context.getSide()),
@@ -135,10 +135,12 @@ public class CPacketTransferRecipe implements IMessage {
IAEItemStack iaeItemStack = AEApi.instance().storage().createItemStack(is);
if (storageList.findPrecise(iaeItemStack) == null) {
for (IAEItemStack tmp : storageList.findFuzzy(iaeItemStack, FuzzyMode.IGNORE_ALL)) {
ItemStack substitute = tmp.getItemStack().copy();
substitute.stackSize = is.stackSize;
stack.putStack(substitute);
break;
if (iaeItemStack.sameOre(tmp)) {
ItemStack substitute = tmp.getItemStack().copy();
substitute.stackSize = is.stackSize;
stack.putStack(substitute);
break;
}
}
}
}
@@ -0,0 +1,61 @@
package com.glodblock.github.network;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiScreen;
import com.glodblock.github.client.gui.*;
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 SPacketStringUpdate implements IMessage {
private String text;
private int slot;
public SPacketStringUpdate() {}
public SPacketStringUpdate(String text, int slot) {
this.text = text;
this.slot = slot;
}
public SPacketStringUpdate(String text) {
this.text = text;
this.slot = 0;
}
@Override
public void fromBytes(ByteBuf buf) {
this.slot = buf.readInt();
int leName = buf.readInt();
StringBuilder sb = new StringBuilder();
for (int i = 0; i < leName; i++) {
sb.append(buf.readChar());
}
this.text = sb.toString();
}
@Override
public void toBytes(ByteBuf buf) {
buf.writeInt(this.slot);
buf.writeInt(this.text.length());
for (int i = 0; i < this.text.length(); i++) {
buf.writeChar(this.text.charAt(i));
}
}
public static class Handler implements IMessageHandler<SPacketStringUpdate, IMessage> {
@Override
public IMessage onMessage(SPacketStringUpdate message, MessageContext ctx) {
final GuiScreen gs = Minecraft.getMinecraft().currentScreen;
if (gs instanceof GuiRenamer) {
((GuiRenamer) gs).postUpdate(message.text);
}
return null;
}
}
}
@@ -1,5 +1,6 @@
package com.glodblock.github.proxy;
import com.glodblock.github.loader.KeybindLoader;
import com.glodblock.github.loader.ListenerLoader;
import com.glodblock.github.loader.RenderLoader;
import com.glodblock.github.nei.recipes.DefaultExtractorLoader;
@@ -21,6 +22,7 @@ public class ClientProxy extends CommonProxy {
super.init(event);
(new ListenerLoader()).run();
(new RenderLoader()).run();
(new KeybindLoader()).run();
}
@Override
@@ -16,7 +16,9 @@ import appeng.api.storage.data.IAEItemStack;
import appeng.container.implementations.ContainerUpgradeable;
import appeng.container.implementations.CraftingCPURecord;
import appeng.crafting.MECraftingInventory;
import appeng.helpers.DualityInterface;
import appeng.me.cluster.implementations.CraftingCPUCluster;
import appeng.me.helpers.AENetworkProxy;
import appeng.me.storage.MEInventoryHandler;
import appeng.me.storage.MEPassThrough;
import appeng.parts.p2p.PartP2PLiquids;
@@ -35,6 +37,7 @@ public class Ae2Reflect {
private static final Field fCPU_inventory;
private static final Field fCPU_machineSrc;
private static final Field fContainerUpgradeable_upgradeable;
private static final Field fDualInterface_gridProxy;
private static final Method mItemSlot_setExtractable;
private static final Method mCPU_getGrid;
private static final Method mCPU_postChange;
@@ -54,6 +57,7 @@ public class Ae2Reflect {
fCPU_machineSrc = Ae2Reflect.reflectField(CraftingCPUCluster.class, "machineSrc");
fContainerUpgradeable_upgradeable = Ae2Reflect.reflectField(ContainerUpgradeable.class, "upgradeable");
mItemSlot_setExtractable = reflectMethod(ItemSlot.class, "setExtractable", boolean.class);
fDualInterface_gridProxy = reflectField(DualityInterface.class, "gridProxy");
mCPU_getGrid = reflectMethod(CraftingCPUCluster.class, "getGrid");
mCPU_postChange = reflectMethod(
CraftingCPUCluster.class,
@@ -164,6 +168,10 @@ public class Ae2Reflect {
return Ae2Reflect.readField(owner, fContainerUpgradeable_upgradeable);
}
public static AENetworkProxy getInterfaceProxy(DualityInterface owner) {
return Ae2Reflect.readField(owner, fDualInterface_gridProxy);
}
public static void postCPUChange(CraftingCPUCluster cpu, IAEItemStack stack, MachineSource src) {
try {
mCPU_postChange.invoke(cpu, stack, src);
@@ -40,6 +40,10 @@ public class BlockPos {
return new BlockPos(this.x + face.offsetX, this.y + face.offsetY, this.z + face.offsetZ, this.w);
}
public BlockPos getOffSet(int x, int y, int z) {
return new BlockPos(this.x + x, this.y + y, this.z + z, this.w);
}
public TileEntity getTileEntity() {
if (w != null) {
return w.getTileEntity(x, y, z);
@@ -25,6 +25,7 @@ public final class ModAndClassUtil {
public static boolean COFH = false;
public static boolean GTPP = false;
public static boolean WAILA = false;
public static boolean AVARITIA = false;
public static boolean isV2;
public static boolean isDoubleButton;
public static boolean isSaveText;
@@ -130,5 +131,6 @@ public final class ModAndClassUtil {
if (Loader.isModLoaded("CoFHCore")) COFH = true;
if (Loader.isModLoaded("miscutils")) GTPP = true;
if (Loader.isModLoaded("Waila")) WAILA = true;
if (Loader.isModLoaded("Avaritia")) AVARITIA = true;
}
}
@@ -35,6 +35,9 @@ public class NameConst {
public static final String ITEM_PART_FLUID_LEVEL_EMITTER = "part_fluid_level_emitter";
public static final String ITEM_FLUID_PACKET = "fluid_packet";
public static final String ITEM_FLUID_STORAGE = "fluid_storage";
public static final String ITEM_MULTI_FLUID_STORAGE = "multi_fluid_storage";
public static final String ITEM_QUANTUM_FLUID_STORAGE = ITEM_FLUID_STORAGE + ".quantum";
public static final String ITEM_SINGULARITY_FLUID_STORAGE = ITEM_FLUID_STORAGE + ".singularity";
public static final String ITEM_CREATIVE_FLUID_STORAGE = "creative_" + ITEM_FLUID_STORAGE;
public static final String ITEM_FLUID_PORTABLE_CELL = "portable_fluid_cell";
public static final String ITEM_WIRELESS_FLUID_TERMINAL = "wireless_fluid_terminal";
@@ -42,6 +45,7 @@ public class NameConst {
public static final String ITEM_WIRELESS_ULTRA_TERMINAL = "wireless_ultra_terminal";
public static final String ITEM_WIRELESS_FLUID_PATTERN_TERMINAL = "wireless_fluid_pattern_terminal";
public static final String ITEM_FLUID_PART = "fluid_part";
public static final String ITEM_FLUID_STORAGE_HOUSING = "fluid_storage_housing";
public static final String TT_KEY = FluidCraft.MODID + ".tooltip.";
public static final String TT_FLUID_TERMINAL = TT_KEY + "fluid_terminal";
@@ -81,6 +85,8 @@ public class NameConst {
public static final String TT_WIRELESS_INSTALLED = TT_WIRELESS + "installed";
public static final String TT_FLUID_AUTO_FILLER = TT_KEY + "fluid_auto_filler";
public static final String TT_ULTRA_TERMINAL = TT_KEY + "ultra_terminal";
public static final String TT_ULTRA_TERMINAL_TIPS = TT_ULTRA_TERMINAL + ".tips";
public static final String TT_ULTRA_TERMINAL_TIPS_DESC = TT_ULTRA_TERMINAL_TIPS + ".desc";
public static final String WAILA_KEY = FluidCraft.MODID + ".waila.";
public static final String WAILA_ENABLE = WAILA_KEY + "enable";
+150 -32
View File
@@ -3,6 +3,8 @@ package com.glodblock.github.util;
import static com.glodblock.github.common.item.ItemBaseWirelessTerminal.infinityBoosterCard;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import net.minecraft.entity.player.EntityPlayer;
@@ -16,7 +18,6 @@ import net.minecraftforge.fluids.*;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.apache.commons.lang3.tuple.MutablePair;
import org.lwjgl.input.Mouse;
import appeng.api.AEApi;
import appeng.api.config.Actionable;
@@ -27,23 +28,26 @@ import appeng.api.networking.IGrid;
import appeng.api.networking.IGridHost;
import appeng.api.networking.IGridNode;
import appeng.api.networking.security.ISecurityGrid;
import appeng.api.networking.storage.IBaseMonitor;
import appeng.api.networking.storage.IStorageGrid;
import appeng.api.parts.IPart;
import appeng.api.storage.IMEInventoryHandler;
import appeng.api.storage.StorageChannel;
import appeng.api.storage.data.IAEFluidStack;
import appeng.api.storage.data.IAEStack;
import appeng.api.util.DimensionalCoord;
import appeng.api.util.WorldCoord;
import appeng.container.AEBaseContainer;
import appeng.items.tools.powered.ToolWirelessTerminal;
import appeng.me.storage.NullInventory;
import appeng.tile.networking.TileCableBus;
import appeng.tile.networking.TileWireless;
import appeng.util.Platform;
import appeng.util.item.AEFluidStack;
import baubles.api.BaublesApi;
import com.glodblock.github.common.item.ItemBaseWirelessTerminal;
import com.glodblock.github.common.item.ItemFluidDrop;
import com.glodblock.github.common.item.ItemFluidPacket;
import com.glodblock.github.common.item.ItemWirelessUltraTerminal;
import com.glodblock.github.inventory.IAEFluidTank;
import com.glodblock.github.inventory.item.IFluidPortableCell;
@@ -53,39 +57,30 @@ import io.netty.buffer.ByteBuf;
public final class Util {
public static class MouseHandler {
private static int mouse_x = 0;
private static int mouse_y = 0;
public static void saveMousePos() {
mouse_x = Mouse.getX();
mouse_y = Mouse.getY();
}
public static void loadMousePos() {
if (mouse_x != 0 && mouse_y != 0) {
Mouse.setCursorPosition(mouse_x, mouse_y);
mouse_y = 0;
mouse_x = 0;
}
}
}
public static int drainItemPower(AEBaseContainer c, InventoryPlayer ip, int slot, int ticks, double pm,
IFluidPortableCell wt) {
final ItemStack currentItem = slot < 0 ? ip.getCurrentItem() : ip.getStackInSlot(slot);
if (wt != null) {
if (currentItem != wt.getItemStack()) {
if (currentItem != null) {
if (Platform.isSameItem(wt.getItemStack(), currentItem)) {
ip.setInventorySlotContents(ip.currentItem, wt.getItemStack());
if (slot != -1) {
final ItemStack currentItem = getWirelessTerminal(ip.player, slot);
if (wt != null) {
if (currentItem != wt.getItemStack()) {
if (currentItem != null) {
if (Platform.isSameItem(wt.getItemStack(), currentItem)) {
if (GuiHelper.decodeInvType(slot).getLeft() == GuiHelper.InvType.PLAYER_INV) {
ip.setInventorySlotContents(slot, wt.getItemStack());
} else {
BaublesApi.getBaubles(ip.player).setInventorySlotContents(
GuiHelper.decodeInvType(slot).getRight(),
wt.getItemStack());
}
} else {
c.setValidContainer(false);
}
} else {
c.setValidContainer(false);
}
} else {
c.setValidContainer(false);
}
} else {
c.setValidContainer(false);
}
} else {
c.setValidContainer(false);
@@ -117,8 +112,8 @@ public final class Util {
return null;
}
public static IBaseMonitor<? extends IAEStack<? extends IAEStack<?>>> getWirelessInv(ItemStack is,
EntityPlayer player, StorageChannel channel) {
public static IMEInventoryHandler<?> getWirelessInv(ItemStack is, EntityPlayer player, StorageChannel channel) {
if (Platform.isClient()) return new NullInventory<>();
IGridNode gridNode = getWirelessGrid(is);
if (gridNode == null) return null;
IGrid grid = gridNode.getGrid();
@@ -153,6 +148,40 @@ public final class Util {
return null;
}
public static ItemStack getWirelessTerminal(EntityPlayer player, int x) {
ImmutablePair<GuiHelper.InvType, Integer> result = GuiHelper.decodeInvType(x);
if (result.getLeft() == GuiHelper.InvType.PLAYER_INV) {
return player.inventory.getStackInSlot(result.getRight());
} else {
return BaublesApi.getBaubles(player).getStackInSlot(result.getRight());
}
}
public static ImmutablePair<Integer, ItemStack> getUltraWirelessTerm(EntityPlayer player) {
int invSize = player.inventory.getSizeInventory();
if (invSize <= 0) {
return null;
}
for (int i = 0; i < invSize; ++i) {
ItemStack is = player.inventory.getStackInSlot(i);
if (is != null && is.getItem() instanceof ItemWirelessUltraTerminal) {
return new ImmutablePair<>(i, is);
}
}
IInventory handler = BaublesApi.getBaubles(player);
if (handler != null) {
invSize = handler.getSizeInventory();
for (int i = 0; i < invSize; ++i) {
ItemStack is = handler.getStackInSlot(i);
if (is != null && is.getItem() instanceof ItemWirelessUltraTerminal) {
return new ImmutablePair<>(GuiHelper.encodeType(i, GuiHelper.InvType.PLAYER_BAUBLES), is);
}
}
}
return null;
}
public static int findItemInPlayerInvSlot(EntityPlayer player, ItemStack itemStack) {
for (int i = 0; i < player.inventory.mainInventory.length; i++) {
if (player.inventory.mainInventory[i] != null && player.inventory.mainInventory[i] == itemStack) return i;
@@ -344,6 +373,11 @@ public final class Util {
ITEM
}
public enum InvType {
PLAYER_INV,
PLAYER_BAUBLES
}
private static final int value = 1 << 30;
public static int encodeType(int y, GuiType type) {
@@ -353,6 +387,13 @@ public final class Util {
return value | (type.ordinal() << 29) | y;
}
public static int encodeType(int x, InvType type) {
if (Math.abs(x) > (1 << 28)) {
throw new IllegalArgumentException("out of range");
}
return value | (type.ordinal() << 29) | x;
}
public static ImmutablePair<GuiType, Integer> decodeType(int y) {
if (Math.abs(y) > (1 << 28)) {
return new ImmutablePair<>(GuiType.values()[y >> 29 & 1], y - (3 << 29 & y));
@@ -360,6 +401,14 @@ public final class Util {
return new ImmutablePair<>(GuiType.TILE, y);
}
}
public static ImmutablePair<InvType, Integer> decodeInvType(int x) {
if (Math.abs(x) > (1 << 28)) {
return new ImmutablePair<>(InvType.values()[x >> 29 & 1], x - (3 << 29 & x));
} else {
return new ImmutablePair<>(InvType.PLAYER_INV, x);
}
}
}
public static int clamp(int value, int min, int max) {
@@ -368,6 +417,36 @@ public final class Util {
public static class FluidUtil {
public static void fluidTankInfoWriteToNBT(FluidTankInfo[] infos, NBTTagCompound data) {
int i = 0;
for (FluidTankInfo info : infos) {
if (info.fluid != null && info.fluid.amount > 0) {
NBTTagCompound fs = new NBTTagCompound();
info.fluid.writeToNBT(fs);
fs.setInteger("capacity", info.capacity);
data.setTag("#" + i, fs);
}
i++;
}
data.setInteger("fluidInvSize", i);
}
public static FluidTankInfo[] fluidTankInfoReadFromNBT(NBTTagCompound data) {
int i = 0;
List<FluidTankInfo> infos = new ArrayList<>();
while (data.hasKey("fluidInvSize") && i < data.getInteger("fluidInvSize")) {
if (data.hasKey("#" + i)) {
NBTTagCompound tag = (NBTTagCompound) data.getTag("#" + i);
FluidStack fs = FluidStack.loadFluidStackFromNBT(tag);
infos.add(new FluidTankInfo(fs, tag.getInteger("capacity")));
} else {
infos.add(new FluidTankInfo(null, 0));
}
i++;
}
return infos.toArray(new FluidTankInfo[0]);
}
public static IAEFluidStack createAEFluidStack(Fluid fluid) {
return createAEFluidStack(new FluidStack(fluid, FluidContainerRegistry.BUCKET_VOLUME));
}
@@ -508,4 +587,43 @@ public final class Util {
return null;
}
}
public static class DimensionalCoordSide extends DimensionalCoord {
private ForgeDirection side = ForgeDirection.UNKNOWN;
private final String name;
public DimensionalCoordSide(final int _x, final int _y, final int _z, final int _dim, ForgeDirection side,
String name) {
super(_x, _y, _z, _dim);
this.side = side;
this.name = name;
}
public String getName() {
return name;
}
public ForgeDirection getSide() {
return this.side;
}
@Override
public void writeToNBT(NBTTagCompound data) {
data.setInteger("side", this.side.ordinal());
data.setString("name", this.name);
super.writeToNBT(data);
}
public static DimensionalCoordSide readFromNBT(final NBTTagCompound data) {
return new DimensionalCoordSide(
data.getInteger("x"),
data.getInteger("y"),
data.getInteger("z"),
data.getInteger("dim"),
ForgeDirection.getOrientation(data.getInteger("side")),
data.getString("name"));
}
}
}
@@ -30,8 +30,16 @@ item.fluid_storage.256.name=%s256k%s ME Fluid Storage Cell
item.fluid_storage.1024.name=%s1024k%s ME Fluid Storage Cell
item.fluid_storage.4096.name=%s4096k%s ME Fluid Storage Cell
item.fluid_storage.16384.name=%s16384k%s ME Fluid Storage Cell
item.fluid_storage.131072.name=%s131072k%s ME Fluid Quantum Storage Cell
item.fluid_storage.554160890921312.name=%s554P%s ME Fluid Digital Singularity Storage Cell
item.multi_fluid_storage.1.name=%s1k%s ME Multi-Fluid Storage Cell
item.multi_fluid_storage.4.name=%s4k%s ME Multi-Fluid Storage Cell
item.multi_fluid_storage.16.name=%s16k%s ME Multi-Fluid Storage Cell
item.multi_fluid_storage.64.name=%s64k%s ME Multi-Fluid Storage Cell
item.multi_fluid_storage.256.name=%s256k%s ME Multi-Fluid Storage Cell
item.multi_fluid_storage.1024.name=%s1024k%s ME Multi-Fluid Storage Cell
item.multi_fluid_storage.4096.name=%s4096k%s ME Multi-Fluid Storage Cell
item.multi_fluid_storage.16384.name=%s16384k%s ME Multi-Fluid Storage Cell
item.fluid_storage.quantum.name=ME Fluid Quantum Storage Cell
item.fluid_storage.singularity.name=ME Fluid Digital Singularity Storage Cell
item.fluid_part.0.name=%s1k%s ME Fluid Storage Component
item.fluid_part.1.name=%s4k%s ME Fluid Storage Component
item.fluid_part.2.name=%s16k%s ME Fluid Storage Component
@@ -40,6 +48,10 @@ item.fluid_part.4.name=%s256k%s ME Fluid Storage Component
item.fluid_part.5.name=%s1024k%s ME Fluid Storage Component
item.fluid_part.6.name=%s4096k%s ME Fluid Storage Component
item.fluid_part.7.name=%s16384k%s ME Fluid Storage Component
item.fluid_storage_housing.0.name=ME Fluid Storage Housing
item.fluid_storage_housing.1.name=ME Advanced Fluid Storage Housing
item.fluid_storage_housing.2.name=ME Multi-Fluid Storage Housing
item.fluid_storage_housing.3.name=ME Advanced Multi-Fluid Storage Housing
tile.fluid_discretizer.name=Fluid Discretizer
tile.fluid_pattern_encoder.name=Fluid Pattern Encoder
@@ -52,7 +64,8 @@ tile.level_maintainer.name=ME Level Maintainer
tile.fluid_buffer.name=ME Fluid Buffer
tile.walrus.name=Walrus
tile.fluid_auto_filler.name=ME Fluid Auto Filler
tile.certus_quartz_tank.name=Certus Quartz Tank
tile.certus_quartz_tank.name=Certus Quartz Tank - %s
tile.certus_quartz_tank_empty.name=Certus Quartz Tank
ae2fc.waila.speed=Speed
ae2fc.waila.enable=Enable
@@ -87,6 +100,8 @@ ae2fc.tooltip.ultra_terminal.WIRELESS_ESSENTIA_TERMINAL=Mode: Essentia Terminal
ae2fc.tooltip.ultra_terminal.WIRELESS_INTERFACE_TERMINAL=Mode: Interface Terminal
ae2fc.tooltip.ultra_terminal.WIRELESS_FLUID_PATTERN_TERMINAL_EX=Mode: Processing Pattern Terminal
ae2fc.tooltip.ultra_terminal=Right click + sneaking to switch mode.
ae2fc.tooltip.ultra_terminal.tips=ToolTips:
ae2fc.tooltip.ultra_terminal.tips.desc=1.You can put it to baubles slot and use hotkey to open.\n2.Interface mode hold §3Shift§7 toggle interface renamer button.\n3.When you are in the crafting plan screen.\nHold §3Shift§7 click cancel button will automatically add missing items to NEI bookmark.
ae2fc.tooltip.cell_contents=Contains Fluid:
ae2fc.tooltip.cell_empty=Cell is empty
@@ -118,6 +133,10 @@ ae2fc.tooltip.submit=Submit
ae2fc.tooltip.enable=Enabled
ae2fc.tooltip.disable=Disabled
ae2fc.tooltip.edit=Edit
ae2fc.tooltip.fill_pattern=Allow auto fill blank pattern
ae2fc.tooltip.not_fill_pattern=Allow auto fill blank pattern
ae2fc.tooltip.fill_pattern.hint=Enabled
ae2fc.tooltip.not_fill_pattern.hint=Disabled
ae2fc.gui.part_fluid_pattern_terminal=Fluid Pattern Terminal
ae2fc.gui.part_fluid_pattern_terminal_ex=Fluid Processing Pattern Terminal
@@ -144,4 +163,6 @@ ae2fc.gui.fluid_auto_filler=ME Fluid Auto Filler
error.unknown=Unknown
key.OpenTerminal=Open Wireless Universal Terminal
itemGroup.ae2fc=Fluid Craft For AE2
@@ -30,8 +30,16 @@ item.fluid_storage.256.name=%s256k%s-ME流体存储元件
item.fluid_storage.1024.name=%s1024k%s-ME流体存储元件
item.fluid_storage.4096.name=%s4096k%s-ME流体存储元件
item.fluid_storage.16384.name=%s16384k%s-ME流体存储元件
item.fluid_storage.131072.name=%s131072k%s ME流体量子存储元件
item.fluid_storage.554160890921312.name=%s554P%s MEl流体数字奇点元件
item.multi_fluid_storage.1.name=%s1k%s-ME多重流体存储元件
item.multi_fluid_storage.4.name=%s4k%s-ME多重流体存储元件
item.multi_fluid_storage.16.name=%s16k%s-ME多重流体存储元件
item.multi_fluid_storage.64.name=%s64k%s-ME多重流体存储元件
item.multi_fluid_storage.256.name=%s256k%s-ME多重流体存储元件
item.multi_fluid_storage.1024.name=%s1024k%s-ME多重流体存储元件
item.multi_fluid_storage.4096.name=%s4096k%s-ME多重流体存储元件
item.multi_fluid_storage.16384.name=%s16384k%s-ME多重流体存储元件
item.fluid_storage.quantum.name=ME流体量子存储元件
item.fluid_storage.singularity.name=ME流体数字奇点元件
item.fluid_part.0.name=%s1k%s-ME流体存储组件
item.fluid_part.1.name=%s4k%s-ME流体存储组件
item.fluid_part.2.name=%s16k%s-ME流体存储组件
@@ -40,6 +48,10 @@ item.fluid_part.4.name=%s256k%s-ME流体存储组件
item.fluid_part.5.name=%s1024k%s-ME流体存储组件
item.fluid_part.6.name=%s4096k%s-ME流体存储组件
item.fluid_part.7.name=%s16384k%s-ME流体存储组件
item.fluid_storage_housing.0.name=ME流体存储外壳
item.fluid_storage_housing.1.name=ME流体高级存储外壳
item.fluid_storage_housing.2.name=ME多重流体存储外壳
item.fluid_storage_housing.3.name=ME多重流体高级存储外壳
tile.fluid_discretizer.name=ME流体离散器
tile.fluid_pattern_encoder.name=流体适配型样板编码台
@@ -52,7 +64,8 @@ tile.level_maintainer.name=ME库存维持器
tile.fluid_buffer.name=ME流体缓存器
tile.walrus.name=海象
tile.fluid_auto_filler.name=ME流体自动装填器
tile.certus_quartz_tank.name=赛特斯石英水槽
tile.certus_quartz_tank.name=赛特斯石英水槽 - %s
tile.certus_quartz_tank_empty.name=赛特斯石英水槽
ae2fc.waila.speed=速度
ae2fc.waila.enable=启用
@@ -87,6 +100,8 @@ ae2fc.tooltip.ultra_terminal.WIRELESS_ESSENTIA_TERMINAL=模式: 源质
ae2fc.tooltip.ultra_terminal.WIRELESS_INTERFACE_TERMINAL=模式: 接口
ae2fc.tooltip.ultra_terminal.WIRELESS_FLUID_PATTERN_TERMINAL_EX=模式: 增广样板
ae2fc.tooltip.ultra_terminal=Shift右击切换模式。
ae2fc.tooltip.ultra_terminal.tips=使用提示:
ae2fc.tooltip.ultra_terminal.tips.desc=1.你可以把它放到饰品栏内并用热键打开.\n2.接口模式按§3Shift§7切换出接口命名按钮.\n3.当你在合成计划界面时.\n按§3Shift§7点击取消按钮会自动添加合成缺失的物品到NEI收藏栏.
ae2fc.tooltip.cell_contents=内含流体:
ae2fc.tooltip.cell_empty=空存储
@@ -118,6 +133,10 @@ ae2fc.tooltip.submit=提交
ae2fc.tooltip.enable=启用
ae2fc.tooltip.disable=禁用
ae2fc.tooltip.edit=编辑
ae2fc.tooltip.fill_pattern=允许自动填充空白样板
ae2fc.tooltip.not_fill_pattern=允许自动填充空白样板
ae2fc.tooltip.fill_pattern.hint=启用
ae2fc.tooltip.not_fill_pattern.hint=禁用
ae2fc.gui.part_fluid_pattern_terminal=ME流体样板终端
ae2fc.gui.part_fluid_pattern_terminal_ex=ME增广流体样板终端
@@ -144,7 +163,8 @@ ae2fc.gui.fluid_auto_filler=ME流体自动装填器
error.unknown=未知流体
key.OpenTerminal=打开无线通用终端
itemGroup.ae2fc=AE2流体合成套件重置
Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 486 B

After

Width:  |  Height:  |  Size: 480 B

File renamed without changes.

Before

Width:  |  Height:  |  Size: 605 B

After

Width:  |  Height:  |  Size: 605 B

File renamed without changes.

Before

Width:  |  Height:  |  Size: 641 B

After

Width:  |  Height:  |  Size: 641 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 337 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 358 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 348 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 344 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 448 B

Loaded 100 of 104 files, more files were not shown because too many files have changed in this diff. Show more