mirror of
https://github.com/GTNewHorizons/EnderIO.git
synced 2026-11-20 12:19:55 +00:00
Change the crafter to function on a buffer as per request.
This commit is contained in:
1 parent
6c308fade5
commit
cfd32a7ef8
1 file changed
+25
-1
@@ -1,7 +1,9 @@
|
||||
package crazypants.enderio.machine.crafter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
@@ -19,8 +21,12 @@ public class TileCrafter extends AbstractMachineEntity {
|
||||
|
||||
DummyCraftingGrid craftingGrid = new DummyCraftingGrid();
|
||||
|
||||
private Set<ItemStack> containerItems;
|
||||
|
||||
public TileCrafter() {
|
||||
super(new SlotDefinition(9, 1));
|
||||
super(new SlotDefinition(9, 1));
|
||||
|
||||
containerItems = new HashSet<ItemStack>();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -59,6 +65,20 @@ public class TileCrafter extends AbstractMachineEntity {
|
||||
return false;
|
||||
}
|
||||
|
||||
// process buffered container items
|
||||
if(!containerItems.isEmpty()) {
|
||||
for(ItemStack i : containerItems) {
|
||||
if(inventory[9] == null) {
|
||||
inventory[9] = i;
|
||||
containerItems.remove(i);
|
||||
} else if(ItemStack.areItemStacksEqual(inventory[9], i) && inventory[9].stackSize + i.stackSize <= inventory[9].getMaxStackSize()) {
|
||||
inventory[9].stackSize += i.stackSize;
|
||||
containerItems.remove(i);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
List<ItemStack> required = new ArrayList<ItemStack>();
|
||||
craftingGrid.copyRequiredInputs(required);
|
||||
if(hasRequiredInput(required)) {
|
||||
@@ -81,6 +101,10 @@ public class TileCrafter extends AbstractMachineEntity {
|
||||
avail.stackSize--;
|
||||
if(avail.stackSize <= 0) {
|
||||
avail = avail.getItem().getContainerItem(avail);
|
||||
if (avail != null) {
|
||||
containerItems.add(avail.copy());
|
||||
avail = null;
|
||||
}
|
||||
}
|
||||
setInventorySlotContents(i, avail);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user