Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 20 additions & 18 deletions src/main/java/logisticspipes/gui/GuiCraftingPipe.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ public class GuiCraftingPipe extends ModuleBaseGui {

private GuiButton cleanupModeButton;

private FluidCraftingExtention fluidCraftingExtention = null;

public GuiCraftingPipe(EntityPlayer player, IInventory dummyInventory, ModuleCrafter module, boolean isAdvancedSat,
int liquidCrafter, int[] amount, boolean hasByproductExtractor, boolean isFuzzy, int cleanupSize,
boolean cleanupExclude) {
Expand Down Expand Up @@ -139,10 +141,10 @@ public void initGui() {
super.initGui();
extentionControllerLeft.clear();
buttonList.clear();
FluidCraftingExtention extention = null;
fluidCraftingExtention = null;
if (!isAdvancedSat) {
if (liquidCrafter != 0) {
extention = new FluidCraftingExtention(0);
fluidCraftingExtention = new FluidCraftingExtention(0);
}
addButton(
normalButtonArray[0] = new SmallGuiButton(
Expand Down Expand Up @@ -193,7 +195,7 @@ public void initGui() {
10,
"<"));
if (liquidCrafter != 0) {
extention.registerButton(
fluidCraftingExtention.registerButton(
extentionControllerLeft.registerControlledButton(
addButton(
normalButtonArray[6] = new SmallGuiButton(
Expand All @@ -203,7 +205,7 @@ public void initGui() {
10,
10,
">"))));
extention.registerButton(
fluidCraftingExtention.registerButton(
extentionControllerLeft.registerControlledButton(
addButton(
normalButtonArray[7] = new SmallGuiButton(
Expand Down Expand Up @@ -268,7 +270,7 @@ public void initGui() {
}
for (int i = 0; i < liquidCrafter; i++) {
if (isAdvancedSat) {
extention = new FluidCraftingExtention(i);
fluidCraftingExtention = new FluidCraftingExtention(i);
}
int liquidLeft = 0;
if (isAdvancedSat) {
Expand All @@ -277,7 +279,7 @@ public void initGui() {
liquidLeft = guiLeft - (liquidCrafter * 40) + (i * 40);
}
liquidGuiParts[i] = new GuiButton[10];
extention.registerButton(
fluidCraftingExtention.registerButton(
extentionControllerLeft.registerControlledButton(
addButton(
liquidGuiParts[i][0] = new SmallGuiButton(
Expand All @@ -287,7 +289,7 @@ public void initGui() {
10,
10,
"+"))));
extention.registerButton(
fluidCraftingExtention.registerButton(
extentionControllerLeft.registerControlledButton(
addButton(
liquidGuiParts[i][1] = new SmallGuiButton(
Expand All @@ -297,7 +299,7 @@ public void initGui() {
10,
10,
"+"))));
extention.registerButton(
fluidCraftingExtention.registerButton(
extentionControllerLeft.registerControlledButton(
addButton(
liquidGuiParts[i][2] = new SmallGuiButton(
Expand All @@ -307,7 +309,7 @@ public void initGui() {
10,
10,
"+"))));
extention.registerButton(
fluidCraftingExtention.registerButton(
extentionControllerLeft.registerControlledButton(
addButton(
liquidGuiParts[i][3] = new SmallGuiButton(
Expand All @@ -317,7 +319,7 @@ public void initGui() {
10,
10,
"+"))));
extention.registerButton(
fluidCraftingExtention.registerButton(
extentionControllerLeft.registerControlledButton(
addButton(
liquidGuiParts[i][4] = new SmallGuiButton(
Expand All @@ -327,7 +329,7 @@ public void initGui() {
10,
10,
"-"))));
extention.registerButton(
fluidCraftingExtention.registerButton(
extentionControllerLeft.registerControlledButton(
addButton(
liquidGuiParts[i][5] = new SmallGuiButton(
Expand All @@ -337,7 +339,7 @@ public void initGui() {
10,
10,
"-"))));
extention.registerButton(
fluidCraftingExtention.registerButton(
extentionControllerLeft.registerControlledButton(
addButton(
liquidGuiParts[i][6] = new SmallGuiButton(
Expand All @@ -347,7 +349,7 @@ public void initGui() {
10,
10,
"-"))));
extention.registerButton(
fluidCraftingExtention.registerButton(
extentionControllerLeft.registerControlledButton(
addButton(
liquidGuiParts[i][7] = new SmallGuiButton(
Expand All @@ -358,7 +360,7 @@ public void initGui() {
10,
"-"))));
if (isAdvancedSat) {
extention.registerButton(
fluidCraftingExtention.registerButton(
extentionControllerLeft.registerControlledButton(
addButton(
liquidGuiParts[i][8] = new SmallGuiButton(
Expand All @@ -368,7 +370,7 @@ public void initGui() {
10,
10,
"<"))));
extention.registerButton(
fluidCraftingExtention.registerButton(
extentionControllerLeft.registerControlledButton(
addButton(
liquidGuiParts[i][9] = new SmallGuiButton(
Expand All @@ -378,12 +380,12 @@ public void initGui() {
10,
10,
">"))));
extentionControllerLeft.addExtention(extention);
extentionControllerLeft.addExtention(fluidCraftingExtention);
}
extention.registerSlot(fluidSlotIDs[i]);
fluidCraftingExtention.registerSlot(fluidSlotIDs[i]);
}
if (!isAdvancedSat && liquidCrafter != 0) {
extentionControllerLeft.addExtention(extention);
extentionControllerLeft.addExtention(fluidCraftingExtention);
}
if (hasByproductExtractor) {
ByproductExtention byproductExtention = new ByproductExtention();
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/logisticspipes/gui/modules/ModuleBaseGui.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ public ModuleBaseGui(Container par1Container, LogisticsGuiModule module) {

@Override
protected void keyTyped(char c, int i) {
if (module == null) {
super.keyTyped(c, i);
return;
}
// Fix for NEI integration
super.keyTyped(c, i);

if (module == null) return;

if (i == 1 || c == 'e') {
super.keyTyped(c, i);
if (module.getSlot() == ModulePositionType.SLOT) {
MainProxy.sendPacketToServer(
PacketHandler.getPacket(GuiOpenChassie.class).setPosX(module.getX()).setPosY(module.getY())
Expand Down
48 changes: 42 additions & 6 deletions src/main/java/logisticspipes/gui/popup/GuiRecipeImport.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@
import net.minecraft.client.renderer.entity.RenderItem;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.fluids.FluidStack;

import logisticspipes.network.PacketHandler;
import logisticspipes.network.abstractpackets.ModuleCoordinatesPacket;
import logisticspipes.network.packets.NEISetAdvancedCraftingRecipe;
import logisticspipes.network.packets.NEISetCraftingRecipe;
import logisticspipes.network.packets.pipe.FindMostLikelyRecipeComponents;
import logisticspipes.proxy.MainProxy;
Expand All @@ -38,13 +41,24 @@ public Canidates(Set<ItemIdentifierStack> set) {

private final RenderItem itemRenderer = new RenderItem();
private final TileEntity tile;
private final ModuleCoordinatesPacket modulePacket;
private final List<ItemStack> outputs;
private final List<FluidStack> fluidInputs;
private final Canidates[] grid = new Canidates[9];
private final List<Canidates> list;
private Object[] tooltip = null;

public GuiRecipeImport(TileEntity tile, ItemStack[][] stacks) {
this(tile, stacks, null, null, null);
}

public GuiRecipeImport(TileEntity tile, ItemStack[][] stacks, ModuleCoordinatesPacket modulePacket,
List<ItemStack> outputs, List<FluidStack> fluidInputs) {
super(150, 200, 0, 0);
this.tile = tile;
this.modulePacket = modulePacket;
this.outputs = outputs;
this.fluidInputs = fluidInputs;
list = new ArrayList<>();
for (int i = 0; i < 9; i++) {
if (stacks[i] == null) {
Expand Down Expand Up @@ -133,7 +147,7 @@ protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
itemStack,
guiLeft + 45 + x * 18,
guiTop + 20 + y * 18,
null);
itemStack.stackSize > 1 ? String.valueOf(itemStack.stackSize) : null);

if (guiLeft + 45 + x * 18 < mouseX && mouseX < guiLeft + 45 + x * 18 + 16
&& guiTop + 20 + y * 18 < mouseY
Expand Down Expand Up @@ -234,13 +248,35 @@ protected void actionPerformed(GuiButton button) {
}
stack[i++] = canidate.order.get(canidate.pos).makeNormalStack();
}
NEISetCraftingRecipe packet = PacketHandler.getPacket(NEISetCraftingRecipe.class);
MainProxy.sendPacketToServer(
packet.setContent(stack).setPosX(tile.xCoord).setPosY(tile.yCoord).setPosZ(tile.zCoord));
if (modulePacket instanceof NEISetAdvancedCraftingRecipe) {
List<ItemStack> inputs = new ArrayList<>();
for (ItemStack s : stack) {
if (s != null) {
inputs.add(s);
}
}
((NEISetAdvancedCraftingRecipe) modulePacket).setInputs(inputs).setOutputs(outputs)
.setFluidInputs(fluidInputs);
MainProxy.sendPacketToServer(modulePacket);
} else {
NEISetCraftingRecipe packet = PacketHandler.getPacket(NEISetCraftingRecipe.class);
MainProxy.sendPacketToServer(
packet.setContent(stack).setPosX(tile.xCoord).setPosY(tile.yCoord).setPosZ(tile.zCoord));
}
exitGui();
} else if (id == 1) {
MainProxy.sendPacketToServer(
PacketHandler.getPacket(FindMostLikelyRecipeComponents.class).setContent(list).setTilePos(tile));
FindMostLikelyRecipeComponents packet = PacketHandler.getPacket(FindMostLikelyRecipeComponents.class)
.setContent(list);
if (tile != null) {
packet.setTilePos(tile);
} else if (modulePacket != null) {
packet.setPosX(modulePacket.getPosX());
packet.setPosY(modulePacket.getPosY());
packet.setPosZ(modulePacket.getPosZ());
} else {
return;
}
MainProxy.sendPacketToServer(packet);
} else if (id >= 10 && id < 30) {
int slot = id % 10;
boolean up = id < 20;
Expand Down
46 changes: 46 additions & 0 deletions src/main/java/logisticspipes/modules/ModuleCrafter.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import net.minecraft.world.World;
import net.minecraftforge.common.util.Constants;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.FluidStack;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
Expand Down Expand Up @@ -968,6 +969,51 @@ public void setDummyInventorySlot(int slot, ItemStack itemstack) {
_dummyInventory.setInventorySlotContents(slot, itemstack);
}

public void handleNEIRecipePacket(ItemStack[] content, EntityPlayer player) {
_dummyInventory.clearGrid();
for (int i = 0; i < content.length; i++) {
if (i < _dummyInventory.getSizeInventory()) {
_dummyInventory.setInventorySlotContents(i, content[i]);
}
}
if (player != null) {
MainProxy.sendPacketToPlayer(getCPipePacket(), player);
}
}

public void handleAdvancedNEIRecipePacket(List<ItemStack> inputs, List<ItemStack> outputs,
List<FluidStack> fluidInputs, EntityPlayer player) {
_dummyInventory.clearGrid();
int itemSlot = 0;
for (int i = 0; i < inputs.size() && itemSlot < 9; i++) {
ItemStack stack = inputs.get(i);
_dummyInventory.setInventorySlotContents(itemSlot++, stack);
}
if (!outputs.isEmpty()) {
_dummyInventory.setInventorySlotContents(9, outputs.get(0));
if (outputs.size() > 1) {
_dummyInventory.setInventorySlotContents(10, outputs.get(1));
}
}

// Populate liquids
_liquidInventory.clearGrid();
for (int i = 0; i < amount.length; i++) {
amount[i] = 0;
}

for (int i = 0; i < fluidInputs.size() && i < _liquidInventory.getSizeInventory(); i++) {
FluidStack fs = fluidInputs.get(i);
if (fs != null && fs.getFluid() != null) {
_liquidInventory.setInventorySlotContents(i, FluidIdentifier.get(fs).getItemIdentifier().makeStack(1));
amount[i] = fs.amount;
}
}
if (player != null) {
MainProxy.sendPacketToPlayer(getCPipePacket(), player);
}
}

public void importFromCraftingTable(EntityPlayer player) {
if (MainProxy.isClient(getWorld())) {
// Send packet asking for import
Expand Down
Loading