Make crafting INSTANT!

This commit is contained in:
Raoul Van den Berge
2016-03-28 23:29:55 +02:00
parent 1991c64da3
commit 2c32b31385
2 changed files with 8 additions and 20 deletions

View File

@@ -23,16 +23,6 @@ public class SlotGridCraftingResult extends SlotCrafting {
@Override @Override
public void onPickupFromSlot(EntityPlayer player, ItemStack stack) { public void onPickupFromSlot(EntityPlayer player, ItemStack stack) {
ItemStack[] matrixSlots = new ItemStack[craftingMatrix.getSizeInventory()]; grid.onCrafted(container);
for (int i = 0; i < craftingMatrix.getSizeInventory(); ++i) {
if (craftingMatrix.getStackInSlot(i) != null) {
matrixSlots[i] = craftingMatrix.getStackInSlot(i).copy();
}
}
super.onPickupFromSlot(player, stack);
grid.onCrafted(container, matrixSlots);
} }
} }

View File

@@ -11,8 +11,8 @@ import net.minecraft.nbt.NBTTagCompound;
import refinedstorage.RefinedStorageBlocks; import refinedstorage.RefinedStorageBlocks;
import refinedstorage.block.BlockGrid; import refinedstorage.block.BlockGrid;
import refinedstorage.block.EnumGridType; import refinedstorage.block.EnumGridType;
import refinedstorage.container.ContainerGrid;
import refinedstorage.inventory.InventorySimple; import refinedstorage.inventory.InventorySimple;
import refinedstorage.storage.StorageItem;
import refinedstorage.util.InventoryUtils; import refinedstorage.util.InventoryUtils;
public class TileGrid extends TileMachine { public class TileGrid extends TileMachine {
@@ -73,18 +73,16 @@ public class TileGrid extends TileMachine {
craftingResultInventory.setInventorySlotContents(0, CraftingManager.getInstance().findMatchingRecipe(craftingInventory, worldObj)); craftingResultInventory.setInventorySlotContents(0, CraftingManager.getInstance().findMatchingRecipe(craftingInventory, worldObj));
} }
public void onCrafted(Container container, ItemStack[] matrixSlots) { public void onCrafted(ContainerGrid container) {
if (isConnected() && !worldObj.isRemote) { if (isConnected() && !worldObj.isRemote) {
for (int i = 0; i < craftingInventory.getSizeInventory(); ++i) { for (int i = 0; i < craftingInventory.getSizeInventory(); ++i) {
ItemStack slot = craftingInventory.getStackInSlot(i); ItemStack slot = craftingInventory.getStackInSlot(i);
if (slot == null && matrixSlots[i] != null) { if (slot != null) {
for (StorageItem item : getController().getItems()) { if (slot.stackSize == 1) {
if (item.compareNoQuantity(matrixSlots[i].copy())) { craftingInventory.setInventorySlotContents(i, getController().take(slot.copy()));
craftingInventory.setInventorySlotContents(i, getController().take(matrixSlots[i].copy())); } else {
craftingInventory.decrStackSize(i, 1);
break;
}
} }
} }
} }