private void handleTileReached(TravelingItem item, TileEntity tile) { if (passToNextPipe(item, tile)) { // NOOP } else if (tile instanceof IInventory) { if (CoreProxy.proxy.isSimulating(container.worldObj)) { if (item.getInsertionHandler().canInsertItem(item, (IInventory) tile)) { ItemStack added = Transactor.getTransactorFor(tile) .add(item.getItemStack(), item.output.getOpposite(), true); item.getItemStack().stackSize -= added.stackSize; } if (item.getItemStack().stackSize > 0) { reverseItem(item); } } } else { if (travelHook != null) { travelHook.drop(this, item); } EntityItem dropped = item.toEntityItem(item.output); if (dropped != null) { // On SMP, the client side doesn't actually drops // items onDropped(dropped); } } }
private void craftItem() { ItemStack recipeOutput = getRecipeOutput(); craftSlot.onPickupFromSlot(internalPlayer, recipeOutput); ItemStack[] tempStorage = internalInventoryCrafting.tempStacks; for (int i = 0; i < tempStorage.length; i++) { if (tempStorage[i] != null && tempStorage[i].stackSize <= 0) { tempStorage[i] = null; } inv.getItemStacks()[i] = tempStorage[i]; } subtractEnergy(getRequiredEnergy()); List<ItemStack> outputs = Lists.newArrayList(recipeOutput.copy()); for (int i = 0; i < internalPlayer.inventory.mainInventory.length; i++) { if (internalPlayer.inventory.mainInventory[i] != null) { outputs.add(internalPlayer.inventory.mainInventory[i]); internalPlayer.inventory.mainInventory[i] = null; } } for (ItemStack output : outputs) { output.stackSize -= Transactor.getTransactorFor(invOutput).add(output, ForgeDirection.UP, true).stackSize; if (output.stackSize > 0) { output.stackSize -= Utils.addToRandomInventoryAround(worldObj, xCoord, yCoord, zCoord, output); } if (output.stackSize > 0) { InvUtils.dropItems(worldObj, output, xCoord, yCoord + 1, zCoord); } } }
public boolean canReceivePipeObjects(ForgeDirection o, TravelingItem item) { TileEntity entity = container.getTile(o); if (!container.isPipeConnected(o)) return false; if (entity instanceof TileGenericPipe) { TileGenericPipe pipe = (TileGenericPipe) entity; return pipe.pipe.transport instanceof PipeTransportItems; } else if (entity instanceof IInventory && item.getInsertionHandler().canInsertItem(item, (IInventory) entity)) if (Transactor.getTransactorFor(entity) .add(item.getItemStack(), o.getOpposite(), false) .stackSize > 0) return true; return false; }