mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-19 03:39:09 +00:00
Fix #459 Enable automation of the Thermionic Fabricator
This commit is contained in:
1 parent
5f8661a17f
commit
1ac0cf5489
6 files changed
+39
-15
No files matched your search
Executable → Regular
+1
-2
@@ -8,11 +8,10 @@
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.factory.gui;
|
||||
package forestry.core.gui.slots;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
|
||||
import forestry.core.gui.slots.SlotForestry;
|
||||
import forestry.core.interfaces.IContainerCrafting;
|
||||
|
||||
/**
|
||||
@@ -372,7 +372,9 @@ public class StackUtils {
|
||||
ItemStack container = itemstack.getItem().getContainerItem(itemstack);
|
||||
|
||||
if (container.isItemStackDamageable() && container.getItemDamage() > container.getMaxDamage()) {
|
||||
MinecraftForge.EVENT_BUS.post(new PlayerDestroyItemEvent(player, container));
|
||||
if (player != null) {
|
||||
MinecraftForge.EVENT_BUS.post(new PlayerDestroyItemEvent(player, container));
|
||||
}
|
||||
container = null;
|
||||
}
|
||||
|
||||
@@ -380,13 +382,13 @@ public class StackUtils {
|
||||
|
||||
if (itemstack.getItem().doesContainerItemLeaveCraftingGrid(itemstack)) {
|
||||
if (!InvTools.tryAddStack(stowing, container, true)) {
|
||||
if (!player.inventory.addItemStackToInventory(container)) {
|
||||
if (player != null && !player.inventory.addItemStackToInventory(container)) {
|
||||
player.dropPlayerItemWithRandomChoice(container, true);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (!InvTools.tryAddStack(stowing, container, slotIndex, 1, true)) {
|
||||
if (!InvTools.tryAddStack(stowing, container, true)) {
|
||||
if (!InvTools.tryAddStack(stowing, container, true) && player != null) {
|
||||
player.dropPlayerItemWithRandomChoice(container, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in new issue
Block a user