@Override
	public UnitItemStack[] write(DataOutputStream out, PassthroughConnection ptc, KillableThread thread, boolean serverToClient) {

		if(length == null || value == null) {
			return null;
		}
		
		length = lengthUnit.write(out, ptc, thread, serverToClient);
		if(length == null) {
			return null;
		}
		
		if(length > 0xFFFF) {
			ptc.printLogMessage("To many item window updates in one packet - breaking connection");
			return null;
		}
		
		ItemStack temp = null;
		
		for(int cnt=0;cnt<length;cnt++) {
			
			if(value[cnt] == null) {
				return null;
			}
			
			temp = value[cnt].write(out, ptc, thread, serverToClient);
			
			if(temp == null) {
				return null;
			}
		}
		
		return value;
		

	}