Compare commits

...
52 Commits
Author SHA1 Message Date
asdflj 399c5f53dd craft confirm screen add cpu select support (#99)
* craft confirm screen add cpu select support

* fix bug
2023-03-13 12:58:20 +08:00
asdfljandRaven Szewczyk b9724d9369 fc terminal add type filter (#98)
* fc terminal add type filter

* Update dependencies.gradle

---------

Co-authored-by: Raven Szewczyk <[email protected]>
2023-03-12 20:25:42 +01:00
Yang Xizhi c92f8bdd7c Merge pull request #103 from asdflj/recipe
fix fc pattern terminal shift click will use not support item to fill slot
2023-03-07 12:41:05 +08:00
asdflj ab7769a45d add default method 2023-03-06 18:35:54 +08:00
asdflj d2c03bc903 fix fc pattern terminal shift click will use not support item to fill slot 2023-03-06 15:54:33 +08:00
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
78 changed files with 1981 additions and 1311 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-176-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')
}
@@ -13,6 +13,7 @@ import com.glodblock.github.loader.CalculatorV2PluginLoader;
import com.glodblock.github.loader.ChannelLoader;
import com.glodblock.github.loader.ItemAndBlockHolder;
import com.glodblock.github.loader.RecipeLoader;
import com.glodblock.github.loader.filter.FluidFilter;
import com.glodblock.github.proxy.CommonProxy;
import com.glodblock.github.util.ModAndClassUtil;
@@ -28,7 +29,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";
@@ -77,6 +78,9 @@ public class FluidCraft {
if (ModAndClassUtil.isV2) {
CalculatorV2PluginLoader.installCalculatorV2Plugins();
}
if (ModAndClassUtil.isTypeFilter) {
FluidFilter.installFilter();
}
proxy.postInit(event);
}
@@ -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");
}
}
@@ -1,68 +1,27 @@
package com.glodblock.github.client.gui;
import java.text.NumberFormat;
import java.util.*;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
import org.lwjgl.input.Mouse;
import org.lwjgl.opengl.GL11;
import appeng.api.AEApi;
import appeng.api.storage.ITerminalHost;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IItemList;
import appeng.client.gui.AEBaseGui;
import appeng.client.gui.widgets.GuiScrollbar;
import appeng.core.AELog;
import appeng.core.localization.GuiText;
import appeng.integration.modules.NEI;
import appeng.util.Platform;
import appeng.client.gui.implementations.GuiCraftConfirm;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.container.ContainerFluidCraftConfirm;
import com.glodblock.github.common.item.ItemWirelessUltraTerminal;
import com.glodblock.github.common.parts.PartFluidPatternTerminal;
import com.glodblock.github.common.parts.PartFluidPatternTerminalEx;
import com.glodblock.github.coremod.hooker.CoreModHooks;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.inventory.item.IWirelessTerminal;
import com.glodblock.github.inventory.item.WirelessPatternTerminalInventory;
import com.glodblock.github.network.CPacketFluidPatternTermBtns;
import com.glodblock.github.network.CPacketSwitchGuis;
import com.glodblock.github.util.ModAndClassUtil;
import com.google.common.base.Joiner;
public class GuiFluidCraftConfirm extends AEBaseGui {
private final ContainerFluidCraftConfirm ccc;
private final int rows = 5;
private final IItemList<IAEItemStack> storage = AEApi.instance().storage().createItemList();
private final IItemList<IAEItemStack> pending = AEApi.instance().storage().createItemList();
private final IItemList<IAEItemStack> missing = AEApi.instance().storage().createItemList();
private final List<IAEItemStack> visual = new ArrayList<IAEItemStack>();
public class GuiFluidCraftConfirm extends GuiCraftConfirm {
private GuiType OriginalGui;
private GuiButton cancel;
private GuiButton start;
private GuiButton selectCPU;
private int tooltip = -1;
private ItemStack hoveredStack;
public GuiFluidCraftConfirm(final InventoryPlayer inventoryPlayer, final ITerminalHost te) {
super(new ContainerFluidCraftConfirm(inventoryPlayer, te));
this.xSize = 238;
this.ySize = 206;
final GuiScrollbar scrollbar = new GuiScrollbar();
this.setScrollBar(scrollbar);
this.ccc = (ContainerFluidCraftConfirm) this.inventorySlots;
super(inventoryPlayer, te);
if (te instanceof PartFluidPatternTerminal) {
this.OriginalGui = GuiType.FLUID_PATTERN_TERMINAL;
} else if (te instanceof PartFluidPatternTerminalEx) {
@@ -74,483 +33,8 @@ public class GuiFluidCraftConfirm extends AEBaseGui {
}
}
boolean isAutoStart() {
return ((ContainerFluidCraftConfirm) this.inventorySlots).isAutoStart();
}
@Override
public void initGui() {
super.initGui();
this.start = new GuiButton(
0,
this.guiLeft + 162,
this.guiTop + this.ySize - 25,
50,
20,
GuiText.Start.getLocal());
this.start.enabled = false;
this.buttonList.add(this.start);
this.selectCPU = new GuiButton(
0,
this.guiLeft + (219 - 180) / 2,
this.guiTop + this.ySize - 68,
180,
20,
GuiText.CraftingCPU.getLocal() + ": " + GuiText.Automatic);
this.selectCPU.enabled = false;
this.buttonList.add(this.selectCPU);
if (this.OriginalGui != null) {
this.cancel = new GuiButton(
0,
this.guiLeft + 6,
this.guiTop + this.ySize - 25,
50,
20,
GuiText.Cancel.getLocal());
}
this.buttonList.add(this.cancel);
}
@Override
public void drawScreen(final int mouseX, final int mouseY, final float btn) {
this.updateCPUButtonText();
this.start.enabled = !(this.ccc.hasNoCPU() || this.isSimulation());
this.selectCPU.enabled = !this.isSimulation();
final int gx = (this.width - this.xSize) / 2;
final int gy = (this.height - this.ySize) / 2;
this.tooltip = -1;
final int offY = 23;
int y = 0;
int x = 0;
for (int z = 0; z <= 4 * 5; z++) {
final int minX = gx + 9 + x * 67;
final int minY = gy + 22 + y * offY;
if (minX < mouseX && minX + 67 > mouseX) {
if (minY < mouseY && minY + offY - 2 > mouseY) {
this.tooltip = z;
break;
}
}
x++;
if (x > 2) {
y++;
x = 0;
}
}
super.drawScreen(mouseX, mouseY, btn);
}
private void updateCPUButtonText() {
String btnTextText = GuiText.CraftingCPU.getLocal() + ": " + GuiText.Automatic.getLocal();
if (this.ccc.getSelectedCpu() >= 0) // && status.selectedCpu < status.cpus.size() )
{
if (this.ccc.getName().length() > 0) {
final String name = this.ccc.getName().substring(0, Math.min(20, this.ccc.getName().length()));
btnTextText = GuiText.CraftingCPU.getLocal() + ": " + name;
} else {
btnTextText = GuiText.CraftingCPU.getLocal() + ": #" + this.ccc.getSelectedCpu();
}
}
if (this.ccc.hasNoCPU()) {
btnTextText = GuiText.NoCraftingCPUs.getLocal();
}
this.selectCPU.displayString = btnTextText;
}
private boolean isSimulation() {
return ((ContainerFluidCraftConfirm) this.inventorySlots).isSimulation();
}
@Override
public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
final long BytesUsed = this.ccc.getUsedBytes();
final String byteUsed = NumberFormat.getInstance().format(BytesUsed);
final String Add = BytesUsed > 0 ? (byteUsed + ' ' + GuiText.BytesUsed.getLocal())
: GuiText.CalculatingWait.getLocal();
this.fontRendererObj.drawString(GuiText.CraftingPlan.getLocal() + " - " + Add, 8, 7, 4210752);
String dsp = null;
if (this.isSimulation()) {
dsp = GuiText.Simulation.getLocal();
} else {
dsp = this.ccc.getCpuAvailableBytes() > 0
? (GuiText.Bytes.getLocal() + ": "
+ this.ccc.getCpuAvailableBytes()
+ " : "
+ GuiText.CoProcessors.getLocal()
+ ": "
+ this.ccc.getCpuCoProcessors())
: GuiText.Bytes.getLocal() + ": N/A : " + GuiText.CoProcessors.getLocal() + ": N/A";
}
final int offset = (219 - this.fontRendererObj.getStringWidth(dsp)) / 2;
this.fontRendererObj.drawString(dsp, offset, 165, 4210752);
final int sectionLength = 67;
int x = 0;
int y = 0;
final int xo = 9;
final int yo = 22;
final int viewStart = this.getScrollBar().getCurrentScroll() * 3;
final int viewEnd = viewStart + 3 * this.rows;
String dspToolTip = "";
final List<String> lineList = new LinkedList<String>();
int toolPosX = 0;
int toolPosY = 0;
hoveredStack = null;
final int offY = 23;
for (int z = viewStart; z < Math.min(viewEnd, this.visual.size()); z++) {
final IAEItemStack refStack = this.visual.get(z); // repo.getReferenceItem( z );
if (refStack != null) {
GL11.glPushMatrix();
GL11.glScaled(0.5, 0.5, 0.5);
final IAEItemStack stored = this.storage.findPrecise(refStack);
final IAEItemStack pendingStack = this.pending.findPrecise(refStack);
final IAEItemStack missingStack = this.missing.findPrecise(refStack);
int lines = 0;
if (stored != null && stored.getStackSize() > 0) {
lines++;
}
if (pendingStack != null && pendingStack.getStackSize() > 0) {
lines++;
}
if (pendingStack != null && pendingStack.getStackSize() > 0) {
lines++;
}
final int negY = ((lines - 1) * 5) / 2;
int downY = 0;
if (stored != null && stored.getStackSize() > 0) {
String str = Long.toString(stored.getStackSize());
if (stored.getStackSize() >= 10000) {
str = Long.toString(stored.getStackSize() / 1000) + 'k';
}
if (stored.getStackSize() >= 10000000) {
str = Long.toString(stored.getStackSize() / 1000000) + 'm';
}
str = GuiText.FromStorage.getLocal() + ": " + str;
final int w = 4 + this.fontRendererObj.getStringWidth(str);
this.fontRendererObj.drawString(
str,
(int) ((x * (1 + sectionLength) + xo + sectionLength - 19 - (w * 0.5)) * 2),
(y * offY + yo + 6 - negY + downY) * 2,
4210752);
if (this.tooltip == z - viewStart) {
lineList.add(GuiText.FromStorage.getLocal() + ": " + stored.getStackSize());
}
downY += 5;
}
boolean red = false;
if (missingStack != null && missingStack.getStackSize() > 0) {
String str = Long.toString(missingStack.getStackSize());
if (missingStack.getStackSize() >= 10000) {
str = Long.toString(missingStack.getStackSize() / 1000) + 'k';
}
if (missingStack.getStackSize() >= 10000000) {
str = Long.toString(missingStack.getStackSize() / 1000000) + 'm';
}
str = GuiText.Missing.getLocal() + ": " + str;
final int w = 4 + this.fontRendererObj.getStringWidth(str);
this.fontRendererObj.drawString(
str,
(int) ((x * (1 + sectionLength) + xo + sectionLength - 19 - (w * 0.5)) * 2),
(y * offY + yo + 6 - negY + downY) * 2,
4210752);
if (this.tooltip == z - viewStart) {
lineList.add(GuiText.Missing.getLocal() + ": " + missingStack.getStackSize());
}
red = true;
downY += 5;
}
if (pendingStack != null && pendingStack.getStackSize() > 0) {
String str = Long.toString(pendingStack.getStackSize());
if (pendingStack.getStackSize() >= 10000) {
str = Long.toString(pendingStack.getStackSize() / 1000) + 'k';
}
if (pendingStack.getStackSize() >= 10000000) {
str = Long.toString(pendingStack.getStackSize() / 1000000) + 'm';
}
str = GuiText.ToCraft.getLocal() + ": " + str;
final int w = 4 + this.fontRendererObj.getStringWidth(str);
this.fontRendererObj.drawString(
str,
(int) ((x * (1 + sectionLength) + xo + sectionLength - 19 - (w * 0.5)) * 2),
(y * offY + yo + 6 - negY + downY) * 2,
4210752);
if (this.tooltip == z - viewStart) {
lineList.add(GuiText.ToCraft.getLocal() + ": " + Long.toString(pendingStack.getStackSize()));
}
}
GL11.glPopMatrix();
final int posX = x * (1 + sectionLength) + xo + sectionLength - 19;
final int posY = y * offY + yo;
final ItemStack is = CoreModHooks.displayFluid(refStack.copy());
if (this.tooltip == z - viewStart) {
dspToolTip = Platform.getItemDisplayName(is);
if (lineList.size() > 0) {
addItemTooltip(is, lineList);
dspToolTip = dspToolTip + '\n' + Joiner.on("\n").join(lineList);
}
toolPosX = x * (1 + sectionLength) + xo + sectionLength - 8;
toolPosY = y * offY + yo;
hoveredStack = is;
}
this.drawItem(posX, posY, is);
if (red) {
final int startX = x * (1 + sectionLength) + xo;
final int startY = posY - 4;
drawRect(startX, startY, startX + sectionLength, startY + offY, 0x1AFF0000);
}
x++;
if (x > 2) {
y++;
x = 0;
}
}
}
if (this.tooltip >= 0 && dspToolTip.length() > 0) {
this.drawTooltip(toolPosX, toolPosY + 10, 0, dspToolTip);
}
}
@Override
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
this.setScrollBar();
this.bindTexture("guis/craftingreport.png");
this.drawTexturedModalRect(offsetX, offsetY, 0, 0, this.xSize, this.ySize);
}
private void setScrollBar() {
final int size = this.visual.size();
this.getScrollBar().setTop(19).setLeft(218).setHeight(114);
this.getScrollBar().setRange(0, (size + 2) / 3 - this.rows, 1);
}
public void postUpdate(final List<IAEItemStack> list, final byte ref) {
switch (ref) {
case 0:
for (final IAEItemStack l : list) {
this.handleInput(this.storage, l);
}
break;
case 1:
for (final IAEItemStack l : list) {
this.handleInput(this.pending, l);
}
break;
case 2:
for (final IAEItemStack l : list) {
this.handleInput(this.missing, l);
}
break;
}
for (final IAEItemStack l : list) {
final long amt = this.getTotal(l);
if (amt <= 0) {
this.deleteVisualStack(l);
} else {
final IAEItemStack is = this.findVisualStack(l);
is.setStackSize(amt);
}
}
this.sortItems();
this.setScrollBar();
}
Comparator<IAEItemStack> comparator = (i1, i2) -> {
if (missing.findPrecise(i1) != null) {
if (missing.findPrecise(i2) != null) return 0;
return -1;
} else if (missing.findPrecise(i2) != null) {
return 1;
} else {
return 0;
}
};
private void sortItems() {
if (!this.missing.isEmpty()) {
this.visual.sort(comparator);
}
}
private void handleInput(final IItemList<IAEItemStack> s, final IAEItemStack l) {
IAEItemStack a = s.findPrecise(l);
if (l.getStackSize() <= 0) {
if (a != null) {
a.reset();
}
} else {
if (a == null) {
s.add(l.copy());
a = s.findPrecise(l);
}
if (a != null) {
a.setStackSize(l.getStackSize());
}
}
}
private long getTotal(final IAEItemStack is) {
final IAEItemStack a = this.storage.findPrecise(is);
final IAEItemStack c = this.pending.findPrecise(is);
final IAEItemStack m = this.missing.findPrecise(is);
long total = 0;
if (a != null) {
total += a.getStackSize();
}
if (c != null) {
total += c.getStackSize();
}
if (m != null) {
total += m.getStackSize();
}
return total;
}
private void deleteVisualStack(final IAEItemStack l) {
final Iterator<IAEItemStack> i = this.visual.iterator();
while (i.hasNext()) {
final IAEItemStack o = i.next();
if (o.equals(l)) {
i.remove();
return;
}
}
}
private IAEItemStack findVisualStack(final IAEItemStack l) {
for (final IAEItemStack o : this.visual) {
if (o.equals(l)) {
return o;
}
}
final IAEItemStack stack = l.copy();
this.visual.add(stack);
return stack;
}
@Override
protected void keyTyped(final char character, final int key) {
if (!this.checkHotbarKeys(key)) {
if (key == 28) {
this.actionPerformed(this.start);
}
super.keyTyped(character, key);
}
}
@Override
protected void actionPerformed(final GuiButton btn) {
super.actionPerformed(btn);
final boolean backwards = Mouse.isButtonDown(1);
if (btn == this.selectCPU) {
FluidCraft.proxy.netHandler
.sendToServer(new CPacketFluidPatternTermBtns("Terminal.Cpu", backwards ? "Prev" : "Next"));
}
if (btn == this.cancel) {
this.addMissingItemsToBookMark();
FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(this.OriginalGui));
}
if (btn == this.start) {
try {
FluidCraft.proxy.netHandler.sendToServer(new CPacketFluidPatternTermBtns("Terminal.Start", "Start"));
} catch (final Throwable e) {
AELog.debug(e);
}
}
}
@SuppressWarnings({ "rawtypes", "unchecked" })
protected void addItemTooltip(ItemStack is, List<String> lineList) {
if (isShiftKeyDown()) {
List l = is.getTooltip(this.mc.thePlayer, this.mc.gameSettings.advancedItemTooltips);
if (!l.isEmpty()) l.remove(0);
lineList.addAll(l);
} else if (ModAndClassUtil.isShiftTooltip) {
lineList.add(GuiText.HoldShiftForTooltip.getLocal());
}
}
public ItemStack getHoveredStack() {
return hoveredStack;
}
protected void addMissingItemsToBookMark() {
if (!this.missing.isEmpty() && isShiftKeyDown()) {
for (IAEItemStack iaeItemStack : this.missing) {
NEI.instance.addItemToBookMark(iaeItemStack.getItemStack());
}
}
}
public IItemList<IAEItemStack> getStorage() {
return this.storage;
}
public IItemList<IAEItemStack> getPending() {
return this.pending;
}
public IItemList<IAEItemStack> getMissing() {
return this.missing;
public void switchToOriginalGUI() {
FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(this.OriginalGui));
}
}
@@ -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() {
@@ -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;
}
}
}
@@ -16,7 +16,6 @@ import org.lwjgl.opengl.GL11;
import appeng.api.AEApi;
import appeng.api.config.*;
import appeng.api.util.DimensionalCoord;
import appeng.api.util.WorldCoord;
import appeng.client.gui.widgets.*;
import appeng.client.me.ClientDCInternalInv;
@@ -42,6 +41,7 @@ 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 {
@@ -52,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<>();
@@ -302,6 +302,7 @@ public class GuiInterfaceTerminalWireless extends FCBaseMEGui implements IDropTo
buttonList.add(terminalStyleBox);
buttonList.add(searchStringSave);
buttonList.add(craftingStatusBtn);
this.guiButtonHashMap.clear();
addSwitchGuiBtns();
int offset = 51;
@@ -351,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(
@@ -496,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();
@@ -526,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;
@@ -84,6 +84,7 @@ public abstract class FCGuiMonitor<T extends IAEStack<T>> extends FCBaseMEGui
protected GuiImgButton searchBoxSettings;
protected GuiImgButton terminalStyleBox;
protected GuiImgButton searchStringSave;
protected GuiImgButton typeFilter;
@SuppressWarnings("unchecked")
public FCGuiMonitor(final InventoryPlayer inventoryPlayer, final ITerminalHost te, final FCContainerMonitor<T> c) {
@@ -119,7 +120,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);
@@ -228,6 +229,15 @@ public abstract class FCGuiMonitor<T extends IAEStack<T>> extends FCBaseMEGui
this.configSrc.getSetting(Settings.VIEW_MODE)));
this.offsetY += 20;
}
if (ModAndClassUtil.isTypeFilter && this instanceof GuiItemMonitor) {
this.buttonList.add(
this.typeFilter = new GuiImgButton(
this.guiLeft - 18,
this.offsetY,
Settings.TYPE_FILTER,
this.configSrc.getSetting(Settings.TYPE_FILTER)));
this.offsetY += 20;
}
this.buttonList.add(
this.SortDirBox = new GuiImgButton(
@@ -314,7 +324,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);
}
}
@@ -658,6 +668,11 @@ public abstract class FCGuiMonitor<T extends IAEStack<T>> extends FCBaseMEGui
return this.configSrc.getSetting(Settings.VIEW_MODE);
}
@Override
public Enum getTypeFilter() {
return this.configSrc.getSetting(Settings.TYPE_FILTER);
}
@Override
public void updateSetting(final IConfigManager manager, final Enum settingName, final Enum newValue) {
if (this.SortByBox != null) {
@@ -671,6 +686,9 @@ public abstract class FCGuiMonitor<T extends IAEStack<T>> extends FCBaseMEGui
if (this.ViewBox != null) {
this.ViewBox.set(this.configSrc.getSetting(Settings.VIEW_MODE));
}
if (this.typeFilter != null) {
this.typeFilter.set(this.configSrc.getSetting(Settings.TYPE_FILTER));
}
this.repo.updateView();
}
@@ -1,265 +1,31 @@
package com.glodblock.github.client.gui.container;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Objects;
import java.util.concurrent.Future;
import javax.annotation.Nonnull;
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.util.ChatComponentText;
import net.minecraft.world.World;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.util.ForgeDirection;
import appeng.api.AEApi;
import appeng.api.config.Actionable;
import appeng.api.config.SecurityPermissions;
import appeng.api.networking.IGrid;
import appeng.api.networking.crafting.ICraftingCPU;
import appeng.api.networking.crafting.ICraftingGrid;
import appeng.api.networking.crafting.ICraftingJob;
import appeng.api.networking.crafting.ICraftingLink;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.networking.security.IActionHost;
import appeng.api.networking.security.PlayerSource;
import appeng.api.networking.storage.IStorageGrid;
import appeng.api.storage.IMEInventory;
import appeng.api.storage.ITerminalHost;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IItemList;
import appeng.container.AEBaseContainer;
import appeng.container.guisync.GuiSync;
import appeng.container.implementations.CraftingCPURecord;
import appeng.core.AELog;
import appeng.util.Platform;
import appeng.container.implementations.ContainerCraftConfirm;
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.network.SPacketMEInventoryUpdate;
import com.glodblock.github.util.Ae2Reflect;
import com.glodblock.github.inventory.item.IWirelessTerminal;
import com.glodblock.github.util.BlockPos;
import com.google.common.collect.ImmutableSet;
public class ContainerFluidCraftConfirm extends AEBaseContainer {
private final ArrayList<CraftingCPURecord> cpus = new ArrayList<CraftingCPURecord>();
private Future<ICraftingJob> job;
private ICraftingJob result;
@GuiSync(0)
public long bytesUsed;
@GuiSync(1)
public long cpuBytesAvail;
@GuiSync(2)
public int cpuCoProcessors;
@GuiSync(3)
public boolean autoStart = false;
@GuiSync(4)
public boolean simulation = true;
@GuiSync(5)
public int selectedCpu = -1;
@GuiSync(6)
public boolean noCPU = true;
@GuiSync(7)
public String myName = "";
public class ContainerFluidCraftConfirm extends ContainerCraftConfirm {
public ContainerFluidCraftConfirm(final InventoryPlayer ip, final ITerminalHost te) {
super(ip, te);
}
public void cycleCpu(final boolean next) {
if (next) {
this.setSelectedCpu(this.getSelectedCpu() + 1);
} else {
this.setSelectedCpu(this.getSelectedCpu() - 1);
}
if (this.getSelectedCpu() < -1) {
this.setSelectedCpu(this.cpus.size() - 1);
} else if (this.getSelectedCpu() >= this.cpus.size()) {
this.setSelectedCpu(-1);
}
if (this.getSelectedCpu() == -1) {
this.setCpuAvailableBytes(0);
this.setCpuCoProcessors(0);
this.setName("");
} else {
this.setName(Ae2Reflect.getName(this.cpus.get(this.getSelectedCpu())));
this.setCpuAvailableBytes(Ae2Reflect.getSize(this.cpus.get(this.getSelectedCpu())));
this.setCpuCoProcessors(Ae2Reflect.getProcessors(this.cpus.get(this.getSelectedCpu())));
}
}
@Override
public void detectAndSendChanges() {
if (Platform.isClient()) {
return;
}
if (getGrid() == null) return;
final ICraftingGrid cc = this.getGrid().getCache(ICraftingGrid.class);
final ImmutableSet<ICraftingCPU> cpuSet = cc.getCpus();
int matches = 0;
boolean changed = false;
for (final ICraftingCPU c : cpuSet) {
boolean found = false;
for (final CraftingCPURecord ccr : this.cpus) {
if (Ae2Reflect.getCPU(ccr) == c) {
found = true;
}
}
final boolean matched = this.cpuMatches(c);
if (matched) {
matches++;
}
if (found == !matched) {
changed = true;
}
}
if (changed || this.cpus.size() != matches) {
this.cpus.clear();
for (final ICraftingCPU c : cpuSet) {
if (this.cpuMatches(c)) {
this.cpus.add(new CraftingCPURecord(c.getAvailableStorage(), c.getCoProcessors(), c));
}
}
this.sendCPUs();
}
this.setNoCPU(this.cpus.isEmpty());
super.detectAndSendChanges();
if (this.getJob() != null && this.getJob().isDone()) {
try {
this.result = this.getJob().get();
if (!this.result.isSimulation()) {
this.setSimulation(false);
if (this.isAutoStart()) {
this.startJob();
return;
}
} else {
this.setSimulation(true);
}
final SPacketMEInventoryUpdate a = new SPacketMEInventoryUpdate((byte) 0);
final SPacketMEInventoryUpdate b = new SPacketMEInventoryUpdate((byte) 1);
final SPacketMEInventoryUpdate c = this.result.isSimulation() ? new SPacketMEInventoryUpdate((byte) 2)
: null;
final IItemList<IAEItemStack> plan = AEApi.instance().storage().createItemList();
this.result.populatePlan(plan);
this.setUsedBytes(this.result.getByteTotal());
for (final IAEItemStack out : plan) {
IAEItemStack o = out.copy();
o.reset();
o.setStackSize(out.getStackSize());
final IAEItemStack p = out.copy();
p.reset();
p.setStackSize(out.getCountRequestable());
final IStorageGrid sg = this.getGrid().getCache(IStorageGrid.class);
final IMEInventory<IAEItemStack> items = sg.getItemInventory();
IAEItemStack m = null;
if (c != null && this.result.isSimulation()) {
m = o.copy();
o = items.extractItems(o, Actionable.SIMULATE, this.getActionSource());
if (o == null) {
o = m.copy();
o.setStackSize(0);
}
m.setStackSize(m.getStackSize() - o.getStackSize());
}
if (o.getStackSize() > 0) {
a.appendItem(o);
}
if (p.getStackSize() > 0) {
b.appendItem(p);
}
if (c != null && m != null && m.getStackSize() > 0) {
c.appendItem(m);
}
}
for (final Object g : this.crafters) {
if (g instanceof EntityPlayer) {
FluidCraft.proxy.netHandler.sendTo(a, (EntityPlayerMP) g);
FluidCraft.proxy.netHandler.sendTo(b, (EntityPlayerMP) g);
if (c != null) {
FluidCraft.proxy.netHandler.sendTo(c, (EntityPlayerMP) g);
}
}
}
} catch (final Throwable e) {
this.getPlayerInv().player.addChatMessage(new ChatComponentText("Error: " + e.toString()));
AELog.debug(e);
this.setValidContainer(false);
this.result = null;
}
this.setJob(null);
}
this.verifyPermissions(SecurityPermissions.CRAFT, false);
}
private IGrid getGrid() {
final IActionHost h = ((IActionHost) this.getTarget());
if (h == null || h.getActionableNode() == null) return null;
return h.getActionableNode().getGrid();
}
private boolean cpuMatches(final ICraftingCPU c) {
return c.getAvailableStorage() >= this.getUsedBytes() && !c.isBusy();
}
private void sendCPUs() {
Collections.sort(this.cpus);
if (this.getSelectedCpu() >= this.cpus.size()) {
this.setSelectedCpu(-1);
this.setCpuAvailableBytes(0);
this.setCpuCoProcessors(0);
this.setName("");
} else if (this.getSelectedCpu() != -1) {
this.setName(Ae2Reflect.getName(this.cpus.get(this.getSelectedCpu())));
this.setCpuAvailableBytes(Ae2Reflect.getSize(this.cpus.get(this.getSelectedCpu())));
this.setCpuCoProcessors(Ae2Reflect.getProcessors(this.cpus.get(this.getSelectedCpu())));
}
}
public void startJob() {
public void switchToOriginalGUI() {
GuiType originalGui = null;
final IActionHost ah = this.getActionHost();
@@ -269,122 +35,26 @@ public class ContainerFluidCraftConfirm extends AEBaseContainer {
if (ah instanceof PartFluidPatternTerminalEx) {
originalGui = GuiType.FLUID_PATTERN_TERMINAL_EX;
}
if (this.result != null && !this.isSimulation() && getGrid() != null) {
final ICraftingGrid cc = this.getGrid().getCache(ICraftingGrid.class);
final ICraftingLink g = cc.submitJob(
this.result,
null,
this.getSelectedCpu() == -1 ? null : Ae2Reflect.getCPU(this.cpus.get(this.getSelectedCpu())),
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 (ah instanceof IWirelessTerminal) {
ItemStack terminal = ((IWirelessTerminal) ah).getItemStack();
if (terminal.getItem() instanceof ItemBaseWirelessTerminal) {
originalGui = ((ItemBaseWirelessTerminal) terminal.getItem()).guiGuiType(terminal);
}
}
}
private BaseActionSource getActionSrc() {
return new PlayerSource(this.getPlayerInv().player, (IActionHost) this.getTarget());
}
@Override
public void removeCraftingFromCrafters(final ICrafting c) {
super.removeCraftingFromCrafters(c);
if (this.getJob() != null) {
this.getJob().cancel(true);
this.setJob(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);
}
}
@Override
public void onContainerClosed(final EntityPlayer par1EntityPlayer) {
super.onContainerClosed(par1EntityPlayer);
if (this.getJob() != null) {
this.getJob().cancel(true);
this.setJob(null);
}
}
public World getWorld() {
return this.getPlayerInv().player.worldObj;
}
public boolean isAutoStart() {
return this.autoStart;
}
public void setAutoStart(final boolean autoStart) {
this.autoStart = autoStart;
}
public long getUsedBytes() {
return this.bytesUsed;
}
private void setUsedBytes(final long bytesUsed) {
this.bytesUsed = bytesUsed;
}
public long getCpuAvailableBytes() {
return this.cpuBytesAvail;
}
private void setCpuAvailableBytes(final long cpuBytesAvail) {
this.cpuBytesAvail = cpuBytesAvail;
}
public int getCpuCoProcessors() {
return this.cpuCoProcessors;
}
private void setCpuCoProcessors(final int cpuCoProcessors) {
this.cpuCoProcessors = cpuCoProcessors;
}
public int getSelectedCpu() {
return this.selectedCpu;
}
private void setSelectedCpu(final int selectedCpu) {
this.selectedCpu = selectedCpu;
}
public String getName() {
return this.myName;
}
private void setName(@Nonnull final String myName) {
this.myName = myName;
}
public boolean hasNoCPU() {
return this.noCPU;
}
private void setNoCPU(final boolean noCPU) {
this.noCPU = noCPU;
}
public boolean isSimulation() {
return this.simulation;
}
private void setSimulation(final boolean simulation) {
this.simulation = simulation;
}
private Future<ICraftingJob> getJob() {
return this.job;
}
public void setJob(final Future<ICraftingJob> job) {
this.job = job;
}
}
@@ -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();
}
}
@@ -61,6 +61,11 @@ public abstract class FCContainerMonitor<T extends IAEStack<T>> extends FCBaseCo
this.clientCM.registerSetting(Settings.SORT_BY, SortOrder.NAME);
this.clientCM.registerSetting(Settings.VIEW_MODE, ViewItems.ALL);
this.clientCM.registerSetting(Settings.SORT_DIRECTION, SortDir.ASCENDING);
this.clientCM.registerSetting(Settings.TYPE_FILTER, TypeFilter.ALL);
}
public IMEMonitor<T> getMonitor() {
return this.monitor;
}
public IGridNode getNetworkNode() {
@@ -112,7 +117,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);
}
@@ -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));
}
@@ -162,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));
@@ -173,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),
@@ -191,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;
}
}
@@ -82,6 +82,7 @@ public abstract class FCPart extends AEBasePart
this.cm.registerSetting(Settings.SORT_BY, SortOrder.NAME);
this.cm.registerSetting(Settings.VIEW_MODE, ViewItems.ALL);
this.cm.registerSetting(Settings.SORT_DIRECTION, SortDir.ASCENDING);
this.cm.registerSetting(Settings.TYPE_FILTER, TypeFilter.ALL);
}
@MENetworkEventSubscribe
@@ -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);
}
}
@@ -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;
}
@@ -2,16 +2,9 @@ package com.glodblock.github.coremod.hooker;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.GuiInterfaceTerminalWireless;
import com.glodblock.github.common.item.ItemWirelessInterfaceTerminal;
import com.glodblock.github.common.item.ItemWirelessUltraTerminal;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.network.CPacketSwitchGuis;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@@ -26,12 +19,4 @@ public class CoreModHooksClient {
}
}
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));
}
}
}
@@ -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/CoreModHooksClient",
"reopenInterfaceTerminal",
"()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> {
@@ -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();
}
@@ -95,6 +95,7 @@ public class WirelessCraftingTerminalInventory extends MEMonitorHandler<IAEItemS
out.registerSetting(Settings.SORT_BY, SortOrder.NAME);
out.registerSetting(Settings.VIEW_MODE, ViewItems.ALL);
out.registerSetting(Settings.SORT_DIRECTION, SortDir.ASCENDING);
out.registerSetting(Settings.TYPE_FILTER, TypeFilter.ALL);
out.readFromNBT((NBTTagCompound) Platform.openNbtData(this.target).copy());
return out;
}
@@ -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
@@ -129,6 +135,7 @@ public class WirelessPatternTerminalExInventory extends MEMonitorHandler<IAEItem
out.registerSetting(Settings.SORT_BY, SortOrder.NAME);
out.registerSetting(Settings.VIEW_MODE, ViewItems.ALL);
out.registerSetting(Settings.SORT_DIRECTION, SortDir.ASCENDING);
out.registerSetting(Settings.TYPE_FILTER, TypeFilter.ALL);
out.readFromNBT((NBTTagCompound) Platform.openNbtData(this.target).copy());
this.readFromNBT();
return out;
@@ -167,7 +174,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 +327,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 +402,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
@@ -131,6 +133,7 @@ public class WirelessPatternTerminalInventory extends MEMonitorHandler<IAEItemSt
out.registerSetting(Settings.SORT_BY, SortOrder.NAME);
out.registerSetting(Settings.VIEW_MODE, ViewItems.ALL);
out.registerSetting(Settings.SORT_DIRECTION, SortDir.ASCENDING);
out.registerSetting(Settings.TYPE_FILTER, TypeFilter.ALL);
out.readFromNBT((NBTTagCompound) Platform.openNbtData(this.target).copy());
this.readFromNBT();
return out;
@@ -169,7 +172,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 +239,7 @@ public class WirelessPatternTerminalInventory extends MEMonitorHandler<IAEItemSt
@Override
public boolean isInverted() {
return this.inverted;
return false;
}
@Override
@@ -212,7 +266,7 @@ public class WirelessPatternTerminalInventory extends MEMonitorHandler<IAEItemSt
@Override
public boolean isPrioritize() {
return this.prioritize;
return false;
}
@Override
@@ -245,6 +299,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 +374,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) {
@@ -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()));
}
}
}
}
@@ -0,0 +1,35 @@
package com.glodblock.github.loader.filter;
import static appeng.api.config.TypeFilter.*;
import net.minecraft.item.Item;
import appeng.api.config.TypeFilter;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IAEStack;
import appeng.client.me.ItemRepo;
import com.glodblock.github.common.item.ItemFluidDrop;
public class FluidFilter {
public static void installFilter() {
ItemRepo.registerTypeHandler(FluidFilter::filter, FLUIDS);
}
private static boolean filter(IAEStack<?> stack, TypeFilter typeFilter) {
if (typeFilter == ALL) return true;
if (stack instanceof IAEItemStack) {
Item item = ((IAEItemStack) stack).getItem();
if (item != null) {
switch (typeFilter) {
case ITEMS:
return !(item instanceof ItemFluidDrop);
case FLUIDS:
return item instanceof ItemFluidDrop;
}
}
}
return true;
}
}
@@ -1,9 +1,7 @@
package com.glodblock.github.nei;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Objects;
import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
import net.minecraft.item.ItemStack;
@@ -43,24 +41,11 @@ public class NEIUtils {
}
public static List<OrderStack<?>> clearNull(List<OrderStack<?>> list) {
List<OrderStack<?>> cleared = new LinkedList<>();
HashMap<Integer, Object> map = new HashMap<>();
int upper = 0;
for (OrderStack<?> orderStack : list) {
if (orderStack != null && orderStack.getStack() != null) {
if (orderStack.getStack() instanceof ItemStack && ((ItemStack) orderStack.getStack()).stackSize == 0)
continue;
map.put(orderStack.getIndex(), orderStack.getStack());
upper = Math.max(upper, orderStack.getIndex());
}
}
int id = 0;
for (int i = 0; i <= upper; i++) {
if (map.containsKey(i)) {
cleared.add(new OrderStack<>(map.get(i), id));
id++;
}
}
return cleared;
AtomicInteger i = new AtomicInteger(0);
return list.stream().filter(Objects::nonNull)
.filter(
orderStack -> !(orderStack.getStack() != null && orderStack.getStack() instanceof ItemStack
&& ((ItemStack) orderStack.getStack()).stackSize == 0))
.peek(orderStack -> orderStack.setIndex(i.getAndIncrement())).collect(Collectors.toList());
}
}
@@ -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);
}
}
}
@@ -1,10 +1,14 @@
package com.glodblock.github.nei.object;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.Nullable;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.oredict.OreDictionary;
@@ -15,7 +19,8 @@ import com.glodblock.github.util.Util;
public class OrderStack<T> {
private T RealStack;
private final int index;
private int index;
private ItemStack[] items;
public static final int ITEM = 1;
public static final int FLUID = 2;
@@ -28,10 +33,29 @@ public class OrderStack<T> {
this.index = order;
}
public OrderStack(T stack, int order, ItemStack[] items) {
this(stack, order);
if (items.length > 1) {
this.items = items;
}
}
public void putStack(T stack) {
this.RealStack = stack;
}
public void putItems(ItemStack[] items) {
this.items = items;
}
public ItemStack[] getItems() {
return this.items;
}
public final void setIndex(int i) {
this.index = i;
}
public T getStack() {
return RealStack;
}
@@ -71,6 +95,16 @@ public class OrderStack<T> {
NBTTagCompound tmp = new NBTTagCompound();
tmp.setByte("t", (byte) ITEM);
((ItemStack) RealStack).writeToNBT(tmp);
// replacement items
if (items != null) {
NBTTagList list = new NBTTagList();
for (ItemStack is : this.items) {
NBTTagCompound t = new NBTTagCompound();
is.writeToNBT(t);
list.appendTag(t);
}
tmp.setTag(index + ":", list);
}
buf.setTag(index + ":", tmp);
} else if (RealStack instanceof FluidStack) {
NBTTagCompound tmp = new NBTTagCompound();
@@ -91,7 +125,15 @@ public class OrderStack<T> {
byte id = info.getByte("t");
switch (id) {
case ITEM:
return new OrderStack<>(ItemStack.loadItemStackFromNBT(info), index);
List<ItemStack> list = new ArrayList<>();
if (info.hasKey(index + ":")) {
NBTTagList items = info.getTagList(index + ":", 10);
for (int x = 0; x < items.tagCount(); x++) {
final NBTTagCompound item = items.getCompoundTagAt(x);
list.add(ItemStack.loadItemStackFromNBT(item));
}
}
return new OrderStack<>(ItemStack.loadItemStackFromNBT(info), index, list.toArray(new ItemStack[0]));
case FLUID:
return new OrderStack<>(FluidStack.loadFluidStackFromNBT(info), index);
case CUSTOM:
@@ -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()));
@@ -1,9 +1,7 @@
package com.glodblock.github.nei.recipes;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidStack;
@@ -30,7 +28,8 @@ public final class FluidRecipe {
public static List<OrderStack<?>> getPackageInputs(IRecipeHandler recipe, int index, boolean priority) {
TemplateRecipeHandler tRecipe = (TemplateRecipeHandler) recipe;
if (tRecipe == null || !IdentifierMap.containsKey(tRecipe.getOverlayIdentifier())) return new ArrayList<>();
if (tRecipe == null) return new ArrayList<>();
if (!IdentifierMap.containsKey(tRecipe.getOverlayIdentifier())) return getDefaultPackageInputs(tRecipe, index);
if (tRecipe.getOverlayIdentifier() == null) return getPackageInputsLegacy(recipe, index);
IRecipeExtractor extractor = IdentifierMap.get(tRecipe.getOverlayIdentifier());
if (extractor == null) return new ArrayList<>();
@@ -54,9 +53,26 @@ public final class FluidRecipe {
return out;
}
private static List<OrderStack<?>> getDefaultPackageInputs(TemplateRecipeHandler tRecipe, int index) {
List<OrderStack<?>> tmp = new LinkedList<>();
AtomicInteger i = new AtomicInteger(0);
tRecipe.getIngredientStacks(index)
.forEach(ps -> tmp.add(new OrderStack<>(ps.item, i.getAndIncrement(), ps.items)));
return tmp;
}
private static List<OrderStack<?>> getDefaultPackageOutputs(TemplateRecipeHandler tRecipe, int index) {
List<OrderStack<?>> tmp = new LinkedList<>();
AtomicInteger i = new AtomicInteger(0);
tmp.add(new OrderStack<>(tRecipe.getResultStack(index).item, i.getAndIncrement()));
tRecipe.getOtherStacks(index).forEach(ps -> tmp.add(new OrderStack<>(ps.item, i.getAndIncrement())));
return tmp;
}
public static List<OrderStack<?>> getPackageOutputs(IRecipeHandler recipe, int index, boolean useOther) {
TemplateRecipeHandler tRecipe = (TemplateRecipeHandler) recipe;
if (tRecipe == null || !IdentifierMap.containsKey(tRecipe.getOverlayIdentifier())) return new ArrayList<>();
if (tRecipe == null) return new ArrayList<>();
if (!IdentifierMap.containsKey(tRecipe.getOverlayIdentifier())) return getDefaultPackageOutputs(tRecipe, index);
if (tRecipe.getOverlayIdentifier() == null) return getPackageOutputsLegacy(recipe, index, useOther);
IRecipeExtractor extractor = IdentifierMap.get(tRecipe.getOverlayIdentifier());
if (extractor == null) return new ArrayList<>();
@@ -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);
}
}
@@ -26,7 +26,7 @@ public final class ExtractorUtil {
return items.stream().map(item -> {
index.getAndIncrement();
Object o = transformer.apply(item);
return o != null ? new OrderStack<>(o, index.get()) : null;
return o != null ? new OrderStack<>(o, index.get(), item.items) : null;
}).filter(Objects::nonNull).collect(Collectors.toList());
}
}
@@ -16,11 +16,12 @@ import appeng.api.networking.crafting.ICraftingGrid;
import appeng.api.networking.crafting.ICraftingJob;
import appeng.container.ContainerOpenContext;
import appeng.container.implementations.ContainerCraftAmount;
import appeng.container.implementations.ContainerCraftConfirm;
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,17 +98,17 @@ 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);
}
if (player.openContainer instanceof ContainerFluidCraftConfirm) {
final ContainerFluidCraftConfirm ccc = (ContainerFluidCraftConfirm) player.openContainer;
if (player.openContainer instanceof ContainerCraftConfirm) {
final ContainerCraftConfirm ccc = (ContainerCraftConfirm) player.openContainer;
ccc.setAutoStart(message.heldShift);
ccc.setJob(futureJob);
cca.detectAndSendChanges();
@@ -2,7 +2,6 @@ package com.glodblock.github.network;
import net.minecraft.inventory.Container;
import com.glodblock.github.client.gui.container.ContainerFluidCraftConfirm;
import com.glodblock.github.client.gui.container.ContainerFluidStorageBus;
import com.glodblock.github.client.gui.container.base.FCContainerEncodeTerminal;
@@ -116,14 +115,11 @@ 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) {
final ContainerFluidCraftConfirm qk = (ContainerFluidCraftConfirm) c;
qk.cycleCpu(Value.equals("Next"));
} else if (Name.equals("Terminal.Start") && c instanceof ContainerFluidCraftConfirm) {
final ContainerFluidCraftConfirm qk = (ContainerFluidCraftConfirm) c;
qk.startJob();
} else if (Name.startsWith("StorageBus.") && c instanceof ContainerFluidStorageBus) {
final ContainerFluidStorageBus ccw = (ContainerFluidStorageBus) c;
if (Name.equals("StorageBus.Action")) {
@@ -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()),
@@ -12,8 +12,7 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.fluids.FluidStack;
import appeng.api.AEApi;
import appeng.api.config.FuzzyMode;
import appeng.api.storage.ITerminalHost;
import appeng.api.storage.IMEMonitor;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IItemList;
@@ -97,12 +96,10 @@ public class CPacketTransferRecipe implements IMessage {
public IMessage onMessage(CPacketTransferRecipe message, MessageContext ctx) {
Container c = ctx.getServerHandler().playerEntity.openContainer;
if (c instanceof ContainerItemMonitor) {
ITerminalHost host = ((ContainerItemMonitor) c).getHost();
IItemList<IAEItemStack> storageList;
if (host != null) {
storageList = host.getItemInventory().getStorageList();
} else {
storageList = AEApi.instance().storage().createItemList();
IMEMonitor<IAEItemStack> monitor = ((ContainerItemMonitor) c).getMonitor();
IItemList<IAEItemStack> storageList = AEApi.instance().storage().createItemList();
if (monitor != null) {
storageList = monitor.getStorageList();
}
if (c instanceof FCContainerEncodeTerminal) {
// pattern terminal only
@@ -130,15 +127,16 @@ public class CPacketTransferRecipe implements IMessage {
// using exists item to fill slot
if (message.shift && !storageList.isEmpty()) {
for (OrderStack stack : message.inputs) {
if (stack.getStack() instanceof FluidStack) continue;
ItemStack is = (ItemStack) stack.getStack();
IAEItemStack iaeItemStack = AEApi.instance().storage().createItemStack(is);
if (stack.getStack() instanceof FluidStack || stack.getItems() == null) continue;
IAEItemStack iaeItemStack = AEApi.instance().storage()
.createItemStack((ItemStack) stack.getStack());
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;
// try to replace item
for (ItemStack replaceItemStack : stack.getItems()) {
if (storageList.findPrecise(
AEApi.instance().storage().createItemStack(replaceItemStack)) != null) {
stack.putStack(replaceItemStack);
}
}
}
}
@@ -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,7 +25,9 @@ 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 isTypeFilter;
public static boolean isDoubleButton;
public static boolean isSaveText;
public static boolean isSearchStringTooltip;
@@ -110,6 +112,13 @@ public final class ModAndClassUtil {
} catch (ClassNotFoundException e) {
isV2 = false;
}
try {
Field filters = Class.forName("appeng.client.me.ItemRepo").getDeclaredField("filters");
if (filters == null) isTypeFilter = false;
isTypeFilter = true;
} catch (ClassNotFoundException | NoSuchFieldException e) {
isTypeFilter = false;
}
try {
essentiaGas = Class.forName("thaumicenergistics.common.fluids.GaseousEssentia");
@@ -130,5 +139,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;
}
}
@@ -85,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 -31
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;
@@ -32,6 +33,7 @@ import appeng.api.parts.IPart;
import appeng.api.storage.IMEInventoryHandler;
import appeng.api.storage.StorageChannel;
import appeng.api.storage.data.IAEFluidStack;
import appeng.api.util.DimensionalCoord;
import appeng.api.util.WorldCoord;
import appeng.container.AEBaseContainer;
import appeng.items.tools.powered.ToolWirelessTerminal;
@@ -40,10 +42,12 @@ 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);
@@ -118,10 +113,11 @@ public final class Util {
}
public static IMEInventoryHandler<?> getWirelessInv(ItemStack is, EntityPlayer player, StorageChannel channel) {
if (Platform.isClient()) return new NullInventory<>();
IGridNode gridNode = getWirelessGrid(is);
if (gridNode == null) return new NullInventory<>();
if (gridNode == null) return null;
IGrid grid = gridNode.getGrid();
if (grid == null) return new NullInventory<>();
if (grid == null) return null;
boolean canConnect = false;
if (hasInfinityBoosterCard(is)) {
canConnect = true;
@@ -149,7 +145,41 @@ public final class Util {
}
}
}
return new NullInventory<>();
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) {
@@ -343,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) {
@@ -352,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));
@@ -359,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) {
@@ -367,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));
}
@@ -507,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"));
}
}
}
@@ -100,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
@@ -124,13 +126,17 @@ ae2fc.tooltip.pattern_terminal_ex_w=Processing Pattern Terminal
ae2fc.tooltip.wireless.installed=Installed Card:
ae2fc.tooltip.not_prio=Allow fluids to be placed first
ae2fc.tooltip.not_prio.hint=Enabled
ae2fc.tooltip.not_prio.hint=Disabled
ae2fc.tooltip.prio=Allow fluids to be placed first
ae2fc.tooltip.prio.hint=Disabled
ae2fc.tooltip.prio.hint=Enabled
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
@@ -157,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
@@ -64,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=启用
@@ -99,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=空存储
@@ -123,13 +126,17 @@ ae2fc.tooltip.pattern_terminal_ex_w=增广样板终端
ae2fc.tooltip.wireless.installed=已安装的卡:
ae2fc.tooltip.not_prio=优先放置流体
ae2fc.tooltip.not_prio.hint=启用
ae2fc.tooltip.not_prio.hint=禁用
ae2fc.tooltip.prio=优先放置流体
ae2fc.tooltip.prio.hint=禁用
ae2fc.tooltip.prio.hint=启用
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增广流体样板终端
@@ -156,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