Fix #459 Enable automation of the Thermionic Fabricator

This commit is contained in:
mezz committed 2015-02-15 17:34:22 -08:00
1 parent 5f8661a17f
commit 1ac0cf5489
6 files changed
+39 -15

No files matched your search

@@ -355,6 +355,7 @@ public class MachineFabricator extends TilePowered implements ICrafter, ILiquidT
@Override
public boolean workCycle() {
craftResult(false, null);
return addHeat(25);
}
@@ -409,14 +410,28 @@ public class MachineFabricator extends TilePowered implements ICrafter, ILiquidT
return null;
}
craftResult(consumeRecipe, player);
IInventoryAdapter inventory = getInternalInventory();
// Return result
return inventory.decrStackSize(SLOT_RESULT, 1);
}
private void craftResult(boolean consumeRecipe, EntityPlayer player) {
Recipe myRecipe = getRecipe();
if (myRecipe == null) {
return null;
return;
}
IInventoryAdapter inventory = getInternalInventory();
if (inventory.getStackInSlot(SLOT_RESULT) != null) {
return;
}
FluidStack liquid = myRecipe.molten;
IInventoryAdapter inventory = getInternalInventory();
// Remove resources
ItemStack[] crafting = InvTools.getStacks(inventory, SLOT_CRAFTING_1, SLOT_CRAFTING_COUNT);
if (removeFromInventory(1, crafting, player, false)) {
@@ -426,10 +441,10 @@ public class MachineFabricator extends TilePowered implements ICrafter, ILiquidT
removeFromCraftMatrix(myRecipe);
moltenTank.drain(liquid.amount, true);
} else {
return null;
return;
}
ItemStack result = myRecipe.internal.getRecipeOutput().copy();
ItemStack result = getResult();
// Damage plan
if (inventory.getStackInSlot(SLOT_PLAN) != null) {
Item planItem = inventory.getStackInSlot(SLOT_PLAN).getItem();
@@ -438,8 +453,7 @@ public class MachineFabricator extends TilePowered implements ICrafter, ILiquidT
}
}
// Return result
return result;
inventory.setInventorySlotContents(SLOT_RESULT, result);
}
private void removeFromCraftMatrix(Recipe recipe) {
@@ -17,6 +17,7 @@ import net.minecraft.inventory.InventoryCraftResult;
import net.minecraft.inventory.Slot;
import forestry.core.gui.ContainerLiquidTanks;
import forestry.core.gui.slots.SlotCraftMatrix;
import forestry.core.gui.slots.SlotFiltered;
import forestry.core.gui.slots.SlotLocked;
import forestry.core.gui.slots.SlotOutput;
@@ -11,14 +11,17 @@
package forestry.factory.gui;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import forestry.core.gui.ContainerLiquidTanks;
import forestry.core.gui.slots.SlotCrafter;
import forestry.core.gui.slots.SlotCraftMatrix;
import forestry.core.gui.slots.SlotFiltered;
import forestry.core.gui.slots.SlotOutput;
import forestry.core.interfaces.IContainerCrafting;
import forestry.factory.gadgets.MachineFabricator;
public class ContainerFabricator extends ContainerLiquidTanks {
public class ContainerFabricator extends ContainerLiquidTanks implements IContainerCrafting {
public ContainerFabricator(InventoryPlayer playerInventory, MachineFabricator tile) {
super(tile);
@@ -37,12 +40,12 @@ public class ContainerFabricator extends ContainerLiquidTanks {
this.addSlotToContainer(new SlotFiltered(tile, MachineFabricator.SLOT_PLAN, 139, 17));
// Result
this.addSlotToContainer(new SlotCrafter(playerInventory.player, tile, tile, MachineFabricator.SLOT_RESULT, 139, 53));
this.addSlotToContainer(new SlotOutput(tile, MachineFabricator.SLOT_RESULT, 139, 53));
// Crafting matrix
for (int l = 0; l < 3; l++) {
for (int k = 0; k < 3; k++) {
addSlotToContainer(new Slot(tile, MachineFabricator.SLOT_CRAFTING_1 + k + l * 3, 67 + k * 18, 17 + l * 18));
addSlotToContainer(new SlotCraftMatrix(this, tile, MachineFabricator.SLOT_CRAFTING_1 + k + l * 3, 67 + k * 18, 17 + l * 18));
}
}
@@ -59,4 +62,8 @@ public class ContainerFabricator extends ContainerLiquidTanks {
}
@Override
public void onCraftMatrixChanged(IInventory iinventory, int slot) {
}
}
@@ -18,6 +18,7 @@ import net.minecraft.item.ItemStack;
import forestry.core.gui.ContainerForestry;
import forestry.core.gui.IGuiSelectable;
import forestry.core.gui.slots.SlotCraftMatrix;
import forestry.core.gui.slots.SlotCrafter;
import forestry.core.interfaces.IContainerCrafting;
import forestry.core.network.PacketIds;
@@ -1,40 +0,0 @@
/*******************************************************************************
* Copyright (c) 2011-2014 SirSengir.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.factory.gui;
import net.minecraft.inventory.IInventory;
import forestry.core.gui.slots.SlotForestry;
import forestry.core.interfaces.IContainerCrafting;
/**
* Informs the passed container of slot changes. Contains a dummy itemstack.
*/
public class SlotCraftMatrix extends SlotForestry {
private final IContainerCrafting eventHandler;
private final int slot;
public SlotCraftMatrix(IContainerCrafting container, IInventory iinventory, int i, int j, int k) {
super(iinventory, i, j, k);
setPhantom();
this.eventHandler = container;
this.slot = i;
stackLimit = 1;
}
@Override
public void onSlotChanged() {
super.onSlotChanged();
eventHandler.onCraftMatrixChanged(inventory, slot);
}
}